Add warn(unreachable_pub)
to rustc_metadata
.
This commit is contained in:
parent
4b92682530
commit
05e07381d0
6 changed files with 29 additions and 14 deletions
|
@ -3,7 +3,9 @@ use quote::{quote, quote_spanned};
|
|||
use syn::parse_quote;
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
pub(super) 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 bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
||||
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
||||
|
@ -20,7 +22,9 @@ pub(super) fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_
|
|||
decodable_body(s, decoder_ty)
|
||||
}
|
||||
|
||||
pub(super) 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") {
|
||||
s.add_impl_generic(parse_quote! { 'tcx });
|
||||
}
|
||||
|
@ -41,7 +45,9 @@ pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
|
|||
decodable_body(s, decoder_ty)
|
||||
}
|
||||
|
||||
pub(super) 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 };
|
||||
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
|
||||
s.add_bounds(synstructure::AddBounds::Generics);
|
||||
|
@ -123,7 +129,9 @@ fn decode_field(field: &syn::Field) -> proc_macro2::TokenStream {
|
|||
quote_spanned! { field_span=> #decode_inner_method(#__decoder) }
|
||||
}
|
||||
|
||||
pub(super) 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") {
|
||||
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
|
||||
} else if s.ast().generics.type_params().any(|ty| ty.ident == "I") {
|
||||
|
@ -140,7 +148,9 @@ pub(super) fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_
|
|||
encodable_body(s, encoder_ty, false)
|
||||
}
|
||||
|
||||
pub(super) 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") {
|
||||
s.add_impl_generic(parse_quote! { 'tcx });
|
||||
}
|
||||
|
@ -161,7 +171,9 @@ pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
|
|||
encodable_body(s, encoder_ty, false)
|
||||
}
|
||||
|
||||
pub(super) 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 };
|
||||
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
|
||||
s.add_bounds(synstructure::AddBounds::Generics);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use quote::quote;
|
||||
use syn::parse_quote;
|
||||
|
||||
pub(super) 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 {
|
||||
panic!("cannot derive on union")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue