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.
This commit is contained in:
parent
8b4b20836b
commit
5b0324fce0
2 changed files with 18 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue