Skip to content

Commit 4434f63

Browse files
committed
Add deny(unreachable_pub) to rustc_attr.
1 parent 4836276 commit 4434f63

File tree

2 files changed

+54
-53
lines changed

2 files changed

+54
-53
lines changed

compiler/rustc_attr/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! to this crate.
66
77
#![allow(internal_features)]
8+
#![deny(unreachable_pub)]
89
#![feature(rustdoc_internals)]
910
#![doc(rust_logo)]
1011
#![feature(let_chains)]

compiler/rustc_attr/src/session_diagnostics.rs

+53-53
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ use crate::UnsupportedLiteralReason;
1212
#[diag(attr_expected_one_cfg_pattern, code = E0536)]
1313
pub(crate) struct ExpectedOneCfgPattern {
1414
#[primary_span]
15-
pub span: Span,
15+
pub(crate) span: Span,
1616
}
1717

1818
#[derive(Diagnostic)]
1919
#[diag(attr_invalid_predicate, code = E0537)]
2020
pub(crate) struct InvalidPredicate {
2121
#[primary_span]
22-
pub span: Span,
22+
pub(crate) span: Span,
2323

24-
pub predicate: String,
24+
pub(crate) predicate: String,
2525
}
2626

2727
#[derive(Diagnostic)]
2828
#[diag(attr_multiple_item, code = E0538)]
2929
pub(crate) struct MultipleItem {
3030
#[primary_span]
31-
pub span: Span,
31+
pub(crate) span: Span,
3232

33-
pub item: String,
33+
pub(crate) item: String,
3434
}
3535

3636
#[derive(Diagnostic)]
3737
#[diag(attr_incorrect_meta_item, code = E0539)]
3838
pub(crate) struct IncorrectMetaItem {
3939
#[primary_span]
40-
pub span: Span,
40+
pub(crate) span: Span,
4141
}
4242

4343
/// Error code: E0541
4444
pub(crate) struct UnknownMetaItem<'a> {
45-
pub span: Span,
46-
pub item: String,
47-
pub expected: &'a [&'a str],
45+
pub(crate) span: Span,
46+
pub(crate) item: String,
47+
pub(crate) expected: &'a [&'a str],
4848
}
4949

