Skip to content

Commit cac04a1

Browse files
committedAug 29, 2024
Add warn(unreachable_pub) to rustc_parser.
1 parent 46ea798 commit cac04a1

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed
 

‎compiler/rustc_parse/src/errors.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub(crate) struct NotAsNegationOperator {
260260
}
261261

262262
#[derive(Subdiagnostic)]
263-
pub enum NotAsNegationOperatorSub {
263+
pub(crate) enum NotAsNegationOperatorSub {
264264
#[suggestion(
265265
parse_unexpected_token_after_not_default,
266266
style = "verbose",
@@ -424,7 +424,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
424424
#[derive(Diagnostic)]
425425
#[diag(parse_ternary_operator)]
426426
#[help]
427-
pub struct TernaryOperator {
427+
pub(crate) struct TernaryOperator {
428428
#[primary_span]
429429
pub span: Span,
430430
}
@@ -1088,7 +1088,7 @@ pub(crate) enum ExpectedIdentifierFound {
10881088
}
10891089

10901090
impl ExpectedIdentifierFound {
1091-
pub fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
1091+
pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
10921092
(match token_descr {
10931093
Some(TokenDescription::ReservedIdentifier) => {
10941094
ExpectedIdentifierFound::ReservedIdentifier
@@ -1659,7 +1659,7 @@ pub(crate) struct SelfArgumentPointer {
16591659

16601660
#[derive(Diagnostic)]
16611661
#[diag(parse_unexpected_token_after_dot)]
1662-
pub struct UnexpectedTokenAfterDot<'a> {
1662+
pub(crate) struct UnexpectedTokenAfterDot<'a> {
16631663
#[primary_span]
16641664
pub span: Span,
16651665
pub actual: Cow<'a, str>,
@@ -1928,7 +1928,7 @@ pub(crate) enum UnexpectedTokenAfterStructName {
19281928
}
19291929

19301930
impl UnexpectedTokenAfterStructName {
1931-
pub fn new(span: Span, token: Token) -> Self {
1931+
pub(crate) fn new(span: Span, token: Token) -> Self {
19321932
match TokenDescription::from_token(&token) {
19331933
Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
19341934
Some(TokenDescription::Keyword) => Self::Keyword { span, token },
@@ -2006,60 +2006,60 @@ pub(crate) enum TopLevelOrPatternNotAllowed {
20062006

20072007
#[derive(Diagnostic)]
20082008
#[diag(parse_cannot_be_raw_ident)]
2009-
pub struct CannotBeRawIdent {
2009+
pub(crate) struct CannotBeRawIdent {
20102010
#[primary_span]
20112011
pub span: Span,
20122012
pub ident: Symbol,
20132013
}
20142014

20152015
#[derive(Diagnostic)]
20162016
#[diag(parse_keyword_lifetime)]
2017-
pub struct KeywordLifetime {
2017+
pub(crate) struct KeywordLifetime {
20182018
#[primary_span]
20192019
pub span: Span,
20202020
}
20212021

20222022
#[derive(Diagnostic)]
20232023
#[diag(parse_invalid_label)]
2024-
pub struct InvalidLabel {
2024+
pub(crate) struct InvalidLabel {
20252025
#[primary_span]
20262026
pub span: Span,
20272027
pub name: Symbol,
20282028
}
20292029

20302030
#[derive(Diagnostic)]
20312031
#[diag(parse_cr_doc_comment)]
2032-
pub struct CrDocComment {
2032+
pub(crate) struct CrDocComment {
20332033
#[primary_span]
20342034
pub span: Span,
20352035
pub block: bool,
20362036
}
20372037

20382038
#[derive(Diagnostic)]
20392039
#[diag(parse_no_digits_literal, code = E0768)]
2040-
pub struct NoDigitsLiteral {
2040+
pub(crate) struct NoDigitsLiteral {
20412041
#[primary_span]
20422042
pub span: Span,
20432043
}
20442044

20452045
#[derive(Diagnostic)]
20462046
#[diag(parse_invalid_digit_literal)]
2047-
pub struct InvalidDigitLiteral {
2047+
pub(crate) struct InvalidDigitLiteral {
20482048
#[primary_span]
20492049
pub span: Span,
20502050
pub base: u32,
20512051
}
20522052

20532053
#[derive(Diagnostic)]
20542054
#[diag(parse_empty_exponent_float)]
2055-
pub struct EmptyExponentFloat {
2055+
pub(crate) struct EmptyExponentFloat {
20562056
#[primary_span]
20572057
pub span: Span,
20582058
}
20592059

20602060
#[derive(Diagnostic)]
20612061
#[diag(parse_float_literal_unsupported_base)]
2062-
pub struct FloatLiteralUnsupportedBase {
2062+
pub(crate) struct FloatLiteralUnsupportedBase {
20632063
#[primary_span]
20642064
pub span: Span,
20652065
pub base: &'static str,
@@ -2068,7 +2068,7 @@ pub struct FloatLiteralUnsupportedBase {
20682068
#[derive(Diagnostic)]
20692069
#[diag(parse_unknown_prefix)]
20702070
#[note]
2071-
pub struct UnknownPrefix<'a> {
2071+
pub(crate) struct UnknownPrefix<'a> {
20722072
#[primary_span]
20732073
#[label]
20742074
pub span: Span,
@@ -2079,12 +2079,12 @@ pub struct UnknownPrefix<'a> {
20792079

20802080
#[derive(Subdiagnostic)]
20812081
#[note(parse_macro_expands_to_adt_field)]
2082-
pub struct MacroExpandsToAdtField<'a> {
2082+
pub(crate) struct MacroExpandsToAdtField<'a> {
20832083
pub adt_ty: &'a str,
20842084
}
20852085

20862086
#[derive(Subdiagnostic)]
2087-
pub enum UnknownPrefixSugg {
2087+
pub(crate) enum UnknownPrefixSugg {
20882088
#[suggestion(
20892089
parse_suggestion_br,
20902090
code = "br",
@@ -2114,15 +2114,15 @@ pub enum UnknownPrefixSugg {
21142114

21152115
#[derive(Diagnostic)]
21162116
#[diag(parse_too_many_hashes)]
2117-
pub struct TooManyHashes {
2117+
pub(crate) struct TooManyHashes {
21182118
#[primary_span]
21192119
pub span: Span,
21202120
pub num: u32,
21212121
}
21222122

21232123
#[derive(Diagnostic)]
21242124
#[diag(parse_unknown_start_of_token)]
2125-
pub struct UnknownTokenStart {
2125+
pub(crate) struct UnknownTokenStart {
21262126
#[primary_span]
21272127
pub span: Span,
21282128
pub escaped: String,
@@ -2135,7 +2135,7 @@ pub struct UnknownTokenStart {
21352135
}
21362136

21372137
#[derive(Subdiagnostic)]
2138-
pub enum TokenSubstitution {
2138+
pub(crate) enum TokenSubstitution {
21392139
#[suggestion(
21402140
parse_sugg_quotes,
21412141
code = "{suggestion}",
@@ -2168,16 +2168,16 @@ pub enum TokenSubstitution {
21682168

21692169
#[derive(Subdiagnostic)]
21702170
#[note(parse_note_repeats)]
2171-
pub struct UnknownTokenRepeat {
2171+
pub(crate) struct UnknownTokenRepeat {
21722172
pub repeats: usize,
21732173
}
21742174

21752175
#[derive(Subdiagnostic)]
21762176
#[help(parse_help_null)]
2177-
pub struct UnknownTokenNull;
2177+
pub(crate) struct UnknownTokenNull;
21782178

21792179
#[derive(Diagnostic)]
2180-
pub enum UnescapeError {
2180+
pub(crate) enum UnescapeError {
21812181
#[diag(parse_invalid_unicode_escape)]
21822182
#[help]
21832183
InvalidUnicodeEscape {
@@ -2322,7 +2322,7 @@ pub enum UnescapeError {
23222322
}
23232323

23242324
#[derive(Subdiagnostic)]
2325-
pub enum MoreThanOneCharSugg {
2325+
pub(crate) enum MoreThanOneCharSugg {
23262326
#[suggestion(
23272327
parse_consider_normalized,
23282328
code = "{normalized}",
@@ -2370,7 +2370,7 @@ pub enum MoreThanOneCharSugg {
23702370
}
23712371

23722372
#[derive(Subdiagnostic)]
2373-
pub enum MoreThanOneCharNote {
2373+
pub(crate) enum MoreThanOneCharNote {
23742374
#[note(parse_followed_by)]
23752375
AllCombining {
23762376
#[primary_span]
@@ -2388,7 +2388,7 @@ pub enum MoreThanOneCharNote {
23882388
}
23892389

23902390
#[derive(Subdiagnostic)]
2391-
pub enum NoBraceUnicodeSub {
2391+
pub(crate) enum NoBraceUnicodeSub {
23922392
#[suggestion(
23932393
parse_use_braces,
23942394
code = "{suggestion}",
@@ -2703,7 +2703,7 @@ pub(crate) struct InvalidDynKeyword {
27032703
}
27042704

27052705
#[derive(Subdiagnostic)]
2706-
pub enum HelpUseLatestEdition {
2706+
pub(crate) enum HelpUseLatestEdition {
27072707
#[help(parse_help_set_edition_cargo)]
27082708
#[note(parse_note_edition_guide)]
27092709
Cargo { edition: Edition },
@@ -2713,7 +2713,7 @@ pub enum HelpUseLatestEdition {
27132713
}
27142714

27152715
impl HelpUseLatestEdition {
2716-
pub fn new() -> Self {
2716+
pub(crate) fn new() -> Self {
27172717
let edition = LATEST_STABLE_EDITION;
27182718
if rustc_session::utils::was_invoked_from_cargo() {
27192719
Self::Cargo { edition }
@@ -2725,7 +2725,7 @@ impl HelpUseLatestEdition {
27252725

27262726
#[derive(Diagnostic)]
27272727
#[diag(parse_box_syntax_removed)]
2728-
pub struct BoxSyntaxRemoved {
2728+
pub(crate) struct BoxSyntaxRemoved {
27292729
#[primary_span]
27302730
pub span: Span,
27312731
#[subdiagnostic]
@@ -2738,7 +2738,7 @@ pub struct BoxSyntaxRemoved {
27382738
applicability = "machine-applicable",
27392739
style = "verbose"
27402740
)]
2741-
pub struct AddBoxNew {
2741+
pub(crate) struct AddBoxNew {
27422742
#[suggestion_part(code = "Box::new(")]
27432743
pub box_kw_and_lo: Span,
27442744
#[suggestion_part(code = ")")]
@@ -3190,7 +3190,7 @@ pub(crate) struct DotDotRangeAttribute {
31903190
#[derive(Diagnostic)]
31913191
#[diag(parse_invalid_attr_unsafe)]
31923192
#[note]
3193-
pub struct InvalidAttrUnsafe {
3193+
pub(crate) struct InvalidAttrUnsafe {
31943194
#[primary_span]
31953195
#[label]
31963196
pub span: Span,
@@ -3199,7 +3199,7 @@ pub struct InvalidAttrUnsafe {
31993199

32003200
#[derive(Diagnostic)]
32013201
#[diag(parse_unsafe_attr_outside_unsafe)]
3202-
pub struct UnsafeAttrOutsideUnsafe {
3202+
pub(crate) struct UnsafeAttrOutsideUnsafe {
32033203
#[primary_span]
32043204
#[label]
32053205
pub span: Span,
@@ -3212,7 +3212,7 @@ pub struct UnsafeAttrOutsideUnsafe {
32123212
parse_unsafe_attr_outside_unsafe_suggestion,
32133213
applicability = "machine-applicable"
32143214
)]
3215-
pub struct UnsafeAttrOutsideUnsafeSuggestion {
3215+
pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
32163216
#[suggestion_part(code = "unsafe(")]
32173217
pub left: Span,
32183218
#[suggestion_part(code = ")")]
@@ -3221,7 +3221,7 @@ pub struct UnsafeAttrOutsideUnsafeSuggestion {
32213221

32223222
#[derive(Diagnostic)]
32233223
#[diag(parse_binder_before_modifiers)]
3224-
pub struct BinderBeforeModifiers {
3224+
pub(crate) struct BinderBeforeModifiers {
32253225
#[primary_span]
32263226
pub binder_span: Span,
32273227
#[label]
@@ -3230,7 +3230,7 @@ pub struct BinderBeforeModifiers {
32303230

32313231
#[derive(Diagnostic)]
32323232
#[diag(parse_binder_and_polarity)]
3233-
pub struct BinderAndPolarity {
3233+
pub(crate) struct BinderAndPolarity {
32343234
#[primary_span]
32353235
pub polarity_span: Span,
32363236
#[label]
@@ -3240,7 +3240,7 @@ pub struct BinderAndPolarity {
32403240

32413241
#[derive(Diagnostic)]
32423242
#[diag(parse_modifiers_and_polarity)]
3243-
pub struct PolarityAndModifiers {
3243+
pub(crate) struct PolarityAndModifiers {
32443244
#[primary_span]
32453245
pub polarity_span: Span,
32463246
#[label]

‎compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(if_let_guard)]
1212
#![feature(iter_intersperse)]
1313
#![feature(let_chains)]
14+
#![warn(unreachable_pub)]
1415
// tidy-alphabetical-end
1516

1617
use std::path::Path;

0 commit comments

Comments
 (0)
Please sign in to comment.