Add warn(unreachable_pub)
to rustc_expand
.
Plus a tiny bit of reformatting.
This commit is contained in:
parent
5fd503ab44
commit
df5fbf05a1
7 changed files with 22 additions and 21 deletions
|
@ -350,7 +350,7 @@ pub(crate) struct ModuleMultipleCandidates {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_trace_macro)]
|
#[diag(expand_trace_macro)]
|
||||||
pub struct TraceMacro {
|
pub(crate) struct TraceMacro {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -402,14 +402,14 @@ pub(crate) struct CustomAttributePanickedHelp {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_proc_macro_derive_tokens)]
|
#[diag(expand_proc_macro_derive_tokens)]
|
||||||
pub struct ProcMacroDeriveTokens {
|
pub(crate) struct ProcMacroDeriveTokens {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_duplicate_matcher_binding)]
|
#[diag(expand_duplicate_matcher_binding)]
|
||||||
pub struct DuplicateMatcherBinding {
|
pub(crate) struct DuplicateMatcherBinding {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
@ -421,7 +421,7 @@ pub struct DuplicateMatcherBinding {
|
||||||
#[diag(expand_missing_fragment_specifier)]
|
#[diag(expand_missing_fragment_specifier)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help(expand_valid)]
|
#[help(expand_valid)]
|
||||||
pub struct MissingFragmentSpecifier {
|
pub(crate) struct MissingFragmentSpecifier {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(
|
#[suggestion(
|
||||||
|
@ -437,7 +437,7 @@ pub struct MissingFragmentSpecifier {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_invalid_fragment_specifier)]
|
#[diag(expand_invalid_fragment_specifier)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct InvalidFragmentSpecifier {
|
pub(crate) struct InvalidFragmentSpecifier {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub fragment: Ident,
|
pub fragment: Ident,
|
||||||
|
@ -446,7 +446,7 @@ pub struct InvalidFragmentSpecifier {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_expected_paren_or_brace)]
|
#[diag(expand_expected_paren_or_brace)]
|
||||||
pub struct ExpectedParenOrBrace<'a> {
|
pub(crate) struct ExpectedParenOrBrace<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub token: Cow<'a, str>,
|
pub token: Cow<'a, str>,
|
||||||
|
@ -479,7 +479,7 @@ pub(crate) struct GlobDelegationTraitlessQpath {
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_proc_macro_back_compat)]
|
#[diag(expand_proc_macro_back_compat)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct ProcMacroBackCompat {
|
pub(crate) struct ProcMacroBackCompat {
|
||||||
pub crate_name: String,
|
pub crate_name: String,
|
||||||
pub fixed_version: String,
|
pub fixed_version: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![feature(yeet_expr)]
|
#![feature(yeet_expr)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
extern crate proc_macro as pm;
|
extern crate proc_macro as pm;
|
||||||
|
|
|
@ -196,13 +196,14 @@ impl<'dcx> CollectTrackerAndEmitter<'dcx, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Currently used by macro_rules! compilation to extract a little information from the `Failure` case.
|
/// Currently used by macro_rules! compilation to extract a little information from the `Failure`
|
||||||
pub struct FailureForwarder<'matcher> {
|
/// case.
|
||||||
|
pub(crate) struct FailureForwarder<'matcher> {
|
||||||
expected_token: Option<&'matcher Token>,
|
expected_token: Option<&'matcher Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'matcher> FailureForwarder<'matcher> {
|
impl<'matcher> FailureForwarder<'matcher> {
|
||||||
pub fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
Self { expected_token: None }
|
Self { expected_token: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// 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.
|
// 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,
|
macro_name: Ident,
|
||||||
|
|
||||||
/// The set of current mps to be processed. This should be empty by the end of a successful
|
/// The set of current mps to be processed. This should be empty by the end of a successful
|
||||||
|
|
|
@ -14,12 +14,11 @@ use crate::mbe::macro_parser::count_metavar_decls;
|
||||||
use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
|
use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
|
||||||
|
|
||||||
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
|
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
|
||||||
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
|
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
|
||||||
`literal`, `path`, `meta`, `tt`, `item` and `vis`";
|
`item` and `vis`";
|
||||||
pub const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
|
pub(crate) const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
|
||||||
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, \
|
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, \
|
||||||
`ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
|
`meta`, `tt`, `item` and `vis`";
|
||||||
`item` and `vis`";
|
|
||||||
|
|
||||||
/// Takes a `tokenstream::TokenStream` and returns a `Vec<self::TokenTree>`. Specifically, this
|
/// 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
|
/// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a
|
||||||
|
|
|
@ -191,12 +191,12 @@ pub(crate) fn placeholder(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PlaceholderExpander {
|
pub(crate) struct PlaceholderExpander {
|
||||||
expanded_fragments: FxHashMap<ast::NodeId, AstFragment>,
|
expanded_fragments: FxHashMap<ast::NodeId, AstFragment>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlaceholderExpander {
|
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);
|
fragment.mut_visit_with(self);
|
||||||
self.expanded_fragments.insert(id, fragment);
|
self.expanded_fragments.insert(id, fragment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,7 +414,7 @@ impl ToInternal<rustc_errors::Level> for Level {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FreeFunctions;
|
pub(crate) struct FreeFunctions;
|
||||||
|
|
||||||
pub(crate) struct Rustc<'a, 'b> {
|
pub(crate) struct Rustc<'a, 'b> {
|
||||||
ecx: &'a mut ExtCtxt<'b>,
|
ecx: &'a mut ExtCtxt<'b>,
|
||||||
|
@ -426,7 +426,7 @@ pub(crate) struct Rustc<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> 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();
|
let expn_data = ecx.current_expansion.id.expn_data();
|
||||||
Rustc {
|
Rustc {
|
||||||
def_site: ecx.with_def_site_ctxt(expn_data.def_site),
|
def_site: ecx.with_def_site_ctxt(expn_data.def_site),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue