Skip to content

Commit

Permalink
Add warn(unreachable_pub) to rustc_parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 29, 2024
1 parent 46ea798 commit cac04a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
70 changes: 35 additions & 35 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub(crate) struct NotAsNegationOperator {
}

#[derive(Subdiagnostic)]
pub enum NotAsNegationOperatorSub {
pub(crate) enum NotAsNegationOperatorSub {
#[suggestion(
parse_unexpected_token_after_not_default,
style = "verbose",
Expand Down Expand Up @@ -424,7 +424,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
#[derive(Diagnostic)]
#[diag(parse_ternary_operator)]
#[help]
pub struct TernaryOperator {
pub(crate) struct TernaryOperator {
#[primary_span]
pub span: Span,
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ pub(crate) enum ExpectedIdentifierFound {
}

impl ExpectedIdentifierFound {
pub fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
(match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
ExpectedIdentifierFound::ReservedIdentifier
Expand Down Expand Up @@ -1659,7 +1659,7 @@ pub(crate) struct SelfArgumentPointer {

#[derive(Diagnostic)]
#[diag(parse_unexpected_token_after_dot)]
pub struct UnexpectedTokenAfterDot<'a> {
pub(crate) struct UnexpectedTokenAfterDot<'a> {
#[primary_span]
pub span: Span,
pub actual: Cow<'a, str>,
Expand Down Expand Up @@ -1928,7 +1928,7 @@ pub(crate) enum UnexpectedTokenAfterStructName {
}

impl UnexpectedTokenAfterStructName {
pub fn new(span: Span, token: Token) -> Self {
pub(crate) fn new(span: Span, token: Token) -> Self {
match TokenDescription::from_token(&token) {
Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
Some(TokenDescription::Keyword) => Self::Keyword { span, token },
Expand Down Expand Up @@ -2006,60 +2006,60 @@ pub(crate) enum TopLevelOrPatternNotAllowed {

#[derive(Diagnostic)]
#[diag(parse_cannot_be_raw_ident)]
pub struct CannotBeRawIdent {
pub(crate) struct CannotBeRawIdent {
#[primary_span]
pub span: Span,
pub ident: Symbol,
}

#[derive(Diagnostic)]
#[diag(parse_keyword_lifetime)]
pub struct KeywordLifetime {
pub(crate) struct KeywordLifetime {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_invalid_label)]
pub struct InvalidLabel {
pub(crate) struct InvalidLabel {
#[primary_span]
pub span: Span,
pub name: Symbol,
}

#[derive(Diagnostic)]
#[diag(parse_cr_doc_comment)]
pub struct CrDocComment {
pub(crate) struct CrDocComment {
#[primary_span]
pub span: Span,
pub block: bool,
}

#[derive(Diagnostic)]
#[diag(parse_no_digits_literal, code = E0768)]
pub struct NoDigitsLiteral {
pub(crate) struct NoDigitsLiteral {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_invalid_digit_literal)]
pub struct InvalidDigitLiteral {
pub(crate) struct InvalidDigitLiteral {
#[primary_span]
pub span: Span,
pub base: u32,
}

#[derive(Diagnostic)]
#[diag(parse_empty_exponent_float)]
pub struct EmptyExponentFloat {
pub(crate) struct EmptyExponentFloat {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_float_literal_unsupported_base)]
pub struct FloatLiteralUnsupportedBase {
pub(crate) struct FloatLiteralUnsupportedBase {
#[primary_span]
pub span: Span,
pub base: &'static str,
Expand All @@ -2068,7 +2068,7 @@ pub struct FloatLiteralUnsupportedBase {
#[derive(Diagnostic)]
#[diag(parse_unknown_prefix)]
#[note]
pub struct UnknownPrefix<'a> {
pub(crate) struct UnknownPrefix<'a> {
#[primary_span]
#[label]
pub span: Span,
Expand All @@ -2079,12 +2079,12 @@ pub struct UnknownPrefix<'a> {

#[derive(Subdiagnostic)]
#[note(parse_macro_expands_to_adt_field)]
pub struct MacroExpandsToAdtField<'a> {
pub(crate) struct MacroExpandsToAdtField<'a> {
pub adt_ty: &'a str,
}

#[derive(Subdiagnostic)]
pub enum UnknownPrefixSugg {
pub(crate) enum UnknownPrefixSugg {
#[suggestion(
parse_suggestion_br,
code = "br",
Expand Down Expand Up @@ -2114,15 +2114,15 @@ pub enum UnknownPrefixSugg {

#[derive(Diagnostic)]
#[diag(parse_too_many_hashes)]
pub struct TooManyHashes {
pub(crate) struct TooManyHashes {
#[primary_span]
pub span: Span,
pub num: u32,
}

#[derive(Diagnostic)]
#[diag(parse_unknown_start_of_token)]
pub struct UnknownTokenStart {
pub(crate) struct UnknownTokenStart {
#[primary_span]
pub span: Span,
pub escaped: String,
Expand All @@ -2135,7 +2135,7 @@ pub struct UnknownTokenStart {
}

#[derive(Subdiagnostic)]
pub enum TokenSubstitution {
pub(crate) enum TokenSubstitution {
#[suggestion(
parse_sugg_quotes,
code = "{suggestion}",
Expand Down Expand Up @@ -2168,16 +2168,16 @@ pub enum TokenSubstitution {

#[derive(Subdiagnostic)]
#[note(parse_note_repeats)]
pub struct UnknownTokenRepeat {
pub(crate) struct UnknownTokenRepeat {
pub repeats: usize,
}

#[derive(Subdiagnostic)]
#[help(parse_help_null)]
pub struct UnknownTokenNull;
pub(crate) struct UnknownTokenNull;

#[derive(Diagnostic)]
pub enum UnescapeError {
pub(crate) enum UnescapeError {
#[diag(parse_invalid_unicode_escape)]
#[help]
InvalidUnicodeEscape {
Expand Down Expand Up @@ -2322,7 +2322,7 @@ pub enum UnescapeError {
}

#[derive(Subdiagnostic)]
pub enum MoreThanOneCharSugg {
pub(crate) enum MoreThanOneCharSugg {
#[suggestion(
parse_consider_normalized,
code = "{normalized}",
Expand Down Expand Up @@ -2370,7 +2370,7 @@ pub enum MoreThanOneCharSugg {
}

#[derive(Subdiagnostic)]
pub enum MoreThanOneCharNote {
pub(crate) enum MoreThanOneCharNote {
#[note(parse_followed_by)]
AllCombining {
#[primary_span]
Expand All @@ -2388,7 +2388,7 @@ pub enum MoreThanOneCharNote {
}

#[derive(Subdiagnostic)]
pub enum NoBraceUnicodeSub {
pub(crate) enum NoBraceUnicodeSub {
#[suggestion(
parse_use_braces,
code = "{suggestion}",
Expand Down Expand Up @@ -2703,7 +2703,7 @@ pub(crate) struct InvalidDynKeyword {
}

#[derive(Subdiagnostic)]
pub enum HelpUseLatestEdition {
pub(crate) enum HelpUseLatestEdition {
#[help(parse_help_set_edition_cargo)]
#[note(parse_note_edition_guide)]
Cargo { edition: Edition },
Expand All @@ -2713,7 +2713,7 @@ pub enum HelpUseLatestEdition {
}

impl HelpUseLatestEdition {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
let edition = LATEST_STABLE_EDITION;
if rustc_session::utils::was_invoked_from_cargo() {
Self::Cargo { edition }
Expand All @@ -2725,7 +2725,7 @@ impl HelpUseLatestEdition {

#[derive(Diagnostic)]
#[diag(parse_box_syntax_removed)]
pub struct BoxSyntaxRemoved {
pub(crate) struct BoxSyntaxRemoved {
#[primary_span]
pub span: Span,
#[subdiagnostic]
Expand All @@ -2738,7 +2738,7 @@ pub struct BoxSyntaxRemoved {
applicability = "machine-applicable",
style = "verbose"
)]
pub struct AddBoxNew {
pub(crate) struct AddBoxNew {
#[suggestion_part(code = "Box::new(")]
pub box_kw_and_lo: Span,
#[suggestion_part(code = ")")]
Expand Down Expand Up @@ -3190,7 +3190,7 @@ pub(crate) struct DotDotRangeAttribute {
#[derive(Diagnostic)]
#[diag(parse_invalid_attr_unsafe)]
#[note]
pub struct InvalidAttrUnsafe {
pub(crate) struct InvalidAttrUnsafe {
#[primary_span]
#[label]
pub span: Span,
Expand All @@ -3199,7 +3199,7 @@ pub struct InvalidAttrUnsafe {

#[derive(Diagnostic)]
#[diag(parse_unsafe_attr_outside_unsafe)]
pub struct UnsafeAttrOutsideUnsafe {
pub(crate) struct UnsafeAttrOutsideUnsafe {
#[primary_span]
#[label]
pub span: Span,
Expand All @@ -3212,7 +3212,7 @@ pub struct UnsafeAttrOutsideUnsafe {
parse_unsafe_attr_outside_unsafe_suggestion,
applicability = "machine-applicable"
)]
pub struct UnsafeAttrOutsideUnsafeSuggestion {
pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
#[suggestion_part(code = "unsafe(")]
pub left: Span,
#[suggestion_part(code = ")")]
Expand All @@ -3221,7 +3221,7 @@ pub struct UnsafeAttrOutsideUnsafeSuggestion {

#[derive(Diagnostic)]
#[diag(parse_binder_before_modifiers)]
pub struct BinderBeforeModifiers {
pub(crate) struct BinderBeforeModifiers {
#[primary_span]
pub binder_span: Span,
#[label]
Expand All @@ -3230,7 +3230,7 @@ pub struct BinderBeforeModifiers {

#[derive(Diagnostic)]
#[diag(parse_binder_and_polarity)]
pub struct BinderAndPolarity {
pub(crate) struct BinderAndPolarity {
#[primary_span]
pub polarity_span: Span,
#[label]
Expand All @@ -3240,7 +3240,7 @@ pub struct BinderAndPolarity {

#[derive(Diagnostic)]
#[diag(parse_modifiers_and_polarity)]
pub struct PolarityAndModifiers {
pub(crate) struct PolarityAndModifiers {
#[primary_span]
pub polarity_span: Span,
#[label]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

use std::path::Path;
Expand Down

0 comments on commit cac04a1

Please sign in to comment.