5050
// Manual implementation to be able to format `expected` items correctly.
@@ -64,31 +64,31 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> {
6464
#[diag(attr_missing_since, code = E0542)]
6565
pub(crate) struct MissingSince {
6666
#[primary_span]
67-
pub span: Span,
67+
pub(crate) span: Span,
6868
}
6969

7070
#[derive(Diagnostic)]
7171
#[diag(attr_missing_note, code = E0543)]
7272
pub(crate) struct MissingNote {
7373
#[primary_span]
74-
pub span: Span,
74+
pub(crate) span: Span,
7575
}
7676

7777
#[derive(Diagnostic)]
7878
#[diag(attr_multiple_stability_levels, code = E0544)]
7979
pub(crate) struct MultipleStabilityLevels {
8080
#[primary_span]
81-
pub span: Span,
81+
pub(crate) span: Span,
8282
}
8383

8484
#[derive(Diagnostic)]
8585
#[diag(attr_invalid_issue_string, code = E0545)]
8686
pub(crate) struct InvalidIssueString {
8787
#[primary_span]
88-
pub span: Span,
88+
pub(crate) span: Span,
8989

9090
#[subdiagnostic]
91-
pub cause: Option<InvalidIssueStringCause>,
91+
pub(crate) cause: Option<InvalidIssueStringCause>,
9292
}
9393

9494
// The error kinds of `IntErrorKind` are duplicated here in order to allow the messages to be
@@ -127,7 +127,7 @@ pub(crate) enum InvalidIssueStringCause {
127127
}
128128

129129
impl InvalidIssueStringCause {
130-
pub fn from_int_error_kind(span: Span, kind: &IntErrorKind) -> Option<Self> {
130+
pub(crate) fn from_int_error_kind(span: Span, kind: &IntErrorKind) -> Option<Self> {
131131
match kind {
132132
IntErrorKind::Empty => Some(Self::Empty { span }),
133133
IntErrorKind::InvalidDigit => Some(Self::InvalidDigit { span }),
@@ -143,21 +143,21 @@ impl InvalidIssueStringCause {
143143
#[diag(attr_missing_feature, code = E0546)]
144144
pub(crate) struct MissingFeature {
145145
#[primary_span]
146-
pub span: Span,
146+
pub(crate) span: Span,
147147
}
148148

149149
#[derive(Diagnostic)]
150150
#[diag(attr_non_ident_feature, code = E0546)]
151151
pub(crate) struct NonIdentFeature {
152152
#[primary_span]
153-
pub span: Span,
153+
pub(crate) span: Span,
154154
}
155155

156156
#[derive(Diagnostic)]
157157
#[diag(attr_missing_issue, code = E0547)]
158158
pub(crate) struct MissingIssue {
159159
#[primary_span]
160-
pub span: Span,
160+
pub(crate) span: Span,
161161
}
162162

163163
// FIXME: Why is this the same error code as `InvalidReprHintNoParen` and `InvalidReprHintNoValue`?
@@ -166,39 +166,39 @@ pub(crate) struct MissingIssue {
166166
#[diag(attr_incorrect_repr_format_packed_one_or_zero_arg, code = E0552)]
167167
pub(crate) struct IncorrectReprFormatPackedOneOrZeroArg {
168168
#[primary_span]
169-
pub span: Span,
169+
pub(crate) span: Span,
170170
}
171171
#[derive(Diagnostic)]
172172
#[diag(attr_incorrect_repr_format_packed_expect_integer, code = E0552)]
173173
pub(crate) struct IncorrectReprFormatPackedExpectInteger {
174174
#[primary_span]
175-
pub span: Span,
175+
pub(crate) span: Span,
176176
}
177177

178178
#[derive(Diagnostic)]
179179
#[diag(attr_invalid_repr_hint_no_paren, code = E0552)]
180180
pub(crate) struct InvalidReprHintNoParen {
181181
#[primary_span]
182-
pub span: Span,
182+
pub(crate) span: Span,
183183

184-
pub name: String,
184+
pub(crate) name: String,
185185
}
186186

187187
#[derive(Diagnostic)]
188188
#[diag(attr_invalid_repr_hint_no_value, code = E0552)]
189189
pub(crate) struct InvalidReprHintNoValue {
190190
#[primary_span]
191-
pub span: Span,
191+
pub(crate) span: Span,
192192

193-
pub name: String,
193+
pub(crate) name: String,
194194
}
195195

196196
/// Error code: E0565
197197
pub(crate) struct UnsupportedLiteral {
198-
pub span: Span,
199-
pub reason: UnsupportedLiteralReason,
200-
pub is_bytestr: bool,
201-
pub start_point_span: Span,
198+
pub(crate) span: Span,
199+
pub(crate) reason: UnsupportedLiteralReason,
200+
pub(crate) is_bytestr: bool,
201+
pub(crate) start_point_span: Span,
202202
}
203203

204204
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
@@ -236,43 +236,43 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
236236
pub(crate) struct InvalidReprAlignNeedArg {
237237
#[primary_span]
238238
#[suggestion(code = "align(...)", applicability = "has-placeholders")]
239-
pub span: Span,
239+
pub(crate) span: Span,
240240
}
241241

242242
#[derive(Diagnostic)]
243243
#[diag(attr_invalid_repr_generic, code = E0589)]
244244
pub(crate) struct InvalidReprGeneric<'a> {
245245
#[primary_span]
246-
pub span: Span,
246+
pub(crate) span: Span,
247247

248-
pub repr_arg: String,
249-
pub error_part: &'a str,
248+
pub(crate) repr_arg: String,
249+
pub(crate) error_part: &'a str,
250250
}
251251

252252
#[derive(Diagnostic)]
253253
#[diag(attr_incorrect_repr_format_align_one_arg, code = E0693)]
254254
pub(crate) struct IncorrectReprFormatAlignOneArg {
255255
#[primary_span]
256-
pub span: Span,
256+
pub(crate) span: Span,
257257
}
258258

259259
#[derive(Diagnostic)]
260260
#[diag(attr_incorrect_repr_format_expect_literal_integer, code = E0693)]
261261
pub(crate) struct IncorrectReprFormatExpectInteger {
262262
#[primary_span]
263-
pub span: Span,
263+
pub(crate) span: Span,
264264
}
265265

266266
#[derive(Diagnostic)]
267267
#[diag(attr_incorrect_repr_format_generic, code = E0693)]
268268
pub(crate) struct IncorrectReprFormatGeneric<'a> {
269269
#[primary_span]
270-
pub span: Span,
270+
pub(crate) span: Span,
271271

272-
pub repr_arg: &'a str,
272+
pub(crate) repr_arg: &'a str,
273273

274274
#[subdiagnostic]
275-
pub cause: Option<IncorrectReprFormatGenericCause<'a>>,
275+
pub(crate) cause: Option<IncorrectReprFormatGenericCause<'a>>,
276276
}
277277

278278
#[derive(Subdiagnostic)]
@@ -303,7 +303,7 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> {
303303
}
304304

305305
impl<'a> IncorrectReprFormatGenericCause<'a> {
306-
pub fn from_lit_kind(span: Span, kind: &ast::LitKind, name: &'a str) -> Option<Self> {
306+
pub(crate) fn from_lit_kind(span: Span, kind: &ast::LitKind, name: &'a str) -> Option<Self> {
307307
match kind {
308308
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
309309
Some(Self::Int { span, name, int: int.get() })
@@ -318,85 +318,85 @@ impl<'a> IncorrectReprFormatGenericCause<'a> {
318318
#[diag(attr_rustc_promotable_pairing, code = E0717)]
319319
pub(crate) struct RustcPromotablePairing {
320320
#[primary_span]
321-
pub span: Span,
321+
pub(crate) span: Span,
322322
}
323323

324324
#[derive(Diagnostic)]
325325
#[diag(attr_rustc_allowed_unstable_pairing, code = E0789)]
326326
pub(crate) struct RustcAllowedUnstablePairing {
327327
#[primary_span]
328-
pub span: Span,
328+
pub(crate) span: Span,
329329
}
330330

331331
#[derive(Diagnostic)]
332332
#[diag(attr_cfg_predicate_identifier)]
333333
pub(crate) struct CfgPredicateIdentifier {
334334
#[primary_span]
335-
pub span: Span,
335+
pub(crate) span: Span,
336336
}
337337

338338
#[derive(Diagnostic)]
339339
#[diag(attr_deprecated_item_suggestion)]
340340
pub(crate) struct DeprecatedItemSuggestion {
341341
#[primary_span]
342-
pub span: Span,
342+
pub(crate) span: Span,
343343

344344
#[help]
345-
pub is_nightly: Option<()>,
345+
pub(crate) is_nightly: Option<()>,
346346

347347
#[note]
348-
pub details: (),
348+
pub(crate) details: (),
349349
}
350350

351351
#[derive(Diagnostic)]
352352
#[diag(attr_expected_single_version_literal)]
353353
pub(crate) struct ExpectedSingleVersionLiteral {
354354
#[primary_span]
355-
pub span: Span,
355+
pub(crate) span: Span,
356356
}
357357

358358
#[derive(Diagnostic)]
359359
#[diag(attr_expected_version_literal)]
360360
pub(crate) struct ExpectedVersionLiteral {
361361
#[primary_span]
362-
pub span: Span,
362+
pub(crate) span: Span,
363363
}
364364

365365
#[derive(Diagnostic)]
366366
#[diag(attr_expects_feature_list)]
367367
pub(crate) struct ExpectsFeatureList {
368368
#[primary_span]
369-
pub span: Span,
369+
pub(crate) span: Span,
370370

371-
pub name: String,
371+
pub(crate) name: String,
372372
}
373373

374374
#[derive(Diagnostic)]
375375
#[diag(attr_expects_features)]
376376
pub(crate) struct ExpectsFeatures {
377377
#[primary_span]
378-
pub span: Span,
378+
pub(crate) span: Span,
379379

380-
pub name: String,
380+
pub(crate) name: String,
381381
}
382382

383383
#[derive(Diagnostic)]
384384
#[diag(attr_invalid_since)]
385385
pub(crate) struct InvalidSince {
386386
#[primary_span]
387-
pub span: Span,
387+
pub(crate) span: Span,
388388
}
389389

390390
#[derive(Diagnostic)]
391391
#[diag(attr_soft_no_args)]
392392
pub(crate) struct SoftNoArgs {
393393
#[primary_span]
394-
pub span: Span,
394+
pub(crate) span: Span,
395395
}
396396

397397
#[derive(Diagnostic)]
398398
#[diag(attr_unknown_version_literal)]
399399
pub(crate) struct UnknownVersionLiteral {
400400
#[primary_span]
401-
pub span: Span,
401+
pub(crate) span: Span,
402402
}

0 commit comments

Comments
 (0)