Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino
Attribute cleanups r? `@ghost`
This commit is contained in:
commit
3e057d1512
15 changed files with 6 additions and 29 deletions
|
@ -15,7 +15,6 @@ pub fn expand_deriving_copy(
|
||||||
) {
|
) {
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(marker::Copy),
|
path: path_std!(marker::Copy),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -71,7 +71,6 @@ pub fn expand_deriving_clone(
|
||||||
let attrs = vec![cx.attribute(inline)];
|
let attrs = vec![cx.attribute(inline)];
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(clone::Clone),
|
path: path_std!(clone::Clone),
|
||||||
additional_bounds: bounds,
|
additional_bounds: bounds,
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -23,7 +23,6 @@ pub fn expand_deriving_eq(
|
||||||
let attrs = vec![cx.attribute(inline), cx.attribute(doc), cx.attribute(no_coverage)];
|
let attrs = vec![cx.attribute(inline), cx.attribute(doc), cx.attribute(no_coverage)];
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(cmp::Eq),
|
path: path_std!(cmp::Eq),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -18,7 +18,6 @@ pub fn expand_deriving_ord(
|
||||||
let attrs = vec![cx.attribute(inline)];
|
let attrs = vec![cx.attribute(inline)];
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(cmp::Ord),
|
path: path_std!(cmp::Ord),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -98,7 +98,6 @@ pub fn expand_deriving_partial_eq(
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(cmp::PartialEq),
|
path: path_std!(cmp::PartialEq),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -36,7 +36,6 @@ pub fn expand_deriving_partial_ord(
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: vec![],
|
|
||||||
path: path_std!(cmp::PartialOrd),
|
path: path_std!(cmp::PartialOrd),
|
||||||
additional_bounds: vec![],
|
additional_bounds: vec![],
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub fn expand_deriving_debug(
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: path_std!(fmt::Debug),
|
path: path_std!(fmt::Debug),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -22,7 +22,6 @@ pub fn expand_deriving_rustc_decodable(
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -25,7 +25,6 @@ pub fn expand_deriving_default(
|
||||||
let attrs = vec![cx.attribute(inline)];
|
let attrs = vec![cx.attribute(inline)];
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: Path::new(vec![kw::Default, sym::Default]),
|
path: Path::new(vec![kw::Default, sym::Default]),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -106,7 +106,6 @@ pub fn expand_deriving_rustc_encodable(
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -184,8 +184,6 @@ pub struct TraitDef<'a> {
|
||||||
/// The span for the current #[derive(Foo)] header.
|
/// The span for the current #[derive(Foo)] header.
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
||||||
pub attributes: Vec<ast::Attribute>,
|
|
||||||
|
|
||||||
/// Path of the trait, including any type parameters
|
/// Path of the trait, including any type parameters
|
||||||
pub path: Path,
|
pub path: Path,
|
||||||
|
|
||||||
|
@ -605,7 +603,7 @@ impl<'a> TraitDef<'a> {
|
||||||
param.bounds.iter().cloned()
|
param.bounds.iter().cloned()
|
||||||
).collect();
|
).collect();
|
||||||
|
|
||||||
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, vec![], bounds, None)
|
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { ty, kw_span, .. } => {
|
GenericParamKind::Const { ty, kw_span, .. } => {
|
||||||
let const_nodefault_kind = GenericParamKind::Const {
|
let const_nodefault_kind = GenericParamKind::Const {
|
||||||
|
@ -718,15 +716,13 @@ impl<'a> TraitDef<'a> {
|
||||||
let self_type = cx.ty_path(path);
|
let self_type = cx.ty_path(path);
|
||||||
|
|
||||||
let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
|
let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
|
||||||
|
let attrs = vec![attr];
|
||||||
let opt_trait_ref = Some(trait_ref);
|
let opt_trait_ref = Some(trait_ref);
|
||||||
|
|
||||||
let mut a = vec![attr];
|
|
||||||
a.extend(self.attributes.iter().cloned());
|
|
||||||
|
|
||||||
cx.item(
|
cx.item(
|
||||||
self.span,
|
self.span,
|
||||||
Ident::empty(),
|
Ident::empty(),
|
||||||
a,
|
attrs,
|
||||||
ast::ItemKind::Impl(Box::new(ast::Impl {
|
ast::ItemKind::Impl(Box::new(ast::Impl {
|
||||||
unsafety: ast::Unsafe::No,
|
unsafety: ast::Unsafe::No,
|
||||||
polarity: ast::ImplPolarity::Positive,
|
polarity: ast::ImplPolarity::Positive,
|
||||||
|
|
|
@ -146,7 +146,6 @@ fn mk_ty_param(
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
attrs: &[ast::Attribute],
|
|
||||||
bounds: &[Path],
|
bounds: &[Path],
|
||||||
self_ident: Ident,
|
self_ident: Ident,
|
||||||
self_generics: &Generics,
|
self_generics: &Generics,
|
||||||
|
@ -158,7 +157,7 @@ fn mk_ty_param(
|
||||||
cx.trait_bound(path)
|
cx.trait_bound(path)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
cx.typaram(span, Ident::new(name, span), attrs.to_owned(), bounds, None)
|
cx.typaram(span, Ident::new(name, span), bounds, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bounds on type parameters.
|
/// Bounds on type parameters.
|
||||||
|
@ -183,7 +182,7 @@ impl Bounds {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
let (name, ref bounds) = *t;
|
let (name, ref bounds) = *t;
|
||||||
mk_ty_param(cx, span, name, &[], &bounds, self_ty, self_generics)
|
mk_ty_param(cx, span, name, &bounds, self_ty, self_generics)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ pub fn expand_deriving_hash(
|
||||||
let arg = Path::new_local(typaram);
|
let arg = Path::new_local(typaram);
|
||||||
let hash_trait_def = TraitDef {
|
let hash_trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
|
||||||
path,
|
path,
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
|
|
|
@ -107,14 +107,13 @@ impl<'a> ExtCtxt<'a> {
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
attrs: Vec<ast::Attribute>,
|
|
||||||
bounds: ast::GenericBounds,
|
bounds: ast::GenericBounds,
|
||||||
default: Option<P<ast::Ty>>,
|
default: Option<P<ast::Ty>>,
|
||||||
) -> ast::GenericParam {
|
) -> ast::GenericParam {
|
||||||
ast::GenericParam {
|
ast::GenericParam {
|
||||||
ident: ident.with_span_pos(span),
|
ident: ident.with_span_pos(span),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
attrs: attrs.into(),
|
attrs: AttrVec::new(),
|
||||||
bounds,
|
bounds,
|
||||||
kind: ast::GenericParamKind::Type { default },
|
kind: ast::GenericParamKind::Type { default },
|
||||||
is_placeholder: false,
|
is_placeholder: false,
|
||||||
|
|
|
@ -820,8 +820,6 @@ pub(crate) trait AttributesExt {
|
||||||
|
|
||||||
fn inner_docs(&self) -> bool;
|
fn inner_docs(&self) -> bool;
|
||||||
|
|
||||||
fn other_attrs(&self) -> Vec<ast::Attribute>;
|
|
||||||
|
|
||||||
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>>;
|
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,10 +846,6 @@ impl AttributesExt for [ast::Attribute] {
|
||||||
self.iter().find(|a| a.doc_str().is_some()).map_or(true, |a| a.style == AttrStyle::Inner)
|
self.iter().find(|a| a.doc_str().is_some()).map_or(true, |a| a.style == AttrStyle::Inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn other_attrs(&self) -> Vec<ast::Attribute> {
|
|
||||||
self.iter().filter(|attr| attr.doc_str().is_none()).cloned().collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
|
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
let doc_cfg_active = tcx.features().doc_cfg;
|
let doc_cfg_active = tcx.features().doc_cfg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue