diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index f61978271e7f6..2ca2f69cf22db 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -93,7 +93,7 @@ pub enum NativeLibraryKind { pub struct NativeLibrary { pub kind: NativeLibraryKind, pub name: String, - pub cfg: Option>, + pub cfg: Option, } /// The data we save and restore about an inlined item or method. This is not diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index 836832de5b9c4..9035c2ab3c236 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -11,7 +11,6 @@ use borrowck::BorrowckCtxt; use syntax::ast::{self, MetaItem}; -use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP}; use rustc::hir; @@ -35,7 +34,7 @@ use self::dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals}; use self::dataflow::{DefinitelyInitializedLvals}; use self::gather_moves::{MoveData, MovePathIndex, LookupResult}; -fn has_rustc_mir_with(attrs: &[ast::Attribute], name: &str) -> Option> { +fn has_rustc_mir_with(attrs: &[ast::Attribute], name: &str) -> Option { for attr in attrs { if attr.check_name("rustc_mir") { let items = attr.meta_item_list(); diff --git a/src/librustc_incremental/calculate_svh/svh_visitor.rs b/src/librustc_incremental/calculate_svh/svh_visitor.rs index 71738b2a7d3d0..a1a7c05f774b6 100644 --- a/src/librustc_incremental/calculate_svh/svh_visitor.rs +++ b/src/librustc_incremental/calculate_svh/svh_visitor.rs @@ -919,7 +919,7 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> { if !attr.is_sugared_doc && !IGNORED_ATTRIBUTES.contains(&&*attr.value.name().as_str()) { SawAttribute(attr.style).hash(self.st); - self.hash_meta_item(&*attr.value); + self.hash_meta_item(&attr.value); } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 15bcdde058f8d..45970a63ab4a5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -505,7 +505,7 @@ pub type NestedMetaItem = Spanned; #[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialEq)] pub enum NestedMetaItemKind { /// A full MetaItem, for recursive meta items. - MetaItem(P), + MetaItem(MetaItem), /// A literal. /// /// E.g. "foo", 64, true @@ -1758,7 +1758,7 @@ pub struct AttrId(pub usize); pub struct Attribute { pub id: AttrId, pub style: AttrStyle, - pub value: P, + pub value: MetaItem, pub is_sugared_doc: bool, pub span: Span, } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index db43bb0285738..cd93b8e96e455 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -107,7 +107,7 @@ pub fn is_known(attr: &Attribute) -> bool { impl NestedMetaItem { /// Returns the MetaItem if self is a NestedMetaItemKind::MetaItem. - pub fn meta_item(&self) -> Option<&P> { + pub fn meta_item(&self) -> Option<&MetaItem> { match self.node { NestedMetaItemKind::MetaItem(ref item) => Some(&item), _ => None @@ -145,7 +145,7 @@ impl NestedMetaItem { } /// Returns a MetaItem if self is a MetaItem with Kind Word. - pub fn word(&self) -> Option<&P> { + pub fn word(&self) -> Option<&MetaItem> { self.meta_item().and_then(|meta_item| if meta_item.is_word() { Some(meta_item) } else { @@ -294,16 +294,16 @@ impl Attribute { /* Constructors */ -pub fn mk_name_value_item_str(name: Name, value: InternedString) -> P { +pub fn mk_name_value_item_str(name: Name, value: InternedString) -> MetaItem { let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::StrStyle::Cooked)); mk_spanned_name_value_item(DUMMY_SP, name, value_lit) } -pub fn mk_name_value_item(name: Name, value: ast::Lit) -> P { +pub fn mk_name_value_item(name: Name, value: ast::Lit) -> MetaItem { mk_spanned_name_value_item(DUMMY_SP, name, value) } -pub fn mk_list_item(name: Name, items: Vec) -> P { +pub fn mk_list_item(name: Name, items: Vec) -> MetaItem { mk_spanned_list_item(DUMMY_SP, name, items) } @@ -311,20 +311,20 @@ pub fn mk_list_word_item(name: Name) -> ast::NestedMetaItem { dummy_spanned(NestedMetaItemKind::MetaItem(mk_spanned_word_item(DUMMY_SP, name))) } -pub fn mk_word_item(name: Name) -> P { +pub fn mk_word_item(name: Name) -> MetaItem { mk_spanned_word_item(DUMMY_SP, name) } -pub fn mk_spanned_name_value_item(sp: Span, name: Name, value: ast::Lit) -> P { - P(MetaItem { span: sp, name: name, node: MetaItemKind::NameValue(value) }) +pub fn mk_spanned_name_value_item(sp: Span, name: Name, value: ast::Lit) -> MetaItem { + MetaItem { span: sp, name: name, node: MetaItemKind::NameValue(value) } } -pub fn mk_spanned_list_item(sp: Span, name: Name, items: Vec) -> P { - P(MetaItem { span: sp, name: name, node: MetaItemKind::List(items) }) +pub fn mk_spanned_list_item(sp: Span, name: Name, items: Vec) -> MetaItem { + MetaItem { span: sp, name: name, node: MetaItemKind::List(items) } } -pub fn mk_spanned_word_item(sp: Span, name: Name) -> P { - P(MetaItem { span: sp, name: name, node: MetaItemKind::Word }) +pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem { + MetaItem { span: sp, name: name, node: MetaItemKind::Word } } @@ -341,12 +341,12 @@ pub fn mk_attr_id() -> AttrId { } /// Returns an inner attribute with the given value. -pub fn mk_attr_inner(id: AttrId, item: P) -> Attribute { +pub fn mk_attr_inner(id: AttrId, item: MetaItem) -> Attribute { mk_spanned_attr_inner(DUMMY_SP, id, item) } /// Returns an innter attribute with the given value and span. -pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: P) -> Attribute { +pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute { Attribute { id: id, style: ast::AttrStyle::Inner, @@ -358,12 +358,12 @@ pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: P) -> Attribu /// Returns an outer attribute with the given value. -pub fn mk_attr_outer(id: AttrId, item: P) -> Attribute { +pub fn mk_attr_outer(id: AttrId, item: MetaItem) -> Attribute { mk_spanned_attr_outer(DUMMY_SP, id, item) } /// Returns an outer attribute with the given value and span. -pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: P) -> Attribute { +pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute { Attribute { id: id, style: ast::AttrStyle::Outer, @@ -373,7 +373,7 @@ pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: P) -> Attribu } } -pub fn mk_doc_attr_outer(id: AttrId, item: P, is_sugared_doc: bool) -> Attribute { +pub fn mk_doc_attr_outer(id: AttrId, item: MetaItem, is_sugared_doc: bool) -> Attribute { Attribute { id: id, style: ast::AttrStyle::Outer, @@ -390,11 +390,11 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, hi: By Attribute { id: id, style: style, - value: P(MetaItem { + value: MetaItem { span: mk_sp(lo, hi), name: token::intern("doc"), node: MetaItemKind::NameValue(lit), - }), + }, is_sugared_doc: true, span: mk_sp(lo, hi), } @@ -423,8 +423,7 @@ pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str) .and_then(|at| at.value_str()) } -pub fn last_meta_item_value_str_by_name(items: &[P], name: &str) - -> Option { +pub fn last_meta_item_value_str_by_name(items: &[MetaItem], name: &str) -> Option { items.iter() .rev() .find(|mi| mi.check_name(name)) @@ -859,7 +858,7 @@ pub fn find_deprecation(diagnostic: &Handler, attrs: &[Attribute], find_deprecation_generic(diagnostic, attrs.iter(), item_sp) } -pub fn require_unique_names(diagnostic: &Handler, metas: &[P]) { +pub fn require_unique_names(diagnostic: &Handler, metas: &[MetaItem]) { let mut set = HashSet::new(); for meta in metas { let name = meta.name(); diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 75e931351717c..f488e1cf95c37 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -275,9 +275,9 @@ pub trait AstBuilder { generics: Generics) -> P; fn item_ty(&self, span: Span, name: Ident, ty: P) -> P; - fn attribute(&self, sp: Span, mi: P) -> ast::Attribute; + fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute; - fn meta_word(&self, sp: Span, w: ast::Name) -> P; + fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem; fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem; @@ -285,12 +285,12 @@ pub trait AstBuilder { sp: Span, name: ast::Name, mis: Vec ) - -> P; + -> ast::MetaItem; fn meta_name_value(&self, sp: Span, name: ast::Name, value: ast::LitKind) - -> P; + -> ast::MetaItem; fn item_use(&self, sp: Span, vis: ast::Visibility, vp: P) -> P; @@ -1146,11 +1146,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.item_ty_poly(span, name, ty, Generics::default()) } - fn attribute(&self, sp: Span, mi: P) -> ast::Attribute { + fn attribute(&self, sp: Span, mi: ast::MetaItem) -> ast::Attribute { attr::mk_spanned_attr_outer(sp, attr::mk_attr_id(), mi) } - fn meta_word(&self, sp: Span, w: ast::Name) -> P { + fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem { attr::mk_spanned_word_item(sp, w) } @@ -1159,12 +1159,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec) - -> P { + -> ast::MetaItem { attr::mk_spanned_list_item(sp, name, mis) } fn meta_name_value(&self, sp: Span, name: ast::Name, value: ast::LitKind) - -> P { + -> ast::MetaItem { attr::mk_spanned_name_value_item(sp, name, respan(sp, value)) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 4386dbeb8344e..fa38f21e9b37c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -211,7 +211,7 @@ pub mod rt { impl_to_tokens_slice! { P, [] } impl_to_tokens_slice! { ast::Arg, [TokenTree::Token(DUMMY_SP, token::Comma)] } - impl ToTokens for P { + impl ToTokens for ast::MetaItem { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { let nt = token::NtMeta(self.clone()); vec![TokenTree::Token(DUMMY_SP, token::Interpolated(Rc::new(nt)))] @@ -405,7 +405,7 @@ pub fn parse_block_panic(parser: &mut Parser) -> P { panictry!(parser.parse_block()) } -pub fn parse_meta_item_panic(parser: &mut Parser) -> P { +pub fn parse_meta_item_panic(parser: &mut Parser) -> ast::MetaItem { panictry!(parser.parse_meta_item()) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 68562e02f9a83..19f5e860b27e7 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -995,7 +995,7 @@ fn contains_novel_literal(item: &ast::MetaItem) -> bool { NameValue(ref lit) => !lit.node.is_str(), List(ref list) => list.iter().any(|li| { match li.node { - MetaItem(ref mi) => contains_novel_literal(&**mi), + MetaItem(ref mi) => contains_novel_literal(&mi), Literal(_) => true, } }), @@ -1013,7 +1013,7 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { self.context.check_attribute(attr, false); } - if contains_novel_literal(&*(attr.value)) { + if contains_novel_literal(&attr.value) { gate_feature_post!(&self, attr_literals, attr.span, "non-string literals in attributes, or string \ literals in top-level positions, are experimental"); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2a544eee00450..b6c87155d6b1c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -43,7 +43,7 @@ pub trait Folder : Sized { noop_fold_crate(c, self) } - fn fold_meta_items(&mut self, meta_items: Vec>) -> Vec> { + fn fold_meta_items(&mut self, meta_items: Vec) -> Vec { noop_fold_meta_items(meta_items, self) } @@ -51,7 +51,7 @@ pub trait Folder : Sized { noop_fold_meta_list_item(list_item, self) } - fn fold_meta_item(&mut self, meta_item: P) -> P { + fn fold_meta_item(&mut self, meta_item: MetaItem) -> MetaItem { noop_fold_meta_item(meta_item, self) } @@ -293,8 +293,7 @@ pub trait Folder : Sized { } } -pub fn noop_fold_meta_items(meta_items: Vec>, fld: &mut T) - -> Vec> { +pub fn noop_fold_meta_items(meta_items: Vec, fld: &mut T) -> Vec { meta_items.move_map(|x| fld.fold_meta_item(x)) } @@ -519,18 +518,18 @@ pub fn noop_fold_meta_list_item(li: NestedMetaItem, fld: &mut T) } } -pub fn noop_fold_meta_item(mi: P, fld: &mut T) -> P { - mi.map(|MetaItem { name, node, span }| MetaItem { - name: name, - node: match node { +pub fn noop_fold_meta_item(mi: MetaItem, fld: &mut T) -> MetaItem { + MetaItem { + name: mi.name, + node: match mi.node { MetaItemKind::Word => MetaItemKind::Word, MetaItemKind::List(mis) => { MetaItemKind::List(mis.move_map(|e| fld.fold_meta_list_item(e))) }, MetaItemKind::NameValue(s) => MetaItemKind::NameValue(s), }, - span: fld.new_span(span) - }) + span: fld.new_span(mi.span) + } } pub fn noop_fold_arg(Arg {id, pat, ty}: Arg, fld: &mut T) -> Arg { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index f6405807a2531..a6e40d70e2fc1 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -16,7 +16,6 @@ use parse::common::SeqSep; use parse::PResult; use parse::token; use parse::parser::{Parser, TokenType}; -use ptr::P; #[derive(PartialEq, Eq, Debug)] enum InnerAttributeParsePolicy<'a> { @@ -211,7 +210,7 @@ impl<'a> Parser<'a> { /// /// meta_item : IDENT ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ; /// meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ; - pub fn parse_meta_item(&mut self) -> PResult<'a, P> { + pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> { let nt_meta = match self.token { token::Interpolated(ref nt) => match **nt { token::NtMeta(ref e) => Some(e.clone()), @@ -235,7 +234,7 @@ impl<'a> Parser<'a> { ast::MetaItemKind::Word }; let hi = self.prev_span.hi; - Ok(P(ast::MetaItem { name: ident.name, node: node, span: mk_sp(lo, hi) })) + Ok(ast::MetaItem { name: ident.name, node: node, span: mk_sp(lo, hi) }) } /// matches meta_item_inner : (meta_item | UNSUFFIXED_LIT) ; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 7feb745259c1b..19e8b711ba485 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -117,7 +117,7 @@ pub fn parse_item_from_source_str<'a>(name: String, source: String, sess: &'a Pa } pub fn parse_meta_from_source_str<'a>(name: String, source: String, sess: &'a ParseSess) - -> PResult<'a, P> { + -> PResult<'a, ast::MetaItem> { new_parser_from_source_str(sess, name, source).parse_meta_item() } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 9493cd281eaf4..4aaa028ef75e2 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -301,7 +301,7 @@ pub enum Nonterminal { NtTy(P), NtIdent(ast::SpannedIdent), /// Stuff inside brackets for attributes - NtMeta(P), + NtMeta(ast::MetaItem), NtPath(ast::Path), NtTT(tokenstream::TokenTree), // These are not exposed to macros, but are used by quasiquote. diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index e999af2907918..166d95911b96c 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -69,11 +69,11 @@ pub fn maybe_inject_crates_ref(sess: &ParseSess, krate.module.items.insert(0, P(ast::Item { attrs: vec![ast::Attribute { style: ast::AttrStyle::Outer, - value: P(ast::MetaItem { + value: ast::MetaItem { name: token::intern("prelude_import"), node: ast::MetaItemKind::Word, span: span, - }), + }, id: attr::mk_attr_id(), is_sugared_doc: false, span: span, diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 32dcdcfd1107e..ef4c02931ab48 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -116,7 +116,7 @@ pub fn expand_derive(cx: &mut ExtCtxt, // Expand `#[derive]`s after other attribute macro invocations. if cx.resolver.find_attr_invoc(&mut item.attrs.clone()).is_some() { return vec![Annotatable::Item(item.map_attrs(|mut attrs| { - attrs.push(cx.attribute(span, P(mitem.clone()))); + attrs.push(cx.attribute(span, mitem.clone())); attrs.extend(derive_attrs); attrs }))];