From 121abd0599f6fd056dca84fe1df724fb7822b355 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 17 Apr 2018 15:33:39 +0200 Subject: [PATCH] make it compile again --- src/librustc/hir/check_attr.rs | 2 +- src/librustc/ich/impls_syntax.rs | 2 +- src/librustc/lint/levels.rs | 4 +- src/librustc/session/config.rs | 2 +- src/librustc/traits/on_unimplemented.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_incremental/assert_dep_graph.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustdoc/clean/cfg.rs | 10 +-- src/librustdoc/html/render.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/attr.rs | 83 +++++++------------ src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/feature_gate.rs | 32 +++++-- src/libsyntax/parse/attr.rs | 6 +- src/libsyntax/parse/parser.rs | 6 +- src/libsyntax/print/pprust.rs | 16 ++-- src/test/compile-fail/unknown-tool-name.rs | 4 +- .../compile-fail/unknown_tool_attributes-1.rs | 2 +- .../ui/feature-gate-tool_attributes.stderr | 3 +- 20 files changed, 92 insertions(+), 94 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index e8bdb9d5d5f..24a1256c9d3 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -308,7 +308,7 @@ fn check_expr_attributes(&self, expr: &hir::Expr) { fn check_used(&self, item: &hir::Item, target: Target) { for attr in &item.attrs { - if attr.name().map(|name| name == "used").unwrap_or(false) && target != Target::Static { + if attr.name() == "used" && target != Target::Static { self.tcx.sess .span_err(attr.span, "attribute must be applied to a `static` variable"); } diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index d90dba2ff04..1cf9b7bf478 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -216,7 +216,7 @@ fn hash_stable(&self, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); for segment in &self.segments { - segment.identifier.name.hash_stable(hcx, hasher); + segment.ident.name.hash_stable(hcx, hasher); } } } diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 0eeb0cf6c37..d158f52c643 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -221,7 +221,7 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush { continue } }; - let name = word.ident.name; + let name = word.name(); match store.check_lint_name(&name.as_str()) { CheckLintNameResult::Ok(ids) => { let src = LintSource::Node(name, li.span); @@ -260,7 +260,7 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush { Some(li.span.into()), &msg); if name.as_str().chars().any(|c| c.is_uppercase()) { - let name_lower = name.as_str().to_lowercase(); + let name_lower = name.as_str().to_lowercase().to_string(); if let CheckLintNameResult::NoLint = store.check_lint_name(&name_lower) { db.emit(); diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 59b40e9e2dc..dc97c941567 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1683,7 +1683,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec) -> ast::CrateConfig { early_error(ErrorOutputType::default(), &msg) } - (meta_item.ident.name, meta_item.value_str()) + (meta_item.name(), meta_item.value_str()) }) .collect::() } diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index d1fd70ae02d..3cf7af30b3d 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -190,7 +190,7 @@ pub fn evaluate(&self, for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| { - options.contains(&(c.ident.name.as_str().to_string(), + options.contains(&(c.name().as_str().to_string(), match c.value_str().map(|s| s.as_str().to_string()) { Some(s) => Some(s), None => None diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 67ba55a6aab..a1052ca6c3c 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1060,7 +1060,7 @@ fn print_crate_info(trans: &TransCrate, let mut cfgs = Vec::new(); for &(name, ref value) in sess.parse_sess.config.iter() { let gated_cfg = GatedCfg::gate(&ast::MetaItem { - name: ast::Path::from_ident(DUMMY_SP, name.to_ident()), + ident: ast::Path::from_ident(name.to_ident()), node: ast::MetaItemKind::Word, span: DUMMY_SP, }); diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 57311a7b588..38e891008f7 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -110,7 +110,7 @@ fn argument(&self, attr: &ast::Attribute) -> Option { for list_item in attr.meta_item_list().unwrap_or_default() { match list_item.word() { Some(word) if value.is_none() => - value = Some(word.ident.name), + value = Some(word.name()), _ => // FIXME better-encapsulate meta_item (don't directly access `node`) span_bug!(list_item.span(), "unexpected meta-item {:?}", list_item.node), diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index e5e6c22c7a2..4522a0b8624 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -702,7 +702,7 @@ fn legacy_macro_imports(&mut self, attrs: &[ast::Attribute]) -> LegacyMacroImpor match attr.meta_item_list() { Some(names) => for attr in names { if let Some(word) = attr.word() { - imports.imports.push((word.ident.name, attr.span())); + imports.imports.push((word.name(), attr.span())); } else { span_err!(self.session, attr.span(), E0466, "bad macro import"); } diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index f8cd6ebc464..d5e0f95ddf4 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -438,7 +438,7 @@ fn name_value_cfg(name: &str, value: &str) -> Cfg { fn dummy_meta_item_word(name: &str) -> MetaItem { MetaItem { - name: Path::from_ident(DUMMY_SP, Ident::from_str(name)), + ident: Path::from_ident(Ident::from_str(name)), node: MetaItemKind::Word, span: DUMMY_SP, } @@ -447,7 +447,7 @@ fn dummy_meta_item_word(name: &str) -> MetaItem { macro_rules! dummy_meta_item_list { ($name:ident, [$($list:ident),* $(,)*]) => { MetaItem { - name: Path::from_ident(DUMMY_SP, Ident::from_str(stringify!($name))), + ident: Path::from_ident(Ident::from_str(stringify!($name))), node: MetaItemKind::List(vec![ $( dummy_spanned(NestedMetaItemKind::MetaItem( @@ -461,7 +461,7 @@ macro_rules! dummy_meta_item_list { ($name:ident, [$($list:expr),* $(,)*]) => { MetaItem { - name: Path::from_ident(DUMMY_SP, Ident::from_str(stringify!($name))), + ident: Path::from_ident(Ident::from_str(stringify!($name))), node: MetaItemKind::List(vec![ $( dummy_spanned(NestedMetaItemKind::MetaItem($list)), @@ -601,7 +601,7 @@ fn test_parse_ok() { assert_eq!(Cfg::parse(&mi), Ok(word_cfg("all"))); let mi = MetaItem { - name: Path::from_ident(DUMMY_SP, Ident::from_str("all")), + ident: Path::from_ident(Ident::from_str("all")), node: MetaItemKind::NameValue(dummy_spanned(LitKind::Str( Symbol::intern("done"), StrStyle::Cooked, @@ -636,7 +636,7 @@ fn test_parse_ok() { fn test_parse_err() { with_globals(|| { let mi = MetaItem { - name: Path::from_ident(DUMMY_SP, Ident::from_str("foo")), + ident: Path::from_ident(Ident::from_str("foo")), node: MetaItemKind::NameValue(dummy_spanned(LitKind::Bool(false))), span: DUMMY_SP, }; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9248210c269..e9520573f8b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3284,7 +3284,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, } fn render_attribute(attr: &ast::MetaItem) -> Option { - let name = attr.ident.name; + let name = attr.name(); if attr.is_word() { Some(format!("{}", name)) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index bc457f49fcf..f8cd6103bdf 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -477,7 +477,7 @@ pub enum NestedMetaItemKind { /// E.g. `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]` #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct MetaItem { - pub name: Path, + pub ident: Path, pub node: MetaItemKind, pub span: Span, } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 8fa5f55490e..82e04ff32ca 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -18,7 +18,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 codemap::{BytePos, Spanned, respan, dummy_spanned}; use syntax_pos::Span; use errors::Handler; use feature_gate::{Features, GatedCfg}; @@ -111,7 +111,7 @@ pub fn is_known(attr: &Attribute) -> bool { pub fn is_known_tool(attr: &Attribute) -> bool { let tool_name = - attr.path.segments.iter().next().expect("empty path in attribute").identifier.name; + attr.path.segments.iter().next().expect("empty path in attribute").ident.name; RUST_KNOWN_TOOL.contains(&tool_name.as_str().as_ref()) } @@ -213,7 +213,7 @@ pub fn is_meta_item_list(&self) -> bool { } fn name_from_path(path: &ast::Path) -> Name { - path.segments.last().expect("empty path in attribute").identifier.name + path.segments.last().expect("empty path in attribute").ident.name } impl Attribute { @@ -266,7 +266,7 @@ pub fn is_scoped(&self) -> bool { impl MetaItem { pub fn name(&self) -> Name { - name_from_path(&self.name) + name_from_path(&self.ident) } pub fn value_str(&self) -> Option { @@ -315,7 +315,7 @@ impl Attribute { pub fn meta(&self) -> Option { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { - name: self.path.clone(), + ident: self.path.clone(), node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) { if tokens.peek().is_some() { return None; @@ -361,7 +361,7 @@ pub fn parse_list<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> { Ok(MetaItem { - name: self.path.clone(), + ident: self.path.clone(), node: self.parse(sess, |parser| parser.parse_meta_item_kind())?, span: self.span, }) @@ -399,41 +399,19 @@ pub fn mk_name_value_item_str(ident: Ident, value: Spanned) -> MetaItem } pub fn mk_name_value_item(span: Span, ident: Ident, value: ast::Lit) -> MetaItem { - MetaItem { ident, span, node: MetaItemKind::NameValue(value) } + MetaItem { ident: ast::Path::from_ident(ident), span, node: MetaItemKind::NameValue(value) } } pub fn mk_list_item(span: Span, ident: Ident, items: Vec) -> MetaItem { - MetaItem { ident, span, node: MetaItemKind::List(items) } + MetaItem { ident: ast::Path::from_ident(ident), span, node: MetaItemKind::List(items) } } pub fn mk_word_item(ident: Ident) -> MetaItem { - MetaItem { ident, span: ident.span, node: MetaItemKind::Word } + MetaItem { ident: ast::Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word } } -pub fn mk_word_item(name: Name) -> MetaItem { - mk_spanned_word_item(DUMMY_SP, name) -} - -macro_rules! mk_spanned_meta_item { - ($sp:ident, $name:ident, $node:expr) => { - MetaItem { - span: $sp, - name: ast::Path::from_ident($sp, ast::Ident::with_empty_ctxt($name)), - node: $node, - } - } -} - -pub fn mk_spanned_name_value_item(sp: Span, name: Name, value: ast::Lit) -> MetaItem { - mk_spanned_meta_item!(sp, name, MetaItemKind::NameValue(value)) -} - -pub fn mk_spanned_list_item(sp: Span, name: Name, items: Vec) -> MetaItem { - mk_spanned_meta_item!(sp, name, MetaItemKind::List(items)) -} - -pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem { - mk_spanned_meta_item!(sp, name, 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 { @@ -457,7 +435,7 @@ pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute Attribute { id, style: ast::AttrStyle::Inner, - path: item.name, + path: item.ident, tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -475,7 +453,7 @@ pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute Attribute { id, style: ast::AttrStyle::Outer, - path: item.name, + path: item.ident, tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -1082,7 +1060,7 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec } } else { if let Some(meta_item) = item.meta_item() { - if meta_item.ident.name == "align" { + if meta_item.name() == "align" { if let MetaItemKind::NameValue(ref value) = meta_item.node { recognised = true; let mut err = struct_span_err!(diagnostic, item.span, E0693, @@ -1165,14 +1143,17 @@ fn tokens(&self) -> TokenStream { let mut idents = vec![]; let mut last_pos = BytePos(0 as u32); // FIXME: Share code with `parse_path`. - for (i, segment) in self.name.segments.iter().enumerate() { + for (i, segment) in self.ident.segments.iter().enumerate() { let is_first = i == 0; if !is_first { - let mod_sep_span = Span::new(last_pos, segment.span.lo(), segment.span.ctxt()); + let mod_sep_span = Span::new(last_pos, + segment.ident.span.lo(), + segment.ident.span.ctxt()); idents.push(TokenTree::Token(mod_sep_span, Token::ModSep).into()); } - idents.push(TokenTree::Token(segment.span, Token::Ident(segment.identifier)).into()); - last_pos = segment.span.hi(); + idents.push(TokenTree::Token(segment.ident.span, + Token::from_ast_ident(segment.ident)).into()); + last_pos = segment.ident.span.hi(); } idents.push(self.node.tokens(self.span)); TokenStream::concat(idents) @@ -1181,14 +1162,14 @@ fn tokens(&self) -> TokenStream { fn from_tokens(tokens: &mut iter::Peekable) -> Option where I: Iterator, { - let name = match tokens.next() { - Some(TokenTree::Token(span, Token::Ident(ident))) => { + let ident = match tokens.next() { + Some(TokenTree::Token(span, Token::Ident(ident, _))) => { if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() { tokens.next(); let mut segments = vec![]; loop { - if let Some(TokenTree::Token(span, Token::Ident(ident))) = tokens.next() { - segments.push(ast::PathSegment::from_ident(ident, span)); + if let Some(TokenTree::Token(_, Token::Ident(ident, _))) = tokens.next() { + segments.push(ast::PathSegment::from_ident(ident)); } else { return None; } @@ -1200,12 +1181,12 @@ fn from_tokens(tokens: &mut iter::Peekable) -> Option } ast::Path { span, segments } } else { - ast::Path::from_ident(span, ident) + ast::Path::from_ident(ident) } } Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 { - token::Nonterminal::NtIdent(ident) => { - ast::Path::from_ident(ident.span, ident.node) + token::Nonterminal::NtIdent(ident, _) => { + ast::Path::from_ident(ident) } token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), token::Nonterminal::NtPath(ref path) => path.clone(), @@ -1217,11 +1198,11 @@ fn from_tokens(tokens: &mut iter::Peekable) -> Option let node = MetaItemKind::from_tokens(tokens)?; let hi = match node { MetaItemKind::NameValue(ref lit) => lit.span.hi(), - MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(name.span.hi()), - _ => name.span.hi(), + MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(ident.span.hi()), + _ => ident.span.hi(), }; - let span = name.span.with_hi(hi); - Some(MetaItem { name, node, span }) + let span = ident.span.with_hi(hi); + Some(MetaItem { ident, node, span }) } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 41cd9c595d2..584b9455a93 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -810,7 +810,7 @@ fn expand_derive_invoc(&mut self, 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: Path::from_ident(DUMMY_SP, keywords::Invalid.ident()), + ident: Path::from_ident(keywords::Invalid.ident()), span: DUMMY_SP, node: ast::MetaItemKind::Word, }; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4405c1a2658..18bf5445123 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -462,7 +462,7 @@ pub fn walk_feature_fields(&self, mut f: F) (active, extern_prelude, "1.27.0", Some(44660), Some(Edition::Edition2018)), // Scoped attributes - (active, tool_attributes, "1.25.0", Some(44690)), + (active, tool_attributes, "1.25.0", Some(44690), None), ); declare_features! ( @@ -1175,12 +1175,28 @@ fn check_attribute(&self, attr: &ast::Attribute, is_macro: bool) { // before the plugin attributes are registered // so we skip this then if !is_macro { - gate_feature!(self, custom_attribute, attr.span, - &format!("The attribute `{}` is currently \ - unknown to the compiler and \ - may have meaning \ - added to it in the future", - attr.path)); + if attr.is_scoped() { + gate_feature!(self, tool_attributes, attr.span, + &format!("scoped attribute `{}` is experimental", attr.path)); + if attr::is_known_tool(attr) { + attr::mark_used(attr); + } else { + span_err!( + self.parse_sess.span_diagnostic, + attr.span, + E0694, + "an unknown tool name found in scoped attribute: `{}`.", + attr.path + ); + } + } else { + gate_feature!(self, custom_attribute, attr.span, + &format!("the attribute `{}` is currently \ + unknown to the compiler and \ + may have meaning \ + added to it in the future", + attr.path)); + } } } } @@ -1846,7 +1862,7 @@ fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) { for mi in list { let name = if let Some(word) = mi.word() { - word.ident.name + word.name() } else { span_err!(span_handler, mi.span, E0556, "malformed feature, expected just one word"); diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 0671f29648f..cceed589212 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -149,7 +149,7 @@ pub fn parse_path_and_tokens(&mut self) -> PResult<'a, (ast::Path, TokenStream)> }; Ok(if let Some(meta) = meta { self.bump(); - (meta.name, meta.node.tokens(meta.span)) + (meta.ident, meta.node.tokens(meta.span)) } else { (self.parse_path(PathStyle::Mod)?, self.parse_tokens()) }) @@ -225,10 +225,10 @@ pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> { } let lo = self.span; - let name = self.parse_path(PathStyle::Mod)?; + let ident = self.parse_path(PathStyle::Mod)?; let node = self.parse_meta_item_kind()?; let span = lo.to(self.prev_span); - Ok(ast::MetaItem { name, node, span }) + Ok(ast::MetaItem { ident, node, 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 d8fd3870495..0e3bced3222 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1955,17 +1955,17 @@ pub fn parse_path_common(&mut self, style: PathStyle, enable_warning: bool) /// Like `parse_path`, but also supports parsing `Word` meta items into paths for back-compat. /// This is used when parsing derive macro paths in `#[derive]` attributes. pub fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, ast::Path> { - let meta_name = match self.token { + let meta_ident = match self.token { token::Interpolated(ref nt) => match nt.0 { token::NtMeta(ref meta) => match meta.node { - ast::MetaItemKind::Word => Some(meta.name.clone()), + ast::MetaItemKind::Word => Some(meta.ident.clone()), _ => None, }, _ => None, }, _ => None, }; - if let Some(path) = meta_name { + if let Some(path) = meta_ident { self.bump(); return Ok(path); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 96f7caf165c..f78e3f3084b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -719,12 +719,12 @@ fn print_attribute_path(&mut self, path: &ast::Path) -> io::Result<()> { if i > 0 { self.writer().word("::")? } - if segment.identifier.name != keywords::CrateRoot.name() && - segment.identifier.name != keywords::DollarCrate.name() + if segment.ident.name != keywords::CrateRoot.name() && + segment.ident.name != keywords::DollarCrate.name() { - self.writer().word(&segment.identifier.name.as_str())?; - } else if segment.identifier.name == keywords::DollarCrate.name() { - self.print_dollar_crate(segment.identifier.ctxt)?; + self.writer().word(&segment.ident.name.as_str())?; + } else if segment.ident.name == keywords::DollarCrate.name() { + self.print_dollar_crate(segment.ident.span.ctxt())?; } } Ok(()) @@ -773,15 +773,15 @@ fn print_meta_list_item(&mut self, item: &ast::NestedMetaItem) -> io::Result<()> fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> { self.ibox(INDENT_UNIT)?; match item.node { - ast::MetaItemKind::Word => self.print_attribute_path(&item.name)?, + ast::MetaItemKind::Word => self.print_attribute_path(&item.ident)?, ast::MetaItemKind::NameValue(ref value) => { - self.print_attribute_path(&item.name)?; + self.print_attribute_path(&item.ident)?; self.writer().space()?; self.word_space("=")?; self.print_literal(value)?; } ast::MetaItemKind::List(ref items) => { - self.print_attribute_path(&item.name)?; + self.print_attribute_path(&item.ident)?; self.popen()?; self.commasep(Consistent, &items[..], diff --git a/src/test/compile-fail/unknown-tool-name.rs b/src/test/compile-fail/unknown-tool-name.rs index 0cb897917b4..c2192a21d90 100644 --- a/src/test/compile-fail/unknown-tool-name.rs +++ b/src/test/compile-fail/unknown-tool-name.rs @@ -10,7 +10,7 @@ #![feature(tool_attributes)] -#![foo::bar] //~ ERROR An unknown tool name found in scoped attributes: `foo::bar`. [E0693] +#![foo::bar] //~ ERROR an unknown tool name found in scoped attribute: `foo::bar`. [E0694] -#[foo::bar] //~ ERROR An unknown tool name found in scoped attributes: `foo::bar`. [E0693] +#[foo::bar] //~ ERROR an unknown tool name found in scoped attribute: `foo::bar`. [E0694] fn main() {} diff --git a/src/test/compile-fail/unknown_tool_attributes-1.rs b/src/test/compile-fail/unknown_tool_attributes-1.rs index fbc46219461..ba38c297a11 100644 --- a/src/test/compile-fail/unknown_tool_attributes-1.rs +++ b/src/test/compile-fail/unknown_tool_attributes-1.rs @@ -14,5 +14,5 @@ #[foo::bar] //~^ ERROR scoped attribute `foo::bar` is experimental (see issue #44690) [E0658] -//~^^ ERROR An unknown tool name found in scoped attributes: `foo::bar`. [E0693] +//~^^ ERROR an unknown tool name found in scoped attribute: `foo::bar`. [E0694] fn main() {} diff --git a/src/test/ui/feature-gate-tool_attributes.stderr b/src/test/ui/feature-gate-tool_attributes.stderr index 13307bd7133..da89c4a5ef6 100644 --- a/src/test/ui/feature-gate-tool_attributes.stderr +++ b/src/test/ui/feature-gate-tool_attributes.stderr @@ -1,10 +1,11 @@ error[E0658]: scoped attribute `rustfmt::skip` is experimental (see issue #44690) --> $DIR/feature-gate-tool_attributes.rs:12:5 | -12 | #[rustfmt::skip] //~ ERROR scoped attribute `rustfmt::skip` is experimental +LL | #[rustfmt::skip] //~ ERROR scoped attribute `rustfmt::skip` is experimental | ^^^^^^^^^^^^^^^^ | = help: add #![feature(tool_attributes)] to the crate attributes to enable error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. -- 2.44.0