Skip to content

Commit 28544c7

Browse files
committed
Add deny(unreachable_pub) to rustc_builtin_macros.
1 parent a67d371 commit 28544c7

File tree

6 files changed

+87
-86
lines changed

6 files changed

+87
-86
lines changed

compiler/rustc_builtin_macros/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::symbol::{sym, Ident};
1313
use rustc_span::{ErrorGuaranteed, Span};
1414

1515
pub(crate) struct Expander {
16-
pub is_const: bool,
16+
pub(crate) is_const: bool,
1717
}
1818

1919
impl MultiItemModifier for Expander {

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+29-29
Original file line numberDiff line numberDiff line change
@@ -199,51 +199,51 @@ pub(crate) mod ty;
199199

200200
pub(crate) struct TraitDef<'a> {
201201
/// The span for the current #[derive(Foo)] header.
202-
pub span: Span,
202+
pub(crate) span: Span,
203203

204204
/// Path of the trait, including any type parameters
205-
pub path: Path,
205+
pub(crate) path: Path,
206206

207207
/// Whether to skip adding the current trait as a bound to the type parameters of the type.
208-
pub skip_path_as_bound: bool,
208+
pub(crate) skip_path_as_bound: bool,
209209

210210
/// Whether `Copy` is needed as an additional bound on type parameters in a packed struct.
211-
pub needs_copy_as_bound_if_packed: bool,
211+
pub(crate) needs_copy_as_bound_if_packed: bool,
212212

213213
/// Additional bounds required of any type parameters of the type,
214214
/// other than the current trait
215-
pub additional_bounds: Vec<Ty>,
215+
pub(crate) additional_bounds: Vec<Ty>,
216216

217217
/// Can this trait be derived for unions?
218-
pub supports_unions: bool,
218+
pub(crate) supports_unions: bool,
219219

220-
pub methods: Vec<MethodDef<'a>>,
220+
pub(crate) methods: Vec<MethodDef<'a>>,
221221

222-
pub associated_types: Vec<(Ident, Ty)>,
222+
pub(crate) associated_types: Vec<(Ident, Ty)>,
223223

224-
pub is_const: bool,
224+
pub(crate) is_const: bool,
225225
}
226226

227227
pub(crate) struct MethodDef<'a> {
228228
/// name of the method
229-
pub name: Symbol,
229+
pub(crate) name: Symbol,
230230
/// List of generics, e.g., `R: rand::Rng`
231-
pub generics: Bounds,
231+
pub(crate) generics: Bounds,
232232

233233
/// Is there is a `&self` argument? If not, it is a static function.
234-
pub explicit_self: bool,
234+
pub(crate) explicit_self: bool,
235235

236236
/// Arguments other than the self argument.
237-
pub nonself_args: Vec<(Ty, Symbol)>,
237+
pub(crate) nonself_args: Vec<(Ty, Symbol)>,
238238

239239
/// Returns type
240-
pub ret_ty: Ty,
240+
pub(crate) ret_ty: Ty,
241241

242-
pub attributes: ast::AttrVec,
242+
pub(crate) attributes: ast::AttrVec,
243243

244-
pub fieldless_variants_strategy: FieldlessVariantsStrategy,
244+
pub(crate) fieldless_variants_strategy: FieldlessVariantsStrategy,
245245

246-
pub combine_substructure: RefCell<CombineSubstructureFunc<'a>>,
246+
pub(crate) combine_substructure: RefCell<CombineSubstructureFunc<'a>>,
247247
}
248248

249249
/// How to handle fieldless enum variants.
@@ -265,25 +265,25 @@ pub(crate) enum FieldlessVariantsStrategy {
265265
/// All the data about the data structure/method being derived upon.
266266
pub(crate) struct Substructure<'a> {
267267
/// ident of self
268-
pub type_ident: Ident,
268+
pub(crate) type_ident: Ident,
269269
/// Verbatim access to any non-selflike arguments, i.e. arguments that
270270
/// don't have type `&Self`.
271-
pub nonselflike_args: &'a [P<Expr>],
272-
pub fields: &'a SubstructureFields<'a>,
271+
pub(crate) nonselflike_args: &'a [P<Expr>],
272+
pub(crate) fields: &'a SubstructureFields<'a>,
273273
}
274274

275275
/// Summary of the relevant parts of a struct/enum field.
276276
pub(crate) struct FieldInfo {
277-
pub span: Span,
277+
pub(crate) span: Span,
278278
/// None for tuple structs/normal enum variants, Some for normal
279279
/// structs/struct enum variants.
280-
pub name: Option<Ident>,
280+
pub(crate) name: Option<Ident>,
281281
/// The expression corresponding to this field of `self`
282282
/// (specifically, a reference to it).
283-
pub self_expr: P<Expr>,
283+
pub(crate) self_expr: P<Expr>,
284284
/// The expressions corresponding to references to this field in
285285
/// the other selflike arguments.
286-
pub other_selflike_exprs: Vec<P<Expr>>,
286+
pub(crate) other_selflike_exprs: Vec<P<Expr>>,
287287
}
288288

289289
#[derive(Copy, Clone)]
@@ -352,15 +352,15 @@ struct TypeParameter {
352352
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);
353353

354354
impl BlockOrExpr {
355-
pub fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
355+
pub(crate) fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
356356
BlockOrExpr(stmts, None)
357357
}
358358

359-
pub fn new_expr(expr: P<Expr>) -> BlockOrExpr {
359+
pub(crate) fn new_expr(expr: P<Expr>) -> BlockOrExpr {
360360
BlockOrExpr(ThinVec::new(), Some(expr))
361361
}
362362

363-
pub fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<P<Expr>>) -> BlockOrExpr {
363+
pub(crate) fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<P<Expr>>) -> BlockOrExpr {
364364
BlockOrExpr(stmts, expr)
365365
}
366366

