  We present a generalization of Rastall's gravity in which the conservation
law of the energy-momentum tensor is altered, and as a result, the trace of the
energy-momentum tensor is taken into account together with the Ricci scalar in
the expression for the covariant derivative. Afterwards, we obtain the field
equations in this theory and solve them by considering a spherically symmetric
space-time. We show that the external solution has two possible classes of
solutions with spherical symmetry in the vacuum in generalized Rastall's
gravity, and we analyse one of them explicitly. The generalization, in contrast
to constant value $k=8\pi G$ in general relativity, has a gravitational
parameter $k$ that depends on the Rastall constant $\alpha$. As an application,
we perform a careful analysis of the effects of the theory on neutron stars
using realistic equations of state (EoS) as input. Our results show that
important differences on the profile of neutron stars are obtained within two
representatives EoS.
