diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-03-24 21:17:27 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-04-06 11:52:16 +0300 |
| commit | 3a30bad6de92fd00f24b8ba9547798cb1afa1ba3 (patch) | |
| tree | 07ccbbb3d1690546c1f0ad75136aafaf08a84e62 /src/libsyntax | |
| parent | 303298b1d53186c17b2466ac8678de77ea2a15fb (diff) | |
| download | rust-3a30bad6de92fd00f24b8ba9547798cb1afa1ba3.tar.gz rust-3a30bad6de92fd00f24b8ba9547798cb1afa1ba3.zip | |
Use `Ident` instead of `Name` in `MetaItem`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 106 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 8 |
11 files changed, 77 insertions, 96 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e51702c2eb8..e7900af7f12 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -477,7 +477,7 @@ pub enum NestedMetaItemKind { /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]` #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct MetaItem { - pub name: Name, + pub ident: Ident, pub node: MetaItemKind, pub span: Span, } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 04232bf15bc..2812e1238e9 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -19,7 +19,7 @@ use ast::{AttrId, Attribute, Name, Ident}; use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind}; use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind}; use codemap::{Spanned, respan, dummy_spanned}; -use syntax_pos::{Span, DUMMY_SP}; +use syntax_pos::Span; use errors::Handler; use feature_gate::{Features, GatedCfg}; use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; @@ -137,7 +137,7 @@ impl NestedMetaItem { /// Returns the name of the meta item, e.g. `foo` in `#[foo]`, /// `#[foo="bar"]` and `#[foo(bar)]`, if self is a MetaItem pub fn name(&self) -> Option<Name> { - self.meta_item().and_then(|meta_item| Some(meta_item.name())) + self.meta_item().and_then(|meta_item| Some(meta_item.ident.name)) } /// Gets the string value if self is a MetaItem and the MetaItem is a @@ -154,7 +154,7 @@ impl NestedMetaItem { if meta_item_list.len() == 1 { let nested_item = &meta_item_list[0]; if nested_item.is_literal() { - Some((meta_item.name(), nested_item.literal().unwrap())) + Some((meta_item.ident.name, nested_item.literal().unwrap())) } else { None } @@ -250,10 +250,6 @@ impl Attribute { } impl MetaItem { - pub fn name(&self) -> Name { - self.name - } - pub fn value_str(&self) -> Option<Symbol> { match self.node { MetaItemKind::NameValue(ref v) => { @@ -283,7 +279,7 @@ impl MetaItem { pub fn span(&self) -> Span { self.span } pub fn check_name(&self, name: &str) -> bool { - self.name() == name + self.ident.name == name } pub fn is_value_str(&self) -> bool { @@ -300,8 +296,8 @@ impl Attribute { pub fn meta(&self) -> Option<MetaItem> { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { - name: match self.path.segments.len() { - 1 => self.path.segments[0].ident.name, + ident: match self.path.segments.len() { + 1 => self.path.segments[0].ident, _ => return None, }, node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) { @@ -353,7 +349,7 @@ impl Attribute { } Ok(MetaItem { - name: self.path.segments.last().unwrap().ident.name, + ident: self.path.segments.last().unwrap().ident, node: self.parse(sess, |parser| parser.parse_meta_item_kind())?, span: self.span, }) @@ -368,8 +364,8 @@ impl Attribute { if self.is_sugared_doc { let comment = self.value_str().unwrap(); let meta = mk_name_value_item_str( - Symbol::intern("doc"), - Symbol::intern(&strip_doc_comment_decoration(&comment.as_str()))); + Ident::from_str("doc"), + dummy_spanned(Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())))); let mut attr = if self.style == ast::AttrStyle::Outer { mk_attr_outer(self.span, self.id, meta) } else { @@ -385,37 +381,24 @@ impl Attribute { /* Constructors */ -pub fn mk_name_value_item_str(name: Name, value: Symbol) -> MetaItem { - let value_lit = dummy_spanned(LitKind::Str(value, ast::StrStyle::Cooked)); - mk_spanned_name_value_item(DUMMY_SP, name, value_lit) +pub fn mk_name_value_item_str(ident: Ident, value: Spanned<Symbol>) -> MetaItem { + let value = respan(value.span, LitKind::Str(value.node, ast::StrStyle::Cooked)); + mk_name_value_item(ident.span.to(value.span), ident, value) } -pub fn mk_name_value_item(name: Name, value: ast::Lit) -> MetaItem { - mk_spanned_name_value_item(DUMMY_SP, name, value) +pub fn mk_name_value_item(span: Span, ident: Ident, value: ast::Lit) -> MetaItem { + MetaItem { ident, span, node: MetaItemKind::NameValue(value) } } -pub fn mk_list_item(name: Name, items: Vec<NestedMetaItem>) -> MetaItem { - mk_spanned_list_item(DUMMY_SP, name, items) +pub fn mk_list_item(span: Span, ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem { + MetaItem { ident, span, node: MetaItemKind::List(items) } } -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(ident: Ident) -> MetaItem { + MetaItem { ident, span: ident.span, node: MetaItemKind::Word } } - -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) -> MetaItem { - MetaItem { span: sp, name: name, node: MetaItemKind::NameValue(value) } -} - -pub fn mk_spanned_list_item(sp: Span, name: Name, items: Vec<NestedMetaItem>) -> MetaItem { - MetaItem { span: sp, name: name, node: MetaItemKind::List(items) } -} - -pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem { - MetaItem { span: sp, name: name, node: MetaItemKind::Word } +pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem { + respan(ident.span, NestedMetaItemKind::MetaItem(mk_word_item(ident))) } pub fn mk_attr_id() -> AttrId { @@ -436,11 +419,10 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute { /// Returns an inner attribute with the given value and span. pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute { - let ident = ast::Ident::with_empty_ctxt(item.name).with_span_pos(item.span); Attribute { id, style: ast::AttrStyle::Inner, - path: ast::Path::from_ident(ident), + path: ast::Path::from_ident(item.ident), tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -455,11 +437,10 @@ pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute { /// Returns an outer attribute with the given value and span. pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute { - let ident = ast::Ident::with_empty_ctxt(item.name).with_span_pos(item.span); Attribute { id, style: ast::AttrStyle::Outer, - path: ast::Path::from_ident(ident), + path: ast::Path::from_ident(item.ident), tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -472,7 +453,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute { Attribute { id, style, - path: ast::Path::from_ident(ast::Ident::from_str("doc").with_span_pos(span)), + path: ast::Path::from_ident(Ident::from_str("doc").with_span_pos(span)), tokens: MetaItemKind::NameValue(lit).tokens(span), is_sugared_doc: true, span, @@ -508,7 +489,7 @@ pub fn contains_feature_attr(attrs: &[Attribute], feature_name: &str) -> bool { item.check_name("feature") && item.meta_item_list().map(|list| { list.iter().any(|mi| { - mi.word().map(|w| w.name() == feature_name) + mi.word().map(|w| w.ident.name == feature_name) .unwrap_or(false) }) }).unwrap_or(false) @@ -581,7 +562,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat if let (Some(feats), Some(gated_cfg)) = (features, GatedCfg::gate(cfg)) { gated_cfg.check_and_emit(sess, feats); } - sess.config.contains(&(cfg.name(), cfg.value_str())) + sess.config.contains(&(cfg.ident.name, cfg.value_str())) }) } @@ -602,7 +583,7 @@ pub fn eval_condition<F>(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F) // The unwraps below may look dangerous, but we've already asserted // that they won't fail with the loop above. - match &*cfg.name.as_str() { + match &*cfg.ident.name.as_str() { "any" => mis.iter().any(|mi| { eval_condition(mi.meta_item().unwrap(), sess, eval) }), @@ -695,7 +676,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, let meta = meta.as_ref().unwrap(); let get = |meta: &MetaItem, item: &mut Option<Symbol>| { if item.is_some() { - handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.name())); + handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.ident.name)); return false } if let Some(v) = meta.value_str() { @@ -714,14 +695,14 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, )+ for meta in metas { if let Some(mi) = meta.meta_item() { - match &*mi.name().as_str() { + match &*mi.ident.name.as_str() { $( stringify!($name) => if !get(mi, &mut $name) { continue 'outer }, )+ _ => { handle_errors(diagnostic, mi.span, - AttrError::UnknownMetaItem(mi.name())); + AttrError::UnknownMetaItem(mi.ident.name)); continue 'outer } } @@ -733,7 +714,7 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, } } - match &*meta.name.as_str() { + match &*meta.ident.name.as_str() { "rustc_deprecated" => { if rustc_depr.is_some() { span_err!(diagnostic, item_sp, E0540, @@ -788,13 +769,13 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, let mut issue = None; for meta in metas { if let Some(mi) = meta.meta_item() { - match &*mi.name().as_str() { + match &*mi.ident.name.as_str() { "feature" => if !get(mi, &mut feature) { continue 'outer }, "reason" => if !get(mi, &mut reason) { continue 'outer }, "issue" => if !get(mi, &mut issue) { continue 'outer }, _ => { handle_errors(diagnostic, meta.span, - AttrError::UnknownMetaItem(mi.name())); + AttrError::UnknownMetaItem(mi.ident.name)); continue 'outer } } @@ -844,12 +825,12 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, let mut since = None; for meta in metas { if let NestedMetaItemKind::MetaItem(ref mi) = meta.node { - match &*mi.name().as_str() { + match &*mi.ident.name.as_str() { "feature" => if !get(mi, &mut feature) { continue 'outer }, "since" => if !get(mi, &mut since) { continue 'outer }, _ => { handle_errors(diagnostic, meta.span, - AttrError::UnknownMetaItem(mi.name())); + AttrError::UnknownMetaItem(mi.ident.name)); continue 'outer } } @@ -936,7 +917,7 @@ fn find_deprecation_generic<'a, I>(diagnostic: &Handler, depr = if let Some(metas) = attr.meta_item_list() { let get = |meta: &MetaItem, item: &mut Option<Symbol>| { if item.is_some() { - handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.name())); + handle_errors(diagnostic, meta.span, AttrError::MultipleItem(meta.ident.name)); return false } if let Some(v) = meta.value_str() { @@ -952,12 +933,12 @@ fn find_deprecation_generic<'a, I>(diagnostic: &Handler, let mut note = None; for meta in metas { if let NestedMetaItemKind::MetaItem(ref mi) = meta.node { - match &*mi.name().as_str() { + match &*mi.ident.name.as_str() { "since" => if !get(mi, &mut since) { continue 'outer }, "note" => if !get(mi, &mut note) { continue 'outer }, _ => { handle_errors(diagnostic, meta.span, - AttrError::UnknownMetaItem(mi.name())); + AttrError::UnknownMetaItem(mi.ident.name)); continue 'outer } } @@ -1009,7 +990,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> let mut recognised = false; if let Some(mi) = item.word() { - let word = &*mi.name().as_str(); + let word = &*mi.ident.name.as_str(); let hint = match word { "C" => Some(ReprC), "packed" => Some(ReprPacked), @@ -1108,18 +1089,17 @@ impl IntType { impl MetaItem { fn tokens(&self) -> TokenStream { - let ident = TokenTree::Token(self.span, - Token::from_ast_ident(Ident::with_empty_ctxt(self.name))); + let ident = TokenTree::Token(self.span, Token::from_ast_ident(self.ident)); TokenStream::concat(vec![ident.into(), self.node.tokens(self.span)]) } fn from_tokens<I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItem> where I: Iterator<Item = TokenTree>, { - let (span, name) = match tokens.next() { - Some(TokenTree::Token(span, Token::Ident(ident, _))) => (span, ident.name), + let (span, ident) = match tokens.next() { + Some(TokenTree::Token(span, Token::Ident(ident, _))) => (span, ident), Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 { - token::Nonterminal::NtIdent(ident, _) => (ident.span, ident.name), + token::Nonterminal::NtIdent(ident, _) => (ident.span, ident), token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), _ => return None, }, @@ -1132,7 +1112,7 @@ impl MetaItem { MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(span.hi()), _ => span.hi(), }; - Some(MetaItem { name, node, span: span.with_hi(hi) }) + Some(MetaItem { ident, node, span: span.with_hi(hi) }) } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 40d9d242ae6..062f3ce1127 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1129,21 +1129,22 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem { - attr::mk_spanned_word_item(sp, w) + attr::mk_word_item(Ident::with_empty_ctxt(w).with_span_pos(sp)) } fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem { - respan(sp, ast::NestedMetaItemKind::MetaItem(attr::mk_spanned_word_item(sp, w))) + attr::mk_nested_word_item(Ident::with_empty_ctxt(w).with_span_pos(sp)) } fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec<ast::NestedMetaItem>) -> ast::MetaItem { - attr::mk_spanned_list_item(sp, name, mis) + attr::mk_list_item(sp, Ident::with_empty_ctxt(name).with_span_pos(sp), mis) } fn meta_name_value(&self, sp: Span, name: ast::Name, value: ast::LitKind) -> ast::MetaItem { - attr::mk_spanned_name_value_item(sp, name, respan(sp, value)) + attr::mk_name_value_item(sp, Ident::with_empty_ctxt(name).with_span_pos(sp), + respan(sp, value)) } fn item_use(&self, sp: Span, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index bbfde736ef0..678c20402d6 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -733,7 +733,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc.expansion_data.mark.set_expn_info(expn_info); let span = span.with_ctxt(self.cx.backtrace()); let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this - name: keywords::Invalid.name(), + ident: keywords::Invalid.ident(), span: DUMMY_SP, node: ast::MetaItemKind::Word, }; @@ -1279,15 +1279,16 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { let include_info = vec![ dummy_spanned(ast::NestedMetaItemKind::MetaItem( - attr::mk_name_value_item_str("file".into(), - file))), + attr::mk_name_value_item_str(Ident::from_str("file"), + dummy_spanned(file)))), dummy_spanned(ast::NestedMetaItemKind::MetaItem( - attr::mk_name_value_item_str("contents".into(), - (&*src).into()))), + attr::mk_name_value_item_str(Ident::from_str("contents"), + dummy_spanned(Symbol::intern(&src))))), ]; - items.push(dummy_spanned(ast::NestedMetaItemKind::MetaItem( - attr::mk_list_item("include".into(), include_info)))); + let include_ident = Ident::from_str("include"); + let item = attr::mk_list_item(DUMMY_SP, include_ident, include_info); + items.push(dummy_spanned(ast::NestedMetaItemKind::MetaItem(item))); } Err(_) => { self.cx.span_err(at.span, @@ -1300,7 +1301,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { } } - let meta = attr::mk_list_item("doc".into(), items); + let meta = attr::mk_list_item(DUMMY_SP, Ident::from_str("doc"), items); match at.style { ast::AttrStyle::Inner => Some(attr::mk_spanned_attr_inner(at.span, at.id, meta)), diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index b55a268800f..24bfb5d9088 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1054,7 +1054,7 @@ pub struct GatedCfg { impl GatedCfg { pub fn gate(cfg: &ast::MetaItem) -> Option<GatedCfg> { - let name = cfg.name().as_str(); + let name = cfg.ident.name.as_str(); GATED_CFGS.iter() .position(|info| info.0 == name) .map(|idx| { @@ -1811,7 +1811,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], for mi in list { let name = if let Some(word) = mi.word() { - word.name() + word.ident.name } else { span_err!(span_handler, mi.span, E0556, "malformed feature, expected just one word"); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index e476a0c653e..ba6703b9c74 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -543,7 +543,7 @@ pub fn noop_fold_meta_list_item<T: Folder>(li: NestedMetaItem, fld: &mut T) pub fn noop_fold_meta_item<T: Folder>(mi: MetaItem, fld: &mut T) -> MetaItem { MetaItem { - name: mi.name, + ident: mi.ident, node: match mi.node { MetaItemKind::Word => MetaItemKind::Word, MetaItemKind::List(mis) => { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 6f0e382c047..90f08ab1468 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -149,8 +149,7 @@ impl<'a> Parser<'a> { }; Ok(if let Some(meta) = meta { self.bump(); - (ast::Path::from_ident(ast::Ident::with_empty_ctxt(meta.name).with_span_pos(meta.span)), - meta.node.tokens(meta.span)) + (ast::Path::from_ident(meta.ident), meta.node.tokens(meta.span)) } else { (self.parse_path(PathStyle::Mod)?, self.parse_tokens()) }) @@ -228,7 +227,7 @@ impl<'a> Parser<'a> { let lo = self.span; let ident = self.parse_ident()?; let node = self.parse_meta_item_kind()?; - Ok(ast::MetaItem { name: ident.name, node: node, span: lo.to(self.prev_span) }) + Ok(ast::MetaItem { ident, node: node, span: lo.to(self.prev_span) }) } pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 84c770605d5..e6da5bcaa3a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1957,7 +1957,7 @@ impl<'a> Parser<'a> { let meta_ident = match self.token { token::Interpolated(ref nt) => match nt.0 { token::NtMeta(ref meta) => match meta.node { - ast::MetaItemKind::Word => Some(ast::Ident::with_empty_ctxt(meta.name)), + ast::MetaItemKind::Word => Some(meta.ident), _ => None, }, _ => None, @@ -1966,7 +1966,7 @@ impl<'a> Parser<'a> { }; if let Some(ident) = meta_ident { self.bump(); - return Ok(ast::Path::from_ident(ident.with_span_pos(self.prev_span))); + return Ok(ast::Path::from_ident(ident)); } self.parse_path(style) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b233b145fdd..8d42206c5cc 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -26,7 +26,7 @@ use print::pp::{self, Breaks}; use print::pp::Breaks::{Consistent, Inconsistent}; use ptr::P; use std_inject; -use symbol::{Symbol, keywords}; +use symbol::keywords; use syntax_pos::{DUMMY_SP, FileName}; use tokenstream::{self, TokenStream, TokenTree}; @@ -101,13 +101,13 @@ pub fn print_crate<'a>(cm: &'a CodeMap, // of the feature gate, so we fake them up here. // #![feature(prelude_import)] - let prelude_import_meta = attr::mk_list_word_item(Symbol::intern("prelude_import")); - let list = attr::mk_list_item(Symbol::intern("feature"), vec![prelude_import_meta]); + let pi_nested = attr::mk_nested_word_item(ast::Ident::from_str("prelude_import")); + let list = attr::mk_list_item(DUMMY_SP, ast::Ident::from_str("feature"), vec![pi_nested]); let fake_attr = attr::mk_attr_inner(DUMMY_SP, attr::mk_attr_id(), list); s.print_attribute(&fake_attr)?; // #![no_std] - let no_std_meta = attr::mk_word_item(Symbol::intern("no_std")); + let no_std_meta = attr::mk_word_item(ast::Ident::from_str("no_std")); let fake_attr = attr::mk_attr_inner(DUMMY_SP, attr::mk_attr_id(), no_std_meta); s.print_attribute(&fake_attr)?; } @@ -768,15 +768,15 @@ pub trait PrintState<'a> { self.ibox(INDENT_UNIT)?; match item.node { ast::MetaItemKind::Word => { - self.writer().word(&item.name.as_str())?; + self.writer().word(&item.ident.name.as_str())?; } ast::MetaItemKind::NameValue(ref value) => { - self.word_space(&item.name.as_str())?; + self.word_space(&item.ident.name.as_str())?; self.word_space("=")?; self.print_literal(value)?; } ast::MetaItemKind::List(ref items) => { - self.writer().word(&item.name.as_str())?; + self.writer().word(&item.ident.name.as_str())?; self.popen()?; self.commasep(Consistent, &items[..], diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 8ef24713188..63d7b3336a8 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -57,7 +57,7 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<&str> krate.module.items.insert(0, P(ast::Item { attrs: vec![attr::mk_attr_outer(DUMMY_SP, attr::mk_attr_id(), - attr::mk_word_item(Symbol::intern("macro_use")))], + attr::mk_word_item(ast::Ident::from_str("macro_use")))], vis: dummy_spanned(ast::VisibilityKind::Inherited), node: ast::ItemKind::ExternCrate(alt_std_name.map(Symbol::intern)), ident: ast::Ident::from_str(name), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 308b53c1a38..fd2e760e9be 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -195,10 +195,10 @@ impl fold::Folder for EntryPointCleaner { EntryPointType::MainAttr | EntryPointType::Start => folded.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| { - let allow_str = Symbol::intern("allow"); - let dead_code_str = Symbol::intern("dead_code"); - let word_vec = vec![attr::mk_list_word_item(dead_code_str)]; - let allow_dead_code_item = attr::mk_list_item(allow_str, word_vec); + let allow_ident = Ident::from_str("allow"); + let dc_nested = attr::mk_nested_word_item(Ident::from_str("dead_code")); + let allow_dead_code_item = attr::mk_list_item(DUMMY_SP, allow_ident, + vec![dc_nested]); let allow_dead_code = attr::mk_attr_outer(DUMMY_SP, attr::mk_attr_id(), allow_dead_code_item); |
