Avoid some unnecessary local attr
variables.
This commit is contained in:
parent
5b0324fce0
commit
ee013d83c3
7 changed files with 11 additions and 19 deletions
|
@ -68,7 +68,6 @@ pub fn expand_deriving_clone(
|
||||||
_ => cx.span_bug(span, "`#[derive(Clone)]` on trait item or impl item"),
|
_ => cx.span_bug(span, "`#[derive(Clone)]` on trait item or impl item"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
path: path_std!(clone::Clone),
|
path: path_std!(clone::Clone),
|
||||||
|
@ -82,7 +81,7 @@ pub fn expand_deriving_clone(
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: Vec::new(),
|
nonself_args: Vec::new(),
|
||||||
ret_ty: Self_,
|
ret_ty: Self_,
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
|
||||||
combine_substructure: substructure,
|
combine_substructure: substructure,
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -18,11 +18,6 @@ pub fn expand_deriving_eq(
|
||||||
is_const: bool,
|
is_const: bool,
|
||||||
) {
|
) {
|
||||||
let span = cx.with_def_site_ctxt(span);
|
let span = cx.with_def_site_ctxt(span);
|
||||||
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 {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
path: path_std!(cmp::Eq),
|
path: path_std!(cmp::Eq),
|
||||||
|
@ -36,7 +31,11 @@ pub fn expand_deriving_eq(
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: vec![],
|
nonself_args: vec![],
|
||||||
ret_ty: Unit,
|
ret_ty: Unit,
|
||||||
attributes: attrs,
|
attributes: thin_vec![
|
||||||
|
cx.attr_word(sym::inline, span),
|
||||||
|
cx.attr_nested_word(sym::doc, sym::hidden, span),
|
||||||
|
cx.attr_word(sym::no_coverage, span)
|
||||||
|
],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
cs_total_eq_assert(a, b, c)
|
cs_total_eq_assert(a, b, c)
|
||||||
|
|
|
@ -15,7 +15,6 @@ pub fn expand_deriving_ord(
|
||||||
push: &mut dyn FnMut(Annotatable),
|
push: &mut dyn FnMut(Annotatable),
|
||||||
is_const: bool,
|
is_const: bool,
|
||||||
) {
|
) {
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
path: path_std!(cmp::Ord),
|
path: path_std!(cmp::Ord),
|
||||||
|
@ -29,7 +28,7 @@ pub fn expand_deriving_ord(
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: vec![(self_ref(), sym::other)],
|
nonself_args: vec![(self_ref(), sym::other)],
|
||||||
ret_ty: Path(path_std!(cmp::Ordering)),
|
ret_ty: Path(path_std!(cmp::Ordering)),
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
|
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -82,14 +82,13 @@ pub fn expand_deriving_partial_eq(
|
||||||
|
|
||||||
// No need to generate `ne`, the default suffices, and not generating it is
|
// No need to generate `ne`, the default suffices, and not generating it is
|
||||||
// faster.
|
// faster.
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
let methods = vec![MethodDef {
|
let methods = vec![MethodDef {
|
||||||
name: sym::eq,
|
name: sym::eq,
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: vec![(self_ref(), sym::other)],
|
nonself_args: vec![(self_ref(), sym::other)],
|
||||||
ret_ty: Path(path_local!(bool)),
|
ret_ty: Path(path_local!(bool)),
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_eq(a, b, c))),
|
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_eq(a, b, c))),
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -19,8 +19,6 @@ pub fn expand_deriving_partial_ord(
|
||||||
let ret_ty =
|
let ret_ty =
|
||||||
Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std));
|
Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std));
|
||||||
|
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
|
|
||||||
// Order in which to perform matching
|
// Order in which to perform matching
|
||||||
let tag_then_data = if let Annotatable::Item(item) = item
|
let tag_then_data = if let Annotatable::Item(item) = item
|
||||||
&& let ItemKind::Enum(def, _) = &item.kind {
|
&& let ItemKind::Enum(def, _) = &item.kind {
|
||||||
|
@ -48,7 +46,7 @@ pub fn expand_deriving_partial_ord(
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: vec![(self_ref(), sym::other)],
|
nonself_args: vec![(self_ref(), sym::other)],
|
||||||
ret_ty,
|
ret_ty,
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
||||||
cs_partial_cmp(cx, span, substr, tag_then_data)
|
cs_partial_cmp(cx, span, substr, tag_then_data)
|
||||||
|
|
|
@ -20,7 +20,6 @@ pub fn expand_deriving_default(
|
||||||
) {
|
) {
|
||||||
item.visit_with(&mut DetectNonVariantDefaultAttr { cx });
|
item.visit_with(&mut DetectNonVariantDefaultAttr { cx });
|
||||||
|
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
path: Path::new(vec![kw::Default, sym::Default]),
|
path: Path::new(vec![kw::Default, sym::Default]),
|
||||||
|
@ -34,7 +33,7 @@ pub fn expand_deriving_default(
|
||||||
explicit_self: false,
|
explicit_self: false,
|
||||||
nonself_args: Vec::new(),
|
nonself_args: Vec::new(),
|
||||||
ret_ty: Self_,
|
ret_ty: Self_,
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
|
||||||
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
|
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
|
||||||
match substr.fields {
|
match substr.fields {
|
||||||
|
|
|
@ -20,7 +20,6 @@ pub fn expand_deriving_hash(
|
||||||
let typaram = sym::__H;
|
let typaram = sym::__H;
|
||||||
|
|
||||||
let arg = Path::new_local(typaram);
|
let arg = Path::new_local(typaram);
|
||||||
let attrs = thin_vec![cx.attr_word(sym::inline, span)];
|
|
||||||
let hash_trait_def = TraitDef {
|
let hash_trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
path,
|
path,
|
||||||
|
@ -34,7 +33,7 @@ pub fn expand_deriving_hash(
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
nonself_args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
|
nonself_args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
|
||||||
ret_ty: Unit,
|
ret_ty: Unit,
|
||||||
attributes: attrs,
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
combine_substructure: combine_substructure(Box::new(|a, b, c| {
|
||||||
hash_substructure(a, b, c)
|
hash_substructure(a, b, c)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue