Theta-regularity of curves and Brill–Noether loci