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 --- compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs | 15 ++++++++------- compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs | 6 +++--- .../rustc_builtin_macros/src/deriving/cmp/partial_eq.rs | 6 +++--- .../rustc_builtin_macros/src/deriving/cmp/partial_ord.rs | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'compiler/rustc_builtin_macros/src/deriving/cmp') diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs index eab67b0d3..f861d47ed 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs @@ -5,7 +5,7 @@ use crate::deriving::path_std; use rustc_ast::{self as ast, MetaItem}; use rustc_data_structures::fx::FxHashSet; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{sym, Ident}; +use rustc_span::symbol::sym; use rustc_span::Span; use thin_vec::thin_vec; @@ -15,19 +15,19 @@ pub fn expand_deriving_eq( mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), + is_const: bool, ) { let span = cx.with_def_site_ctxt(span); - let inline = cx.meta_word(span, sym::inline); - let hidden = rustc_ast::attr::mk_nested_word_item(Ident::new(sym::hidden, span)); - let doc = rustc_ast::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]); - let no_coverage = cx.meta_word(span, sym::no_coverage); - let attrs = thin_vec![cx.attribute(inline), cx.attribute(doc), cx.attribute(no_coverage)]; + let attrs = thin_vec![ + cx.attr_word(sym::inline, span), + cx.attr_nested_word(sym::doc, sym::hidden, span), + cx.attr_word(sym::no_coverage, span) + ]; let trait_def = TraitDef { span, path: path_std!(cmp::Eq), skip_path_as_bound: false, additional_bounds: Vec::new(), - generics: Bounds::empty(), supports_unions: true, methods: vec![MethodDef { name: sym::assert_receiver_is_total_eq, @@ -42,6 +42,7 @@ pub fn expand_deriving_eq( })), }], associated_types: Vec::new(), + is_const, }; super::inject_impl_of_structural_trait(cx, span, item, path_std!(marker::StructuralEq), push); diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs index 7f117981a..96d18c7af 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs @@ -13,15 +13,14 @@ pub fn expand_deriving_ord( mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), + is_const: bool, ) { - let inline = cx.meta_word(span, sym::inline); - let attrs = thin_vec![cx.attribute(inline)]; + let attrs = thin_vec![cx.attr_word(sym::inline, span)]; let trait_def = TraitDef { span, path: path_std!(cmp::Ord), skip_path_as_bound: false, additional_bounds: Vec::new(), - generics: Bounds::empty(), supports_unions: false, methods: vec![MethodDef { name: sym::cmp, @@ -34,6 +33,7 @@ pub fn expand_deriving_ord( combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))), }], associated_types: Vec::new(), + is_const, }; trait_def.expand(cx, mitem, item, push) diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs index 236cbccaf..7f95551fc 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs @@ -14,6 +14,7 @@ pub fn expand_deriving_partial_eq( mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), + is_const: bool, ) { fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr { let base = true; @@ -67,8 +68,7 @@ pub fn expand_deriving_partial_eq( // No need to generate `ne`, the default suffices, and not generating it is // faster. - let inline = cx.meta_word(span, sym::inline); - let attrs = thin_vec![cx.attribute(inline)]; + let attrs = thin_vec![cx.attr_word(sym::inline, span)]; let methods = vec![MethodDef { name: sym::eq, generics: Bounds::empty(), @@ -85,10 +85,10 @@ pub fn expand_deriving_partial_eq( path: path_std!(cmp::PartialEq), skip_path_as_bound: false, additional_bounds: Vec::new(), - generics: Bounds::empty(), supports_unions: false, methods, associated_types: Vec::new(), + is_const, }; trait_def.expand(cx, mitem, item, push) } diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs index 4173403a1..5c4e5b7f8 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs @@ -13,13 +13,13 @@ pub fn expand_deriving_partial_ord( mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), + is_const: bool, ) { let ordering_ty = Path(path_std!(cmp::Ordering)); let ret_ty = Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std)); - let inline = cx.meta_word(span, sym::inline); - let attrs = thin_vec![cx.attribute(inline)]; + let attrs = thin_vec![cx.attr_word(sym::inline, span)]; let partial_cmp_def = MethodDef { name: sym::partial_cmp, @@ -39,10 +39,10 @@ pub fn expand_deriving_partial_ord( path: path_std!(cmp::PartialOrd), skip_path_as_bound: false, additional_bounds: vec![], - generics: Bounds::empty(), supports_unions: false, methods: vec![partial_cmp_def], associated_types: Vec::new(), + is_const, }; trait_def.expand(cx, mitem, item, push) } -- cgit v1.2.3