diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-26 06:55:06 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-05-26 06:55:06 +1000 |
| commit | 5b0324fce09e1b08d4ebb51e90d1e37d206bef3b (patch) | |
| tree | 57235abd8c9a70a0192cbf72c567bc3ecf520485 /compiler | |
| parent | 8b4b20836b832e91aa605a2faf5e2a55190202c8 (diff) | |
| download | rust-5b0324fce09e1b08d4ebb51e90d1e37d206bef3b.tar.gz rust-5b0324fce09e1b08d4ebb51e90d1e37d206bef3b.zip | |
Inline derived `hash` function.
Because most of the other derived functions are inlined: `clone`, `default`, `eq`, `partial_cmp`, `cmp`. The exception is `fmt`, but it tends to not be on hot paths as much.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/deriving/hash.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs index 4eee573db42..6fea50feb2a 100644 --- a/compiler/rustc_builtin_macros/src/deriving/hash.rs +++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs @@ -1,7 +1,7 @@ use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::{path_std, pathvec_std}; -use rustc_ast::{AttrVec, MetaItem, Mutability}; +use rustc_ast::{MetaItem, Mutability}; use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -20,6 +20,7 @@ pub fn expand_deriving_hash( let typaram = sym::__H; let arg = Path::new_local(typaram); + let attrs = thin_vec![cx.attr_word(sym::inline, span)]; let hash_trait_def = TraitDef { span, path, @@ -33,7 +34,7 @@ pub fn expand_deriving_hash( explicit_self: true, nonself_args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)], ret_ty: Unit, - attributes: AttrVec::new(), + attributes: attrs, fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, combine_substructure: combine_substructure(Box::new(|a, b, c| { hash_substructure(a, b, c) |
