  Context: Pebble accretion is expected to be the dominant process for the
formation of massive solid planets, such as the cores of giant planets and
super-Earths. So, far, this process has been studied under the assumption that
dust coagulates and drifts throughout the full protoplanetary disk. However,
observations show that many disks are structured in rings that may be due to
pressure maxima, preventing the global radial drift of the dust.
  Aims: We study how the pebble-accretion paradigm changes if the dust is
confined in a ring.
  Results: Planet Type-I migration is stopped in a ring, but not necessarily at
its center. If the entropy-driven corotation torque is desaturated, the planet
is located in a region with a low density of dust, which severely limits its
accretion rate. If instead the planet is near the ring's center, its accretion
rate can be similar to the one it would have in a classic (ring-less) disk of
equivalent dust density. However, the growth rate of the planet is limited by
the diffusion of dust in the ring and the final planet's mass is bounded by the
total ring's mass. The DSHARP rings are too far from the star to allow the
formation of massive planets within the disk's lifetime. However, a similar
ring rescaled to 5 AU could lead to the formation of a planet incorporating the
full ring's mass in less than 1/2 My.
  Conclusions: The existence of rings may not be an obstacle to planet
formation by pebble-accretion. However, for accretion to be effective the
resting position of the planet has to be relatively near the ring's center and
the ring needs to be not too far from the central star. The formation of
planets in rings can explain the existence of giant planets with core masses
smaller than the so-called pebble isolation mass.