@@ -452,7 +452,7 @@ fn find_type_parameters(
452452
}
453453

454454
impl<'a> TraitDef<'a> {
455-
pub fn expand(
455+
pub(crate) fn expand(
456456
self,
457457
cx: &ExtCtxt<'_>,
458458
mitem: &ast::MetaItem,
@@ -462,7 +462,7 @@ impl<'a> TraitDef<'a> {
462462
self.expand_ext(cx, mitem, item, push, false);
463463
}
464464

465-
pub fn expand_ext(
465+
pub(crate) fn expand_ext(
466466
self,
467467
cx: &ExtCtxt<'_>,
468468
mitem: &ast::MetaItem,

compiler/rustc_builtin_macros/src/deriving/generic/ty.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ pub(crate) enum PathKind {
2828
}
2929

3030
impl Path {
31-
pub fn new(path: Vec<Symbol>) -> Path {
31+
pub(crate) fn new(path: Vec<Symbol>) -> Path {
3232
Path::new_(path, Vec::new(), PathKind::Std)
3333
}
34-
pub fn new_local(path: Symbol) -> Path {
34+
pub(crate) fn new_local(path: Symbol) -> Path {
3535
Path::new_(vec![path], Vec::new(), PathKind::Local)
3636
}
37-
pub fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
37+
pub(crate) fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
3838
Path { path, params, kind }
3939
}
4040

41-
pub fn to_ty(
41+
fn to_ty(
4242
&self,
4343
cx: &ExtCtxt<'_>,
4444
span: Span,
@@ -47,7 +47,7 @@ impl Path {
4747
) -> P<ast::Ty> {
4848
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
4949
}
50-
pub fn to_path(
50+
pub(crate) fn to_path(
5151
&self,
5252
cx: &ExtCtxt<'_>,
5353
span: Span,
@@ -88,7 +88,7 @@ pub(crate) fn self_ref() -> Ty {
8888
}
8989

9090
impl Ty {
91-
pub fn to_ty(
91+
pub(crate) fn to_ty(
9292
&self,
9393
cx: &ExtCtxt<'_>,
9494
span: Span,
@@ -109,7 +109,7 @@ impl Ty {
109109
}
110110
}
111111

112-
pub fn to_path(
112+
pub(crate) fn to_path(
113113
&self,
114114
cx: &ExtCtxt<'_>,
115115
span: Span,
@@ -164,14 +164,14 @@ fn mk_ty_param(
164164
/// Bounds on type parameters.
165165
#[derive(Clone)]
166166
pub(crate) struct Bounds {
167-
pub bounds: Vec<(Symbol, Vec<Path>)>,
167+
pub(crate) bounds: Vec<(Symbol, Vec<Path>)>,
168168
}
169169

170170
impl Bounds {
171-
pub fn empty() -> Bounds {
171+
pub(crate) fn empty() -> Bounds {
172172
Bounds { bounds: Vec::new() }
173173
}
174-
pub fn to_generics(
174+
pub(crate) fn to_generics(
175175
&self,
176176
cx: &ExtCtxt<'_>,
177177
span: Span,

compiler/rustc_builtin_macros/src/errors.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub(crate) struct BadDeriveLit {
268268
#[label]
269269
pub(crate) span: Span,
270270
#[subdiagnostic]
271-
pub help: BadDeriveLitHelp,
271+
pub(crate) help: BadDeriveLitHelp,
272272
}
273273

274274
#[derive(Subdiagnostic)]
@@ -327,9 +327,9 @@ pub(crate) struct MultipleDefaults {
327327
#[label]
328328
pub(crate) first: Span,
329329
#[label(builtin_macros_additional)]
330-
pub additional: Vec<Span>,
330+
pub(crate) additional: Vec<Span>,
331331
#[subdiagnostic]
332-
pub suggs: Vec<MultipleDefaultsSugg>,
332+
pub(crate) suggs: Vec<MultipleDefaultsSugg>,
333333
}
334334

335335
#[derive(Subdiagnostic)]
@@ -581,9 +581,9 @@ pub(crate) struct FormatUnknownTrait<'a> {
581581
)]
582582
pub(crate) struct FormatUnknownTraitSugg {
583583
#[primary_span]
584-
pub span: Span,
585-
pub fmt: &'static str,
586-
pub trait_name: &'static str,
584+
pub(crate) span: Span,
585+
pub(crate) fmt: &'static str,
586+
pub(crate) trait_name: &'static str,
587587
}
588588

589589
#[derive(Diagnostic)]
@@ -847,21 +847,21 @@ pub(crate) struct ExpectedRegisterClassOrExplicitRegister {
847847
#[diag(builtin_macros_expected_comma_in_list)]
848848
pub(crate) struct ExpectedCommaInList {
849849
#[primary_span]
850-
pub span: Span,
850+
pub(crate) span: Span,
851851
}
852852

853853
#[derive(Diagnostic)]
854854
#[diag(builtin_macros_only_one_argument)]
855855
pub(crate) struct OnlyOneArgument<'a> {
856856
#[primary_span]
857-
pub span: Span,
858-
pub name: &'a str,
857+
pub(crate) span: Span,
858+
pub(crate) name: &'a str,
859859
}
860860

861861
#[derive(Diagnostic)]
862862
#[diag(builtin_macros_takes_no_arguments)]
863863
pub(crate) struct TakesNoArguments<'a> {
864864
#[primary_span]
865-
pub span: Span,
866-
pub name: &'a str,
865+
pub(crate) span: Span,
866+
pub(crate) name: &'a str,
867867
}

0 commit comments

Comments
 (0)