From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- .../rustc_builtin_macros/src/deriving/decodable.rs | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_builtin_macros/src/deriving/decodable.rs') diff --git a/compiler/rustc_builtin_macros/src/deriving/decodable.rs b/compiler/rustc_builtin_macros/src/deriving/decodable.rs index d669f6168..62af02c2b 100644 --- a/compiler/rustc_builtin_macros/src/deriving/decodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/decodable.rs @@ -16,6 +16,7 @@ pub fn expand_deriving_rustc_decodable( mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), + is_const: bool, ) { let krate = sym::rustc_serialize; let typaram = sym::__D; @@ -25,7 +26,6 @@ pub fn expand_deriving_rustc_decodable( path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global), skip_path_as_bound: false, additional_bounds: Vec::new(), - generics: Bounds::empty(), supports_unions: false, methods: vec![MethodDef { name: sym::decode, @@ -55,6 +55,7 @@ pub fn expand_deriving_rustc_decodable( })), }], associated_types: Vec::new(), + is_const, }; trait_def.expand(cx, mitem, item, push) @@ -77,11 +78,11 @@ fn decodable_substructure( let blkarg = Ident::new(sym::_d, trait_span); let blkdecoder = cx.expr_ident(trait_span, blkarg); - let expr = match *substr.fields { - StaticStruct(_, ref summary) => { - let nfields = match *summary { - Unnamed(ref fields, _) => fields.len(), - Named(ref fields) => fields.len(), + let expr = match substr.fields { + StaticStruct(_, summary) => { + let nfields = match summary { + Unnamed(fields, _) => fields.len(), + Named(fields) => fields.len(), }; let fn_read_struct_field_path: Vec<_> = cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_struct_field]); @@ -118,7 +119,7 @@ fn decodable_substructure( ], ) } - StaticEnum(_, ref fields) => { + StaticEnum(_, fields) => { let variant = Ident::new(sym::i, trait_span); let mut arms = Vec::with_capacity(fields.len() + 1); @@ -193,10 +194,10 @@ fn decode_static_fields( where F: FnMut(&mut ExtCtxt<'_>, Span, Symbol, usize) -> P, { - match *fields { - Unnamed(ref fields, is_tuple) => { + match fields { + Unnamed(fields, is_tuple) => { let path_expr = cx.expr_path(outer_pat_path); - if !is_tuple { + if !*is_tuple { path_expr } else { let fields = fields @@ -208,7 +209,7 @@ where cx.expr_call(trait_span, path_expr, fields) } } - Named(ref fields) => { + Named(fields) => { // use the field's span to get nicer error messages. let fields = fields .iter() -- cgit v1.2.3