Formation of rocky and icy planetesimals inside and outside the snow line: effects of diffusion, sublimation, and back-reaction