Skip to content

Commit ea014b4

Browse files
committed
Add warn(unreachable_pub) to rustc_ast_lowering.
1 parent f839309 commit ea014b4

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_span::{Span, Symbol};
66

77
#[derive(Diagnostic)]
88
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
9-
pub struct GenericTypeWithParentheses {
9+
pub(crate) struct GenericTypeWithParentheses {
1010
#[primary_span]
1111
#[label]
1212
pub span: Span,
@@ -16,7 +16,7 @@ pub struct GenericTypeWithParentheses {
1616

1717
#[derive(Subdiagnostic)]
1818
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
19-
pub struct UseAngleBrackets {
19+
pub(crate) struct UseAngleBrackets {
2020
#[suggestion_part(code = "<")]
2121
pub open_param: Span,
2222
#[suggestion_part(code = ">")]
@@ -26,7 +26,7 @@ pub struct UseAngleBrackets {
2626
#[derive(Diagnostic)]
2727
#[diag(ast_lowering_invalid_abi, code = E0703)]
2828
#[note]
29-
pub struct InvalidAbi {
29+
pub(crate) struct InvalidAbi {
3030
#[primary_span]
3131
#[label]
3232
pub span: Span,
@@ -38,7 +38,7 @@ pub struct InvalidAbi {
3838
pub suggestion: Option<InvalidAbiSuggestion>,
3939
}
4040

41-
pub struct InvalidAbiReason(pub &'static str);
41+
pub(crate) struct InvalidAbiReason(pub &'static str);
4242

4343
impl Subdiagnostic for InvalidAbiReason {
4444
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
@@ -57,23 +57,23 @@ impl Subdiagnostic for InvalidAbiReason {
5757
code = "{suggestion}",
5858
applicability = "maybe-incorrect"
5959
)]
60-
pub struct InvalidAbiSuggestion {
60+
pub(crate) struct InvalidAbiSuggestion {
6161
#[primary_span]
6262
pub span: Span,
6363
pub suggestion: String,
6464
}
6565

6666
#[derive(Diagnostic)]
6767
#[diag(ast_lowering_assoc_ty_parentheses)]
68-
pub struct AssocTyParentheses {
68+
pub(crate) struct AssocTyParentheses {
6969
#[primary_span]
7070
pub span: Span,
7171
#[subdiagnostic]
7272
pub sub: AssocTyParenthesesSub,
7373
}
7474

7575
#[derive(Subdiagnostic)]
76-
pub enum AssocTyParenthesesSub {
76+
pub(crate) enum AssocTyParenthesesSub {
7777
#[multipart_suggestion(ast_lowering_remove_parentheses)]
7878
Empty {
7979
#[suggestion_part(code = "")]
@@ -91,15 +91,15 @@ pub enum AssocTyParenthesesSub {
9191
#[derive(Diagnostic)]
9292
#[diag(ast_lowering_misplaced_impl_trait, code = E0562)]
9393
#[note]
94-
pub struct MisplacedImplTrait<'a> {
94+
pub(crate) struct MisplacedImplTrait<'a> {
9595
#[primary_span]
9696
pub span: Span,
9797
pub position: DiagArgFromDisplay<'a>,
9898
}
9999

100100
#[derive(Diagnostic)]
101101
#[diag(ast_lowering_assoc_ty_binding_in_dyn)]
102-
pub struct MisplacedAssocTyBinding {
102+
pub(crate) struct MisplacedAssocTyBinding {
103103
#[primary_span]
104104
pub span: Span,
105105
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
@@ -108,23 +108,23 @@ pub struct MisplacedAssocTyBinding {
108108

109109
#[derive(Diagnostic)]
110110
#[diag(ast_lowering_underscore_expr_lhs_assign)]
111-
pub struct UnderscoreExprLhsAssign {
111+
pub(crate) struct UnderscoreExprLhsAssign {
112112
#[primary_span]
113113
#[label]
114114
pub span: Span,
115115
}
116116

117117
#[derive(Diagnostic)]
118118
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
119-
pub struct BaseExpressionDoubleDot {
119+
pub(crate) struct BaseExpressionDoubleDot {
120120
#[primary_span]
121121
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
122122
pub span: Span,
123123
}
124124

125125
#[derive(Diagnostic)]
126126
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
127-
pub struct AwaitOnlyInAsyncFnAndBlocks {
127+
pub(crate) struct AwaitOnlyInAsyncFnAndBlocks {
128128
#[primary_span]
129129
#[label]
130130
pub await_kw_span: Span,
@@ -134,50 +134,50 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
134134

135135
#[derive(Diagnostic)]
136136
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
137-
pub struct CoroutineTooManyParameters {
137+
pub(crate) struct CoroutineTooManyParameters {
138138
#[primary_span]
139139
pub fn_decl_span: Span,
140140
}
141141

142142
#[derive(Diagnostic)]
143143
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
144-
pub struct ClosureCannotBeStatic {
144+
pub(crate) struct ClosureCannotBeStatic {
145145
#[primary_span]
146146
pub fn_decl_span: Span,
147147
}
148148

149149
#[derive(Diagnostic)]
150150
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
151-
pub struct FunctionalRecordUpdateDestructuringAssignment {
151+
pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
152152
#[primary_span]
153153
#[suggestion(code = "", applicability = "machine-applicable")]
154154
pub span: Span,
155155
}
156156

157157
#[derive(Diagnostic)]
158158
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
159-
pub struct AsyncCoroutinesNotSupported {
159+
pub(crate) struct AsyncCoroutinesNotSupported {
160160
#[primary_span]
161161
pub span: Span,
162162
}
163163

164164
#[derive(Diagnostic)]
165165
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
166-
pub struct InlineAsmUnsupportedTarget {
166+
pub(crate) struct InlineAsmUnsupportedTarget {
167167
#[primary_span]
168168
pub span: Span,
169169
}
170170

171171
#[derive(Diagnostic)]
172172
#[diag(ast_lowering_att_syntax_only_x86)]
173-
pub struct AttSyntaxOnlyX86 {
173+
pub(crate) struct AttSyntaxOnlyX86 {
174174
#[primary_span]
175175
pub span: Span,
176176
}
177177

178178
#[derive(Diagnostic)]
179179
#[diag(ast_lowering_abi_specified_multiple_times)]
180-
pub struct AbiSpecifiedMultipleTimes {
180+
pub(crate) struct AbiSpecifiedMultipleTimes {
181181
#[primary_span]
182182
pub abi_span: Span,
183183
pub prev_name: Symbol,
@@ -189,23 +189,23 @@ pub struct AbiSpecifiedMultipleTimes {
189189

190190
#[derive(Diagnostic)]
191191
#[diag(ast_lowering_clobber_abi_not_supported)]
192-
pub struct ClobberAbiNotSupported {
192+
pub(crate) struct ClobberAbiNotSupported {
193193
#[primary_span]
194194
pub abi_span: Span,
195195
}
196196

197197
#[derive(Diagnostic)]
198198
#[note]
199199
#[diag(ast_lowering_invalid_abi_clobber_abi)]
200-
pub struct InvalidAbiClobberAbi {
200+
pub(crate) struct InvalidAbiClobberAbi {
201201
#[primary_span]
202202
pub abi_span: Span,
203203
pub supported_abis: String,
204204
}
205205

206206
#[derive(Diagnostic)]
207207
#[diag(ast_lowering_invalid_register)]
208-
pub struct InvalidRegister<'a> {
208+
pub(crate) struct InvalidRegister<'a> {
209209
#[primary_span]
210210
pub op_span: Span,
211211
pub reg: Symbol,
@@ -214,7 +214,7 @@ pub struct InvalidRegister<'a> {
214214

215215
#[derive(Diagnostic)]
216216
#[diag(ast_lowering_invalid_register_class)]
217-
pub struct InvalidRegisterClass<'a> {
217+
pub(crate) struct InvalidRegisterClass<'a> {
218218
#[primary_span]
219219
pub op_span: Span,
220220
pub reg_class: Symbol,
@@ -223,7 +223,7 @@ pub struct InvalidRegisterClass<'a> {
223223

224224
#[derive(Diagnostic)]
225225
#[diag(ast_lowering_invalid_asm_template_modifier_reg_class)]
226-
pub struct InvalidAsmTemplateModifierRegClass {
226+
pub(crate) struct InvalidAsmTemplateModifierRegClass {
227227
#[primary_span]
228228
#[label(ast_lowering_template_modifier)]
229229
pub placeholder_span: Span,
@@ -234,7 +234,7 @@ pub struct InvalidAsmTemplateModifierRegClass {
234234
}
235235

236236
#[derive(Subdiagnostic)]
237-
pub enum InvalidAsmTemplateModifierRegClassSub {
237+
pub(crate) enum InvalidAsmTemplateModifierRegClassSub {
238238
#[note(ast_lowering_support_modifiers)]
239239
SupportModifier { class_name: Symbol, modifiers: String },
240240
#[note(ast_lowering_does_not_support_modifiers)]
@@ -243,7 +243,7 @@ pub enum InvalidAsmTemplateModifierRegClassSub {
243243

244244
#[derive(Diagnostic)]
245245
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
246-
pub struct InvalidAsmTemplateModifierConst {
246+
pub(crate) struct InvalidAsmTemplateModifierConst {
247247
#[primary_span]
248248
#[label(ast_lowering_template_modifier)]
249249
pub placeholder_span: Span,
@@ -253,7 +253,7 @@ pub struct InvalidAsmTemplateModifierConst {
253253

254254
#[derive(Diagnostic)]
255255
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
256-
pub struct InvalidAsmTemplateModifierSym {
256+
pub(crate) struct InvalidAsmTemplateModifierSym {
257257
#[primary_span]
258258
#[label(ast_lowering_template_modifier)]
259259
pub placeholder_span: Span,
@@ -263,7 +263,7 @@ pub struct InvalidAsmTemplateModifierSym {
263263

264264
#[derive(Diagnostic)]
265265
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
266-
pub struct InvalidAsmTemplateModifierLabel {
266+
pub(crate) struct InvalidAsmTemplateModifierLabel {
267267
#[primary_span]
268268
#[label(ast_lowering_template_modifier)]
269269
pub placeholder_span: Span,
@@ -273,15 +273,15 @@ pub struct InvalidAsmTemplateModifierLabel {
273273

274274
#[derive(Diagnostic)]
275275
#[diag(ast_lowering_register_class_only_clobber)]
276-
pub struct RegisterClassOnlyClobber {
276+
pub(crate) struct RegisterClassOnlyClobber {
277277
#[primary_span]
278278
pub op_span: Span,
279279
pub reg_class_name: Symbol,
280280
}
281281

282282
#[derive(Diagnostic)]
283283
#[diag(ast_lowering_register_conflict)]
284-
pub struct RegisterConflict<'a> {
284+
pub(crate) struct RegisterConflict<'a> {
285285
#[primary_span]
286286
#[label(ast_lowering_register1)]
287287
pub op_span1: Span,
@@ -296,7 +296,7 @@ pub struct RegisterConflict<'a> {
296296
#[derive(Diagnostic)]
297297
#[help]
298298
#[diag(ast_lowering_sub_tuple_binding)]
299-
pub struct SubTupleBinding<'a> {
299+
pub(crate) struct SubTupleBinding<'a> {
300300
#[primary_span]
301301
#[label]
302302
#[suggestion(
@@ -313,7 +313,7 @@ pub struct SubTupleBinding<'a> {
313313

314314
#[derive(Diagnostic)]
315315
#[diag(ast_lowering_extra_double_dot)]
316-
pub struct ExtraDoubleDot<'a> {
316+
pub(crate) struct ExtraDoubleDot<'a> {
317317
#[primary_span]
318318
#[label]
319319
pub span: Span,
@@ -325,21 +325,21 @@ pub struct ExtraDoubleDot<'a> {
325325
#[derive(Diagnostic)]
326326
#[note]
327327
#[diag(ast_lowering_misplaced_double_dot)]
328-
pub struct MisplacedDoubleDot {
328+
pub(crate) struct MisplacedDoubleDot {
329329
#[primary_span]
330330
pub span: Span,
331331
}
332332

333333
#[derive(Diagnostic)]
334334
#[diag(ast_lowering_misplaced_relax_trait_bound)]
335-
pub struct MisplacedRelaxTraitBound {
335+
pub(crate) struct MisplacedRelaxTraitBound {
336336
#[primary_span]
337337
pub span: Span,
338338
}
339339

340340
#[derive(Diagnostic)]
341341
#[diag(ast_lowering_match_arm_with_no_body)]
342-
pub struct MatchArmWithNoBody {
342+
pub(crate) struct MatchArmWithNoBody {
343343
#[primary_span]
344344
pub span: Span,
345345
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
@@ -348,7 +348,7 @@ pub struct MatchArmWithNoBody {
348348

349349
#[derive(Diagnostic)]
350350
#[diag(ast_lowering_never_pattern_with_body)]
351-
pub struct NeverPatternWithBody {
351+
pub(crate) struct NeverPatternWithBody {
352352
#[primary_span]
353353
#[label]
354354
#[suggestion(code = "", applicability = "maybe-incorrect")]
@@ -357,15 +357,15 @@ pub struct NeverPatternWithBody {
357357

358358
#[derive(Diagnostic)]
359359
#[diag(ast_lowering_never_pattern_with_guard)]
360-
pub struct NeverPatternWithGuard {
360+
pub(crate) struct NeverPatternWithGuard {
361361
#[primary_span]
362362
#[suggestion(code = "", applicability = "maybe-incorrect")]
363363
pub span: Span,
364364
}
365365

366366
#[derive(Diagnostic)]
367367
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
368-
pub struct ArbitraryExpressionInPattern {
368+
pub(crate) struct ArbitraryExpressionInPattern {
369369
#[primary_span]
370370
pub span: Span,
371371
#[note(ast_lowering_pattern_from_macro_note)]
@@ -374,13 +374,13 @@ pub struct ArbitraryExpressionInPattern {
374374

375375
#[derive(Diagnostic)]
376376
#[diag(ast_lowering_inclusive_range_with_no_end)]
377-
pub struct InclusiveRangeWithNoEnd {
377+
pub(crate) struct InclusiveRangeWithNoEnd {
378378
#[primary_span]
379379
pub span: Span,
380380
}
381381

382382
#[derive(Diagnostic)]
383-
pub enum BadReturnTypeNotation {
383+
pub(crate) enum BadReturnTypeNotation {
384384
#[diag(ast_lowering_bad_return_type_notation_inputs)]
385385
Inputs {
386386
#[primary_span]

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11821182
/// into the body. This is to make sure that the future actually owns the
11831183
/// arguments that are passed to the function, and to ensure things like
11841184
/// drop order are stable.
1185-
pub fn lower_coroutine_body_with_moved_arguments(
1185+
pub(crate) fn lower_coroutine_body_with_moved_arguments(
11861186
&mut self,
11871187
decl: &FnDecl,
11881188
lower_body: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::Expr<'hir>,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![feature(box_patterns)]
3838
#![feature(let_chains)]
3939
#![feature(rustdoc_internals)]
40+
#![warn(unreachable_pub)]
4041
// tidy-alphabetical-end
4142

4243
use std::collections::hash_map::Entry;

0 commit comments

Comments
 (0)