  We want to investigate how planet formation is imprinted on stellar surface
composition using up-to-date stellar evolution models. We simulate the
evolution of pre-main-sequence stars as a function of the efficiency of heat
injection during accretion, the deuterium mass fraction, and the stellar mass.
For simplicity, we assume that planet formation leads to the late accretion of
zero-metallicity gas, diluting the surface stellar composition as a function of
the mass of the stellar outer convective zone. We adopt
$150\,{\mathrm{M}_\oplus}(M_\star/\mathrm{M}_\odot)(Z/\mathrm{Z}_\odot)$ as an
uncertain but plausible estimate of the mass of heavy elements that is not
accreted by stars with giant planets, including our Sun. By combining our
stellar evolution models to these estimates, we evaluate the consequences of
planet formation on stellar surface composition. We show that after the first
$\sim0.1$ Myr, the evolution of the convective zone follows classical
evolutionary tracks within a factor of two in age. We find that planet
formation should lead to a scatter in stellar surface composition that is
larger for high-mass stars than for low-mass stars. We predict a spread in
[Fe/H] of approximately $0.02$ dex for stars with $T_\mathrm{eff}\sim 5500\,$K,
marginally compatible with differences in metallicities observed in some binary
stars with planets. Stars with $T_\mathrm{eff}\geq 7000\,$K may show much
larger [Fe/H] deficits, by 0.6 dex or more, compatible with the existence of
refractory-poor $\lambda$ Boo stars. We also find that planet formation may
explain the lack of refractory elements seen in the Sun as compared to solar
twins, but only if the ice-to-rock ratio in the solar-system planets is less
than $\approx0.4$ and planet formation began less than $\approx1.3$ Myr after
the beginning of the formation of the Sun. (abbreviated)

Solar and Stellar Astrophysics;Earth and Planetary Astrophysics