Add warn(unreachable_pub) to rustc_expand.

Plus a tiny bit of reformatting.
This commit is contained in:
Nicholas Nethercote 2024-08-27 12:40:38 +10:00
parent 5fd503ab44
commit df5fbf05a1
7 changed files with 22 additions and 21 deletions

View File

@ -350,7 +350,7 @@ pub(crate) struct ModuleMultipleCandidates {
#[derive(Diagnostic)]
#[diag(expand_trace_macro)]
pub struct TraceMacro {
pub(crate) struct TraceMacro {
#[primary_span]
pub span: Span,
}
@ -402,14 +402,14 @@ pub(crate) struct CustomAttributePanickedHelp {
#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_tokens)]
pub struct ProcMacroDeriveTokens {
pub(crate) struct ProcMacroDeriveTokens {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_duplicate_matcher_binding)]
pub struct DuplicateMatcherBinding {
pub(crate) struct DuplicateMatcherBinding {
#[primary_span]
#[label]
pub span: Span,
@ -421,7 +421,7 @@ pub struct DuplicateMatcherBinding {
#[diag(expand_missing_fragment_specifier)]
#[note]
#[help(expand_valid)]
pub struct MissingFragmentSpecifier {
pub(crate) struct MissingFragmentSpecifier {
#[primary_span]
pub span: Span,
#[suggestion(
@ -437,7 +437,7 @@ pub struct MissingFragmentSpecifier {
#[derive(Diagnostic)]
#[diag(expand_invalid_fragment_specifier)]
#[help]
pub struct InvalidFragmentSpecifier {
pub(crate) struct InvalidFragmentSpecifier {
#[primary_span]
pub span: Span,
pub fragment: Ident,
@ -446,7 +446,7 @@ pub struct InvalidFragmentSpecifier {
#[derive(Diagnostic)]
#[diag(expand_expected_paren_or_brace)]
pub struct ExpectedParenOrBrace<'a> {
pub(crate) struct ExpectedParenOrBrace<'a> {
#[primary_span]
pub span: Span,
pub token: Cow<'a, str>,
@ -479,7 +479,7 @@ pub(crate) struct GlobDelegationTraitlessQpath {
#[derive(Diagnostic)]
#[diag(expand_proc_macro_back_compat)]
#[note]
pub struct ProcMacroBackCompat {
pub(crate) struct ProcMacroBackCompat {
pub crate_name: String,
pub fixed_version: String,
}

View File

@ -13,6 +13,7 @@
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
extern crate proc_macro as pm;

View File

@ -196,13 +196,14 @@ impl<'dcx> CollectTrackerAndEmitter<'dcx, '_> {
}
}
/// Currently used by macro_rules! compilation to extract a little information from the `Failure` case.
pub struct FailureForwarder<'matcher> {
/// Currently used by macro_rules! compilation to extract a little information from the `Failure`
/// case.
pub(crate) struct FailureForwarder<'matcher> {
expected_token: Option<&'matcher Token>,
}
impl<'matcher> FailureForwarder<'matcher> {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Self { expected_token: None }
}
}

View File

@ -407,7 +407,7 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool {
// Note: the vectors could be created and dropped within `parse_tt`, but to avoid excess
// allocations we have a single vector for each kind that is cleared and reused repeatedly.
pub struct TtParser {
pub(crate) struct TtParser {
macro_name: Ident,
/// The set of current mps to be processed. This should be empty by the end of a successful

View File

@ -14,12 +14,11 @@ use crate::mbe::macro_parser::count_metavar_decls;
use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
`literal`, `path`, `meta`, `tt`, `item` and `vis`";
pub const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, \
`ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
`item` and `vis`";
pub(crate) const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, \
`meta`, `tt`, `item` and `vis`";
/// Takes a `tokenstream::TokenStream` and returns a `Vec<self::TokenTree>`. Specifically, this
/// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a

View File

@ -191,12 +191,12 @@ pub(crate) fn placeholder(
}
#[derive(Default)]
pub struct PlaceholderExpander {
pub(crate) struct PlaceholderExpander {
expanded_fragments: FxHashMap<ast::NodeId, AstFragment>,
}
impl PlaceholderExpander {
pub fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) {
pub(crate) fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) {
fragment.mut_visit_with(self);
self.expanded_fragments.insert(id, fragment);
}

View File

@ -414,7 +414,7 @@ impl ToInternal<rustc_errors::Level> for Level {
}
}
pub struct FreeFunctions;
pub(crate) struct FreeFunctions;
pub(crate) struct Rustc<'a, 'b> {
ecx: &'a mut ExtCtxt<'b>,
@ -426,7 +426,7 @@ pub(crate) struct Rustc<'a, 'b> {
}
impl<'a, 'b> Rustc<'a, 'b> {
pub fn new(ecx: &'a mut ExtCtxt<'b>) -> Self {
pub(crate) fn new(ecx: &'a mut ExtCtxt<'b>) -> Self {
let expn_data = ecx.current_expansion.id.expn_data();
Rustc {
def_site: ecx.with_def_site_ctxt(expn_data.def_site),