Skip to content

Commit 1254559

Browse files
authored
Rollup merge of rust-lang#140181 - nnethercote:rm-underscore_const, r=compiler-errors
Remove `synstructure::Structure::underscore_const` calls. The `synstructure` docs say "This method is a no-op, underscore consts are used by default now." The behaviour change occurred going from `synstructure` version 0.13.0 to 0.13.1. r? ``@SparrowLii``
2 parents 5d52b37 + 51088fd commit 1254559

File tree

6 files changed

+4
-24
lines changed

6 files changed

+4
-24
lines changed

compiler/rustc_macros/src/diagnostics/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ use synstructure::Structure;
5555
///
5656
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
5757
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
58-
pub(super) fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
59-
s.underscore_const(true);
58+
pub(super) fn diagnostic_derive(s: Structure<'_>) -> TokenStream {
6059
DiagnosticDerive::new(s).into_tokens()
6160
}
6261

@@ -102,8 +101,7 @@ pub(super) fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
102101
///
103102
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
104103
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
105-
pub(super) fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
106-
s.underscore_const(true);
104+
pub(super) fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
107105
LintDiagnosticDerive::new(s).into_tokens()
108106
}
109107

@@ -153,7 +151,6 @@ pub(super) fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
153151
///
154152
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
155153
/// ```
156-
pub(super) fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
157-
s.underscore_const(true);
154+
pub(super) fn subdiagnostic_derive(s: Structure<'_>) -> TokenStream {
158155
SubdiagnosticDerive::new().into_tokens(s)
159156
}

compiler/rustc_macros/src/hash_stable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ fn hash_stable_derive_with_mode(
7474
HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX),
7575
};
7676

77-
s.underscore_const(true);
78-
7977
// no_context impl is able to derive by-field, which is closer to a perfect derive.
8078
s.add_bounds(match mode {
8179
HashStableMode::Normal | HashStableMode::Generic => synstructure::AddBounds::Generics,

compiler/rustc_macros/src/lift.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use syn::parse_quote;
44
pub(super) fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
55
s.add_bounds(synstructure::AddBounds::Generics);
66
s.bind_with(|_| synstructure::BindStyle::Move);
7-
s.underscore_const(true);
87

98
let tcx: syn::Lifetime = parse_quote!('tcx);
109
let newtcx: syn::GenericParam = parse_quote!('__lifted);

compiler/rustc_macros/src/serialize.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub(super) fn type_decodable_derive(
1212
let decoder_ty = quote! { __D };
1313
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_middle::ty::codec::TyDecoder<'tcx> });
1414
s.add_bounds(synstructure::AddBounds::Fields);
15-
s.underscore_const(true);
1615

1716
decodable_body(s, decoder_ty)
1817
}
@@ -26,7 +25,6 @@ pub(super) fn meta_decodable_derive(
2625
s.add_impl_generic(parse_quote! { '__a });
2726
let decoder_ty = quote! { DecodeContext<'__a, 'tcx> };
2827
s.add_bounds(synstructure::AddBounds::Generics);
29-
s.underscore_const(true);
3028

3129
decodable_body(s, decoder_ty)
3230
}
@@ -35,7 +33,6 @@ pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
3533
let decoder_ty = quote! { __D };
3634
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_span::SpanDecoder });
3735
s.add_bounds(synstructure::AddBounds::Generics);
38-
s.underscore_const(true);
3936

4037
decodable_body(s, decoder_ty)
4138
}
@@ -46,13 +43,12 @@ pub(super) fn decodable_nocontext_derive(
4643
let decoder_ty = quote! { __D };
4744
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
4845
s.add_bounds(synstructure::AddBounds::Fields);
49-
s.underscore_const(true);
5046

5147
decodable_body(s, decoder_ty)
5248
}
5349

5450
fn decodable_body(
55-
mut s: synstructure::Structure<'_>,
51+
s: synstructure::Structure<'_>,
5652
decoder_ty: TokenStream,
5753
) -> proc_macro2::TokenStream {
5854
if let syn::Data::Union(_) = s.ast().data {
@@ -98,7 +94,6 @@ fn decodable_body(
9894
}
9995
}
10096
};
101-
s.underscore_const(true);
10297

10398
s.bound_impl(
10499
quote!(::rustc_serialize::Decodable<#decoder_ty>),
@@ -133,7 +128,6 @@ pub(super) fn type_encodable_derive(
133128
}
134129
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_middle::ty::codec::TyEncoder<'tcx> });
135130
s.add_bounds(synstructure::AddBounds::Fields);
136-
s.underscore_const(true);
137131

138132
encodable_body(s, encoder_ty, false)
139133
}
@@ -147,7 +141,6 @@ pub(super) fn meta_encodable_derive(
147141
s.add_impl_generic(parse_quote! { '__a });
148142
let encoder_ty = quote! { EncodeContext<'__a, 'tcx> };
149143
s.add_bounds(synstructure::AddBounds::Generics);
150-
s.underscore_const(true);
151144

152145
encodable_body(s, encoder_ty, true)
153146
}
@@ -156,7 +149,6 @@ pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
156149
let encoder_ty = quote! { __E };
157150
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder });
158151
s.add_bounds(synstructure::AddBounds::Generics);
159-
s.underscore_const(true);
160152

161153
encodable_body(s, encoder_ty, false)
162154
}
@@ -167,7 +159,6 @@ pub(super) fn encodable_nocontext_derive(
167159
let encoder_ty = quote! { __E };
168160
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
169161
s.add_bounds(synstructure::AddBounds::Fields);
170-
s.underscore_const(true);
171162

172163
encodable_body(s, encoder_ty, false)
173164
}
@@ -181,7 +172,6 @@ fn encodable_body(
181172
panic!("cannot derive on union")
182173
}
183174

184-
s.underscore_const(true);
185175
s.bind_with(|binding| {
186176
// Handle the lack of a blanket reference impl.
187177
if let syn::Type::Reference(_) = binding.ast().ty {

compiler/rustc_macros/src/type_foldable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub(super) fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_m
66
panic!("cannot derive on union")
77
}
88

9-
s.underscore_const(true);
10-
119
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
1210
s.add_impl_generic(parse_quote! { 'tcx });
1311
}

compiler/rustc_macros/src/type_visitable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ pub(super) fn type_visitable_derive(
88
panic!("cannot derive on union")
99
}
1010

11-
s.underscore_const(true);
12-
1311
// ignore fields with #[type_visitable(ignore)]
1412
s.filter(|bi| {
1513
let mut ignored = false;

0 commit comments

Comments
 (0)