Skip to content

Commit 3e057d1

Browse files
authored
Rollup merge of rust-lang#100669 - nnethercote:attribute-cleanups, r=spastorino
Attribute cleanups r? `@ghost`
2 parents 8b180ed + 52d8397 commit 3e057d1

File tree

15 files changed

+6
-29
lines changed

15 files changed

+6
-29
lines changed

compiler/rustc_builtin_macros/src/deriving/bounds.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub fn expand_deriving_copy(
1515
) {
1616
let trait_def = TraitDef {
1717
span,
18-
attributes: Vec::new(),
1918
path: path_std!(marker::Copy),
2019
additional_bounds: Vec::new(),
2120
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/clone.rs

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ pub fn expand_deriving_clone(
7171
let attrs = vec![cx.attribute(inline)];
7272
let trait_def = TraitDef {
7373
span,
74-
attributes: Vec::new(),
7574
path: path_std!(clone::Clone),
7675
additional_bounds: bounds,
7776
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub fn expand_deriving_eq(
2323
let attrs = vec![cx.attribute(inline), cx.attribute(doc), cx.attribute(no_coverage)];
2424
let trait_def = TraitDef {
2525
span,
26-
attributes: Vec::new(),
2726
path: path_std!(cmp::Eq),
2827
additional_bounds: Vec::new(),
2928
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub fn expand_deriving_ord(
1818
let attrs = vec![cx.attribute(inline)];
1919
let trait_def = TraitDef {
2020
span,
21-
attributes: Vec::new(),
2221
path: path_std!(cmp::Ord),
2322
additional_bounds: Vec::new(),
2423
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub fn expand_deriving_partial_eq(
9898

9999
let trait_def = TraitDef {
100100
span,
101-
attributes: Vec::new(),
102101
path: path_std!(cmp::PartialEq),
103102
additional_bounds: Vec::new(),
104103
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub fn expand_deriving_partial_ord(
3636

3737
let trait_def = TraitDef {
3838
span,
39-
attributes: vec![],
4039
path: path_std!(cmp::PartialOrd),
4140
additional_bounds: vec![],
4241
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/debug.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn expand_deriving_debug(
1919

2020
let trait_def = TraitDef {
2121
span,
22-
attributes: Vec::new(),
2322
path: path_std!(fmt::Debug),
2423
additional_bounds: Vec::new(),
2524
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/decodable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn expand_deriving_rustc_decodable(
2222

2323
let trait_def = TraitDef {
2424
span,
25-
attributes: Vec::new(),
2625
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
2726
additional_bounds: Vec::new(),
2827
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/default.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub fn expand_deriving_default(
2525
let attrs = vec![cx.attribute(inline)];
2626
let trait_def = TraitDef {
2727
span,
28-
attributes: Vec::new(),
2928
path: Path::new(vec![kw::Default, sym::Default]),
3029
additional_bounds: Vec::new(),
3130
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/encodable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pub fn expand_deriving_rustc_encodable(
106106

107107
let trait_def = TraitDef {
108108
span,
109-
attributes: Vec::new(),
110109
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
111110
additional_bounds: Vec::new(),
112111
generics: Bounds::empty(),

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ pub struct TraitDef<'a> {
184184
/// The span for the current #[derive(Foo)] header.
185185
pub span: Span,
186186

187-
pub attributes: Vec<ast::Attribute>,
188-
189187
/// Path of the trait, including any type parameters
190188
pub path: Path,
191189

@@ -605,7 +603,7 @@ impl<'a> TraitDef<'a> {
605603
param.bounds.iter().cloned()
606604
).collect();
607605

608-
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, vec![], bounds, None)
606+
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
609607
}
610608
GenericParamKind::Const { ty, kw_span, .. } => {
611609
let const_nodefault_kind = GenericParamKind::Const {
@@ -718,15 +716,13 @@ impl<'a> TraitDef<'a> {
718716
let self_type = cx.ty_path(path);
719717

720718
let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
719+
let attrs = vec![attr];
721720
let opt_trait_ref = Some(trait_ref);
722721

723-
let mut a = vec![attr];
724-
a.extend(self.attributes.iter().cloned());
725-
726722
cx.item(
727723
self.span,
728724
Ident::empty(),
729-
a,
725+
attrs,
730726
ast::ItemKind::Impl(Box::new(ast::Impl {
731727
unsafety: ast::Unsafe::No,
732728
polarity: ast::ImplPolarity::Positive,

compiler/rustc_builtin_macros/src/deriving/generic/ty.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ fn mk_ty_param(
146146
cx: &ExtCtxt<'_>,
147147
span: Span,
148148
name: Symbol,
149-
attrs: &[ast::Attribute],
150149
bounds: &[Path],
151150
self_ident: Ident,
152151
self_generics: &Generics,
@@ -158,7 +157,7 @@ fn mk_ty_param(
158157
cx.trait_bound(path)
159158
})
160159
.collect();
161-
cx.typaram(span, Ident::new(name, span), attrs.to_owned(), bounds, None)
160+
cx.typaram(span, Ident::new(name, span), bounds, None)
162161
}
163162

164163
/// Bounds on type parameters.
@@ -183,7 +182,7 @@ impl Bounds {
183182
.iter()
184183
.map(|t| {
185184
let (name, ref bounds) = *t;
186-
mk_ty_param(cx, span, name, &[], &bounds, self_ty, self_generics)
185+
mk_ty_param(cx, span, name, &bounds, self_ty, self_generics)
187186
})
188187
.collect();
189188

compiler/rustc_builtin_macros/src/deriving/hash.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub fn expand_deriving_hash(
2121
let arg = Path::new_local(typaram);
2222
let hash_trait_def = TraitDef {
2323
span,
24-
attributes: Vec::new(),
2524
path,
2625
additional_bounds: Vec::new(),
2726
generics: Bounds::empty(),

compiler/rustc_expand/src/build.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@ impl<'a> ExtCtxt<'a> {
107107
&self,
108108
span: Span,
109109
ident: Ident,
110-
attrs: Vec<ast::Attribute>,
111110
bounds: ast::GenericBounds,
112111
default: Option<P<ast::Ty>>,
113112
) -> ast::GenericParam {
114113
ast::GenericParam {
115114
ident: ident.with_span_pos(span),
116115
id: ast::DUMMY_NODE_ID,
117-
attrs: attrs.into(),
116+
attrs: AttrVec::new(),
118117
bounds,
119118
kind: ast::GenericParamKind::Type { default },
120119
is_placeholder: false,

src/librustdoc/clean/types.rs

-6
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,6 @@ pub(crate) trait AttributesExt {
820820

821821
fn inner_docs(&self) -> bool;
822822

823-
fn other_attrs(&self) -> Vec<ast::Attribute>;
824-
825823
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>>;
826824
}
827825

@@ -848,10 +846,6 @@ impl AttributesExt for [ast::Attribute] {
848846
self.iter().find(|a| a.doc_str().is_some()).map_or(true, |a| a.style == AttrStyle::Inner)
849847
}
850848

851-
fn other_attrs(&self) -> Vec<ast::Attribute> {
852-
self.iter().filter(|attr| attr.doc_str().is_none()).cloned().collect()
853-
}
854-
855849
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
856850
let sess = tcx.sess;
857851
let doc_cfg_active = tcx.features().doc_cfg;

0 commit comments

Comments
 (0)