mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add warn(unreachable_pub)
to rustc_macros
.
This commit is contained in:
parent
6cf068db56
commit
4b92682530
@ -55,7 +55,7 @@ use synstructure::Structure;
|
|||||||
///
|
///
|
||||||
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
|
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
|
||||||
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
|
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
|
||||||
pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
pub(super) fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
DiagnosticDerive::new(s).into_tokens()
|
DiagnosticDerive::new(s).into_tokens()
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
|||||||
///
|
///
|
||||||
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
|
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
|
||||||
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
|
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
|
||||||
pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
pub(super) fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
LintDiagnosticDerive::new(s).into_tokens()
|
LintDiagnosticDerive::new(s).into_tokens()
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
|||||||
///
|
///
|
||||||
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
|
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
|
||||||
/// ```
|
/// ```
|
||||||
pub fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
pub(super) fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
SubdiagnosticDerive::new().into_tokens(s)
|
SubdiagnosticDerive::new().into_tokens(s)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#![feature(proc_macro_diagnostic)]
|
#![feature(proc_macro_diagnostic)]
|
||||||
#![feature(proc_macro_span)]
|
#![feature(proc_macro_span)]
|
||||||
#![feature(proc_macro_tracked_env)]
|
#![feature(proc_macro_tracked_env)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
|
|
||||||
pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
s.add_bounds(synstructure::AddBounds::Generics);
|
s.add_bounds(synstructure::AddBounds::Generics);
|
||||||
s.bind_with(|_| synstructure::BindStyle::Move);
|
s.bind_with(|_| synstructure::BindStyle::Move);
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
|
@ -307,7 +307,7 @@ fn add_query_desc_cached_impl(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
|
||||||
let queries = parse_macro_input!(input as List<Query>);
|
let queries = parse_macro_input!(input as List<Query>);
|
||||||
|
|
||||||
let mut query_stream = quote! {};
|
let mut query_stream = quote! {};
|
||||||
|
@ -3,7 +3,7 @@ use quote::{quote, quote_spanned};
|
|||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
|
|
||||||
pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let decoder_ty = quote! { __D };
|
let decoder_ty = quote! { __D };
|
||||||
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
||||||
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
||||||
@ -20,7 +20,7 @@ pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||||||
decodable_body(s, decoder_ty)
|
decodable_body(s, decoder_ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
||||||
s.add_impl_generic(parse_quote! { 'tcx });
|
s.add_impl_generic(parse_quote! { 'tcx });
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||||||
decodable_body(s, decoder_ty)
|
decodable_body(s, decoder_ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let decoder_ty = quote! { __D };
|
let decoder_ty = quote! { __D };
|
||||||
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_span::SpanDecoder });
|
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_span::SpanDecoder });
|
||||||
s.add_bounds(synstructure::AddBounds::Generics);
|
s.add_bounds(synstructure::AddBounds::Generics);
|
||||||
@ -41,7 +41,7 @@ pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
|
|||||||
decodable_body(s, decoder_ty)
|
decodable_body(s, decoder_ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let decoder_ty = quote! { __D };
|
let decoder_ty = quote! { __D };
|
||||||
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
|
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
|
||||||
s.add_bounds(synstructure::AddBounds::Generics);
|
s.add_bounds(synstructure::AddBounds::Generics);
|
||||||
@ -123,7 +123,7 @@ fn decode_field(field: &syn::Field) -> proc_macro2::TokenStream {
|
|||||||
quote_spanned! { field_span=> #decode_inner_method(#__decoder) }
|
quote_spanned! { field_span=> #decode_inner_method(#__decoder) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
||||||
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
||||||
} else if s.ast().generics.type_params().any(|ty| ty.ident == "I") {
|
} else if s.ast().generics.type_params().any(|ty| ty.ident == "I") {
|
||||||
@ -140,7 +140,7 @@ pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||||||
encodable_body(s, encoder_ty, false)
|
encodable_body(s, encoder_ty, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
||||||
s.add_impl_generic(parse_quote! { 'tcx });
|
s.add_impl_generic(parse_quote! { 'tcx });
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
|||||||
encodable_body(s, encoder_ty, true)
|
encodable_body(s, encoder_ty, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let encoder_ty = quote! { __E };
|
let encoder_ty = quote! { __E };
|
||||||
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder });
|
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder });
|
||||||
s.add_bounds(synstructure::AddBounds::Generics);
|
s.add_bounds(synstructure::AddBounds::Generics);
|
||||||
@ -161,7 +161,7 @@ pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
|
|||||||
encodable_body(s, encoder_ty, false)
|
encodable_body(s, encoder_ty, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
let encoder_ty = quote! { __E };
|
let encoder_ty = quote! { __E };
|
||||||
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
|
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
|
||||||
s.add_bounds(synstructure::AddBounds::Generics);
|
s.add_bounds(synstructure::AddBounds::Generics);
|
||||||
|
@ -131,7 +131,7 @@ impl Errors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symbols(input: TokenStream) -> TokenStream {
|
pub(super) fn symbols(input: TokenStream) -> TokenStream {
|
||||||
let (mut output, errors) = symbols_with_errors(input);
|
let (mut output, errors) = symbols_with_errors(input);
|
||||||
|
|
||||||
// If we generated any errors, then report them as compiler_error!() macro calls.
|
// If we generated any errors, then report them as compiler_error!() macro calls.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use quote::{quote, ToTokens};
|
use quote::{quote, ToTokens};
|
||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
|
|
||||||
pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
if let syn::Data::Union(_) = s.ast().data {
|
if let syn::Data::Union(_) = s.ast().data {
|
||||||
panic!("cannot derive on union")
|
panic!("cannot derive on union")
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
|
|
||||||
pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub(super) fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
if let syn::Data::Union(_) = s.ast().data {
|
if let syn::Data::Union(_) = s.ast().data {
|
||||||
panic!("cannot derive on union")
|
panic!("cannot derive on union")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user