diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4be467c01aac1..db69c5c4c8fc8 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -221,13 +221,13 @@ impl<'a> HashStable> for [ast::Attribute] { } } -impl<'a> HashStable> for ast::Path { +impl<'a> HashStable> for ast::MetaPath { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); - for segment in &self.segments { - segment.ident.name.hash_stable(hcx, hasher); + for ident in &self.segments { + ident.name.hash_stable(hcx, hasher); } } } @@ -380,7 +380,7 @@ impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItemKind { }); impl_stable_hash_for!(struct ::syntax::ast::MetaItem { - ident, + path, node, span }); diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index cfb9f04c4c6d1..15d5bed9c5a35 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -233,7 +233,7 @@ impl<'a> LintLevelsBuilder<'a> { ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::NameValue(ref name_value) => { let gate_reasons = !self.sess.features_untracked().lint_reasons; - if item.ident == "reason" { + if item.path == "reason" { // found reason, reslice meta list to exclude it metas = &metas[0..metas.len()-1]; // FIXME (#55112): issue unused-attributes lint if we thereby @@ -274,7 +274,7 @@ impl<'a> LintLevelsBuilder<'a> { let mut err = bad_attr(li.span); if let Some(item) = li.meta_item() { if let ast::MetaItemKind::NameValue(_) = item.node { - if item.ident == "reason" { + if item.path == "reason" { err.help("reason in lint attribute must come last"); } } @@ -290,7 +290,7 @@ impl<'a> LintLevelsBuilder<'a> { lint_tool.span, E0710, "an unknown tool name found in scoped lint: `{}`", - word.ident + word.path ); continue; } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 480d4a8e48f0e..7d8d0165fa799 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1766,7 +1766,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec) -> ast::CrateConfig { match &mut parser.parse_meta_item() { Ok(meta_item) if parser.token == token::Eof => { - if meta_item.ident.segments.len() != 1 { + if meta_item.path.segments.len() != 1 { error!("argument key must be an identifier"); } match &meta_item.node { diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index b063176d3cafa..4527c78b31ee7 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1071,7 +1071,7 @@ impl RustcDefaultCalls { let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| { let gated_cfg = GatedCfg::gate(&ast::MetaItem { - ident: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)), + path: ast::MetaPath::from_ident(ast::Ident::with_empty_ctxt(name)), node: ast::MetaItemKind::Word, span: DUMMY_SP, }); diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index c19145636e6da..0d21189e242f2 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -151,7 +151,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitD } else { sess.span_err( item.span, - &format!("{} attribute requires a path", item.ident)); + &format!("{} attribute requires a path", item.path)); return None; } } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 0fa41cb484fc9..7dd5ba2b63a13 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -1021,7 +1021,7 @@ impl<'a, 'b, 'cl> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b, 'cl> { derives: Vec::new(), }; parent_scope.module.builtin_attrs.borrow_mut().push(( - attr.path.segments[0].ident, parent_scope + attr.path.segments[0], parent_scope )); } visit::walk_attribute(self, attr); diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 5db3efee9f6a1..862f402f23ba8 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -299,7 +299,7 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { }).into(); } return Some(ast::Attribute { - path: ast::Path::from_ident(Ident::new(legacy_name, span)), + path: ast::MetaPath::from_ident(Ident::new(legacy_name, span)), tokens: TokenStream::empty(), id: attr::mk_attr_id(), style: ast::AttrStyle::Outer, @@ -315,11 +315,14 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: Mark, force: bool) -> Result>, Determinacy> { + let path; let (path, kind, derives_in_scope, after_derive) = match invoc.kind { InvocationKind::Attr { attr: None, .. } => return Ok(None), - InvocationKind::Attr { attr: Some(ref attr), ref traits, after_derive, .. } => - (&attr.path, MacroKind::Attr, traits.clone(), after_derive), + InvocationKind::Attr { attr: Some(ref attr), ref traits, after_derive, .. } => { + path = attr.path.to_regular_path(); + (&path, MacroKind::Attr, traits.clone(), after_derive) + } InvocationKind::Bang { ref mac, .. } => (&mac.node.path, MacroKind::Bang, Vec::new(), false), InvocationKind::Derive { ref path, .. } => diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 227017a9073fe..7052e49050652 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -63,6 +63,66 @@ impl fmt::Debug for Lifetime { } } +/// Simpler version of `Path` for `Attribute` and `MetaItem`. +#[derive(Clone, RustcEncodable, RustcDecodable)] +pub struct MetaPath { + pub span: Span, + pub segments: Vec, +} + +impl<'a> PartialEq<&'a str> for MetaPath { + fn eq(&self, string: &&'a str) -> bool { + self.segments.len() == 1 && self.segments[0].name == *string + } +} + +impl fmt::Debug for MetaPath { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "path({})", pprust::meta_path_to_string(self)) + } +} + +impl fmt::Display for MetaPath { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", pprust::meta_path_to_string(self)) + } +} + +impl MetaPath { + // convert a span and an identifier to the corresponding + // 1-segment path + pub fn from_ident(ident: Ident) -> MetaPath { + MetaPath { + span: ident.span, + segments: vec![ident], + } + } + + /// Try to convert a `Path` into a `MetaPath`, returning `None` + /// if any of the path's segments had any generic arguments. + pub fn from_regular_path(path: &Path) -> Option { + Some(MetaPath { + span: path.span, + segments: path.segments.iter().map(|segment| { + if segment.args.is_none() { + Some(segment.ident) + } else { + None + } + }).collect::>()?, + }) + } + + pub fn to_regular_path(&self) -> Path { + Path { + span: self.span, + segments: self.segments.iter().map(|&ident| { + PathSegment::from_ident(ident) + }).collect(), + } + } +} + /// A "Path" is essentially Rust's notion of a name. /// /// It's represented as a sequence of identifiers, @@ -430,7 +490,7 @@ pub enum NestedMetaItemKind { /// E.g. `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]` #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct MetaItem { - pub ident: Path, + pub path: MetaPath, pub node: MetaItemKind, pub span: Span, } @@ -1988,7 +2048,7 @@ impl Idx for AttrId { pub struct Attribute { pub id: AttrId, pub style: AttrStyle, - pub path: Path, + pub path: MetaPath, pub tokens: TokenStream, pub is_sugared_doc: bool, pub span: Span, diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index 1bbc1accc07d6..2d43024b47842 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -499,8 +499,8 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat gated_cfg.check_and_emit(sess, feats); } let error = |span, msg| { sess.span_diagnostic.span_err(span, msg); true }; - if cfg.ident.segments.len() != 1 { - return error(cfg.ident.span, "`cfg` predicate key must be an identifier"); + if cfg.path.segments.len() != 1 { + return error(cfg.path.span, "`cfg` predicate key must be an identifier"); } match &cfg.node { MetaItemKind::List(..) => { diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 6487665947729..513158f920584 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -22,7 +22,7 @@ pub use self::ReprAttr::*; pub use self::StabilityLevel::*; use ast; -use ast::{AttrId, Attribute, AttrStyle, Name, Ident, Path, PathSegment}; +use ast::{AttrId, Attribute, AttrStyle, Name, Ident, MetaPath}; use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind}; use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind, GenericParam}; use source_map::{BytePos, Spanned, respan, dummy_spanned}; @@ -166,8 +166,8 @@ impl NestedMetaItem { } } -fn name_from_path(path: &Path) -> Name { - path.segments.last().expect("empty path in attribute").ident.name +fn name_from_path(path: &MetaPath) -> Name { + path.segments.last().expect("empty path in attribute").name } impl Attribute { @@ -216,7 +216,7 @@ impl Attribute { impl MetaItem { pub fn name(&self) -> Name { - name_from_path(&self.ident) + name_from_path(&self.path) } // #[attribute(name = "value")] @@ -269,8 +269,8 @@ impl MetaItem { } pub fn is_scoped(&self) -> Option { - if self.ident.segments.len() > 1 { - Some(self.ident.segments[0].ident) + if self.path.segments.len() > 1 { + Some(self.path.segments[0]) } else { None } @@ -282,7 +282,7 @@ impl Attribute { pub fn meta(&self) -> Option { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { - ident: self.path.clone(), + path: self.path.clone(), node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) { if tokens.peek().is_some() { return None; @@ -328,7 +328,7 @@ impl Attribute { pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> { Ok(MetaItem { - ident: self.path.clone(), + path: self.path.clone(), node: self.parse(sess, |parser| parser.parse_meta_item_kind())?, span: self.span, }) @@ -366,15 +366,15 @@ 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: Path::from_ident(ident), span, node: MetaItemKind::NameValue(value) } + MetaItem { path: MetaPath::from_ident(ident), span, node: MetaItemKind::NameValue(value) } } pub fn mk_list_item(span: Span, ident: Ident, items: Vec) -> MetaItem { - MetaItem { ident: Path::from_ident(ident), span, node: MetaItemKind::List(items) } + MetaItem { path: MetaPath::from_ident(ident), span, node: MetaItemKind::List(items) } } pub fn mk_word_item(ident: Ident) -> MetaItem { - MetaItem { ident: Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word } + MetaItem { path: MetaPath::from_ident(ident), span: ident.span, node: MetaItemKind::Word } } pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem { @@ -402,7 +402,7 @@ pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute Attribute { id, style: ast::AttrStyle::Inner, - path: item.ident, + path: item.path, tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -419,7 +419,7 @@ pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute Attribute { id, style: ast::AttrStyle::Outer, - path: item.ident, + path: item.path, tokens: item.node.tokens(item.span), is_sugared_doc: false, span: sp, @@ -432,7 +432,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute { Attribute { id, style, - path: Path::from_ident(Ident::from_str("doc").with_span_pos(span)), + path: MetaPath::from_ident(Ident::from_str("doc").with_span_pos(span)), tokens: MetaItemKind::NameValue(lit).tokens(span), is_sugared_doc: true, span, @@ -470,17 +470,17 @@ impl MetaItem { fn tokens(&self) -> TokenStream { let mut idents = vec![]; let mut last_pos = BytePos(0 as u32); - for (i, segment) in self.ident.segments.iter().enumerate() { + for (i, &ident) in self.path.segments.iter().enumerate() { let is_first = i == 0; if !is_first { let mod_sep_span = Span::new(last_pos, - segment.ident.span.lo(), - segment.ident.span.ctxt()); + ident.span.lo(), + ident.span.ctxt()); idents.push(TokenTree::Token(mod_sep_span, Token::ModSep).into()); } - idents.push(TokenTree::Token(segment.ident.span, - Token::from_ast_ident(segment.ident)).into()); - last_pos = segment.ident.span.hi(); + idents.push(TokenTree::Token(ident.span, + Token::from_ast_ident(ident)).into()); + last_pos = ident.span.hi(); } idents.push(self.node.tokens(self.span)); TokenStream::concat(idents) @@ -490,15 +490,15 @@ impl MetaItem { where I: Iterator, { // FIXME: Share code with `parse_path`. - let ident = match tokens.next() { + let path = match tokens.next() { Some(TokenTree::Token(span, Token::Ident(ident, _))) => { if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() { - let mut segments = vec![PathSegment::from_ident(ident.with_span_pos(span))]; + let mut segments = vec![ident.with_span_pos(span)]; tokens.next(); loop { if let Some(TokenTree::Token(span, Token::Ident(ident, _))) = tokens.next() { - segments.push(PathSegment::from_ident(ident.with_span_pos(span))); + segments.push(ident.with_span_pos(span)); } else { return None; } @@ -508,16 +508,18 @@ impl MetaItem { break; } } - let span = span.with_hi(segments.last().unwrap().ident.span.hi()); - Path { span, segments } + let span = span.with_hi(segments.last().unwrap().span.hi()); + MetaPath { span, segments } } else { - Path::from_ident(ident.with_span_pos(span)) + MetaPath::from_ident(ident.with_span_pos(span)) } } Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 { - token::Nonterminal::NtIdent(ident, _) => Path::from_ident(ident), + token::Nonterminal::NtIdent(ident, _) => MetaPath::from_ident(ident), token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), - token::Nonterminal::NtPath(ref path) => path.clone(), + token::Nonterminal::NtPath(ref path) => { + ast::MetaPath::from_regular_path(path)? + } _ => return None, }, _ => return None, @@ -526,11 +528,11 @@ impl MetaItem { 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(ident.span.hi()), - _ => ident.span.hi(), + MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(path.span.hi()), + _ => path.span.hi(), }; - let span = ident.span.with_hi(hi); - Some(MetaItem { ident, node, span }) + let span = path.span.with_hi(hi); + Some(MetaItem { path, node, span }) } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index bb927b62a181e..9afa9e1f7f719 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -10,7 +10,7 @@ pub use self::SyntaxExtension::*; -use ast::{self, Attribute, Name, PatKind, MetaItem}; +use ast::{self, Attribute, Name, PatKind}; use attr::HasAttrs; use source_map::{self, SourceMap, Spanned, respan}; use syntax_pos::{Span, MultiSpan, DUMMY_SP}; @@ -571,7 +571,7 @@ impl MacResult for DummyResult { } pub type BuiltinDeriveFn = - for<'cx> fn(&'cx mut ExtCtxt, Span, &MetaItem, &Annotatable, &mut dyn FnMut(Annotatable)); + for<'cx> fn(&'cx mut ExtCtxt, Span, &Annotatable, &mut dyn FnMut(Annotatable)); /// Represents different kinds of macro invocations that can be resolved. #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 68a96293891a0..9992b3b5b9b84 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -601,7 +601,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let input = self.extract_proc_macro_attr_input(attr.tokens, attr.span); let tok_result = mac.expand(self.cx, attr.span, input, item_tok); let res = self.parse_ast_fragment(tok_result, invoc.fragment_kind, - &attr.path, attr.span); + &attr.path.to_regular_path(), attr.span); self.gate_proc_macro_expansion(attr.span, &res); res } @@ -912,12 +912,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let pretty_name = Symbol::intern(&format!("derive({})", path)); let span = path.span; - let attr = ast::Attribute { - path, span, - tokens: TokenStream::empty(), - // irrelevant: - id: ast::AttrId(0), style: ast::AttrStyle::Outer, is_sugared_doc: false, - }; let mut expn_info = ExpnInfo { call_site: span, @@ -934,7 +928,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 - ident: Path::from_ident(keywords::Invalid.ident()), + path: ast::MetaPath::from_ident(keywords::Invalid.ident()), span: DUMMY_SP, node: ast::MetaItemKind::Word, }; @@ -946,11 +940,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc.expansion_data.mark.set_expn_info(expn_info); let span = span.with_ctxt(self.cx.backtrace()); let mut items = Vec::new(); - func(self.cx, span, &attr.meta()?, &item, &mut |a| items.push(a)); + func(self.cx, span, &item, &mut |a| items.push(a)); Some(invoc.fragment_kind.expect_from_annotatables(items)) } _ => { - let msg = &format!("macro `{}` may not be used for derive attributes", attr.path); + let msg = &format!("macro `{}` may not be used for derive attributes", path); self.cx.span_err(span, msg); self.cx.trace_macros_diag(); invoc.fragment_kind.dummy(span) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index c6e0adbb5a43e..c1d92a95ddcae 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -235,12 +235,12 @@ pub mod rt { r.push(TokenTree::Token(self.span, token::Not)); } let mut inner = Vec::new(); - for (i, segment) in self.path.segments.iter().enumerate() { + for (i, &ident) in self.path.segments.iter().enumerate() { if i > 0 { inner.push(TokenTree::Token(self.span, token::Colon).into()); } inner.push(TokenTree::Token( - self.span, token::Token::from_ast_ident(segment.ident) + self.span, token::Token::from_ast_ident(ident) ).into()); } inner.push(self.tokens.clone()); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 0e6e2f90693cf..8a4b96d6dac29 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -541,7 +541,7 @@ pub fn noop_fold_attribute(attr: Attribute, fld: &mut T) -> Option(li: NestedMetaItem, fld: &mut T) pub fn noop_fold_meta_item(mi: MetaItem, fld: &mut T) -> MetaItem { MetaItem { - ident: mi.ident, + path: mi.path.clone(), 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 a240604bfe0ad..6489b7598b3f4 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -147,7 +147,7 @@ impl<'a> Parser<'a> { /// PATH /// PATH `=` TOKEN_TREE /// The delimiters or `=` are still put into the resulting token stream. - crate fn parse_meta_item_unrestricted(&mut self) -> PResult<'a, (ast::Path, TokenStream)> { + crate fn parse_meta_item_unrestricted(&mut self) -> PResult<'a, (ast::MetaPath, TokenStream)> { let meta = match self.token { token::Interpolated(ref nt) => match nt.0 { Nonterminal::NtMeta(ref meta) => Some(meta.clone()), @@ -157,7 +157,7 @@ impl<'a> Parser<'a> { }; Ok(if let Some(meta) = meta { self.bump(); - (meta.ident, meta.node.tokens(meta.span)) + (meta.path, meta.node.tokens(meta.span)) } else { let path = self.parse_path(PathStyle::Mod)?; let tokens = if self.check(&token::OpenDelim(DelimToken::Paren)) || @@ -174,7 +174,7 @@ impl<'a> Parser<'a> { } else { TokenStream::empty() }; - (path, tokens) + (ast::MetaPath::from_regular_path(&path).unwrap(), tokens) }) } @@ -248,10 +248,14 @@ impl<'a> Parser<'a> { } let lo = self.span; - let ident = self.parse_path(PathStyle::Mod)?; + let path = self.parse_path(PathStyle::Mod)?; let node = self.parse_meta_item_kind()?; let span = lo.to(self.prev_span); - Ok(ast::MetaItem { ident, node, span }) + Ok(ast::MetaItem { + path: ast::MetaPath::from_regular_path(&path).unwrap(), + node, + span, + }) } crate 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 33715f206dedf..4678279ea3975 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2071,10 +2071,22 @@ impl<'a> Parser<'a> { crate fn parse_path_common(&mut self, style: PathStyle, enable_warning: bool) -> PResult<'a, ast::Path> { maybe_whole!(self, NtPath, |path| { - if style == PathStyle::Mod && - path.segments.iter().any(|segment| segment.args.is_some()) { - self.diagnostic().span_err(path.span, "unexpected generic arguments in path"); + let mut path = path; + + // Check for disallowed generic arguments, and remove them. + // This guarantees a generic-less path for `PathStyle::Mod`, + // implying `MetaPath::from_regular_path` always succeeds. + if style == PathStyle::Mod { + for segment in &mut path.segments{ + if let Some(args) = segment.args.take() { + self.diagnostic().span_err( + args.span(), + "unexpected generic arguments in path", + ); + } + } } + path }); @@ -2092,17 +2104,17 @@ impl<'a> Parser<'a> { /// 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_ident = match self.token { + let meta_path = match self.token { token::Interpolated(ref nt) => match nt.0 { token::NtMeta(ref meta) => match meta.node { - ast::MetaItemKind::Word => Some(meta.ident.clone()), + ast::MetaItemKind::Word => Some(meta.path.to_regular_path()), _ => None, }, _ => None, }, _ => None, }; - if let Some(path) = meta_ident { + if let Some(path) = meta_path { self.bump(); return Ok(path); } @@ -6479,7 +6491,9 @@ impl<'a> Parser<'a> { let attr = Attribute { id: attr::mk_attr_id(), style: ast::AttrStyle::Outer, - path: ast::Path::from_ident(Ident::from_str("warn_directory_ownership")), + path: ast::MetaPath::from_ident( + Ident::from_str("warn_directory_ownership"), + ), tokens: TokenStream::empty(), is_sugared_doc: false, span: syntax_pos::DUMMY_SP, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 46fc6454d1c3b..1f23111a16bb1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -799,8 +799,8 @@ fn prepend_attrs(sess: &ParseSess, let mut brackets = tokenstream::TokenStreamBuilder::new(); // For simple paths, push the identifier directly - if attr.path.segments.len() == 1 && attr.path.segments[0].args.is_none() { - let ident = attr.path.segments[0].ident; + if attr.path.segments.len() == 1 { + let ident = attr.path.segments[0]; let token = Ident(ident, ident.as_str().starts_with("r#")); brackets.push(tokenstream::TokenTree::Token(ident.span, token)); @@ -809,7 +809,7 @@ fn prepend_attrs(sess: &ParseSess, } else { let stream = parse_stream_from_source_str( FileName::MacroExpansion, - pprust::path_to_string(&attr.path), + pprust::meta_path_to_string(&attr.path), sess, Some(span), ); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 14ad4b5c6f815..50f8e371c5ee3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -361,6 +361,10 @@ pub fn fn_block_to_string(p: &ast::FnDecl) -> String { to_string(|s| s.print_fn_block_args(p)) } +pub fn meta_path_to_string(p: &ast::MetaPath) -> String { + to_string(|s| s.print_meta_path(p)) +} + pub fn path_to_string(p: &ast::Path) -> String { to_string(|s| s.print_path(p, false, 0)) } @@ -720,17 +724,17 @@ pub trait PrintState<'a> { Ok(()) } - fn print_attribute_path(&mut self, path: &ast::Path) -> io::Result<()> { - for (i, segment) in path.segments.iter().enumerate() { + fn print_meta_path(&mut self, path: &ast::MetaPath) -> io::Result<()> { + for (i, ident) in path.segments.iter().enumerate() { if i > 0 { self.writer().word("::")? } - if segment.ident.name != keywords::CrateRoot.name() && - segment.ident.name != keywords::DollarCrate.name() + if ident.name != keywords::CrateRoot.name() && + ident.name != keywords::DollarCrate.name() { - self.writer().word(segment.ident.as_str().get())?; - } else if segment.ident.name == keywords::DollarCrate.name() { - self.print_dollar_crate(segment.ident.span.ctxt())?; + self.writer().word(ident.as_str().get())?; + } else if ident.name == keywords::DollarCrate.name() { + self.print_dollar_crate(ident.span.ctxt())?; } } Ok(()) @@ -757,7 +761,7 @@ pub trait PrintState<'a> { if let Some(mi) = attr.meta() { self.print_meta_item(&mi)? } else { - self.print_attribute_path(&attr.path)?; + self.print_meta_path(&attr.path)?; self.writer().space()?; self.print_tts(attr.tokens.clone())?; } @@ -779,15 +783,15 @@ pub trait PrintState<'a> { 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.ident)?, + ast::MetaItemKind::Word => self.print_meta_path(&item.path)?, ast::MetaItemKind::NameValue(ref value) => { - self.print_attribute_path(&item.ident)?; + self.print_meta_path(&item.path)?; self.writer().space()?; self.word_space("=")?; self.print_literal(value)?; } ast::MetaItemKind::List(ref items) => { - self.print_attribute_path(&item.ident)?; + self.print_meta_path(&item.path)?; self.popen()?; self.commasep(Consistent, &items[..], diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 1210f331b285b..cc70e1eea47ad 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -103,7 +103,9 @@ pub fn maybe_inject_crates_ref( krate.module.items.insert(0, P(ast::Item { attrs: vec![ast::Attribute { style: ast::AttrStyle::Outer, - path: ast::Path::from_ident(ast::Ident::new(Symbol::intern("prelude_import"), span)), + path: ast::MetaPath::from_ident( + ast::Ident::new(Symbol::intern("prelude_import"), span), + ), tokens: TokenStream::empty(), id: attr::mk_attr_id(), is_sugared_doc: false, diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 8ff4b0d025c8d..3084ee6ecf758 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -443,7 +443,7 @@ fn get_test_runner(sd: &errors::Handler, krate: &ast::Crate) -> Option P { diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 117bedf453e6c..abcae27c5b324 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.rs @@ -12,7 +12,7 @@ use deriving::path_std; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{self, Expr, MetaItem}; +use syntax::ast::{self, Expr}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -21,7 +21,6 @@ use syntax_pos::Span; pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { let inline = cx.meta_word(span, Symbol::intern("inline")); @@ -50,7 +49,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index 24a3a7542fb66..1a773aced6628 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -12,7 +12,7 @@ use deriving::{path_local, path_std}; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{BinOpKind, Expr, MetaItem}; +use syntax::ast::{BinOpKind, Expr}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -21,7 +21,6 @@ use syntax_pos::Span; pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { // structures are equal if all fields are equal, and non equal, if @@ -109,5 +108,5 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, methods, associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index 32a58de3529fd..7aa7351b650a2 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -14,7 +14,7 @@ use deriving::{path_local, pathvec_std, path_std}; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{self, BinOpKind, Expr, MetaItem}; +use syntax::ast::{self, BinOpKind, Expr}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -23,7 +23,6 @@ use syntax_pos::Span; pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { macro_rules! md { @@ -93,7 +92,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, methods, associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } #[derive(Copy, Clone)] diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index df9c351ef1c95..3b2425111c3fd 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -15,7 +15,7 @@ use deriving::generic::ty::*; use rustc_data_structures::thin_vec::ThinVec; use syntax::ast::{self, Ident}; -use syntax::ast::{Expr, MetaItem}; +use syntax::ast::Expr; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -23,7 +23,6 @@ use syntax_pos::{DUMMY_SP, Span}; pub fn expand_deriving_debug(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { // &mut ::std::fmt::Formatter @@ -53,7 +52,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt, }], associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } /// We use the debug builders to do the heavy lifting here diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index c2b9294499907..ecb7862279b27 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -16,7 +16,7 @@ use deriving::generic::ty::*; use deriving::warn_if_deprecated; use syntax::ast; -use syntax::ast::{Expr, MetaItem, Mutability}; +use syntax::ast::{Expr, Mutability}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -25,24 +25,21 @@ use syntax_pos::Span; pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { - expand_deriving_decodable_imp(cx, span, mitem, item, push, "rustc_serialize") + expand_deriving_decodable_imp(cx, span, item, push, "rustc_serialize") } pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { warn_if_deprecated(cx, span, "Decodable"); - expand_deriving_decodable_imp(cx, span, mitem, item, push, "serialize") + expand_deriving_decodable_imp(cx, span, item, push, "serialize") } fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), krate: &'static str) { @@ -86,7 +83,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } fn decodable_substructure(cx: &mut ExtCtxt, diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index adbc5828b8fb8..4150e5afe27c3 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -12,7 +12,7 @@ use deriving::path_std; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{Expr, MetaItem}; +use syntax::ast::Expr; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -21,7 +21,6 @@ use syntax_pos::Span; pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { let inline = cx.meta_word(span, Symbol::intern("inline")); @@ -49,7 +48,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, }], associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P { diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 5438c8b52af05..58f08306e03fa 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -97,7 +97,7 @@ use deriving::generic::*; use deriving::generic::ty::*; use deriving::warn_if_deprecated; -use syntax::ast::{Expr, ExprKind, MetaItem, Mutability}; +use syntax::ast::{Expr, ExprKind, Mutability}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -106,24 +106,21 @@ use syntax_pos::Span; pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { - expand_deriving_encodable_imp(cx, span, mitem, item, push, "rustc_serialize") + expand_deriving_encodable_imp(cx, span, item, push, "rustc_serialize") } pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { warn_if_deprecated(cx, span, "Encodable"); - expand_deriving_encodable_imp(cx, span, mitem, item, push, "serialize") + expand_deriving_encodable_imp(cx, span, item, push, "serialize") } fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable), krate: &'static str) { @@ -169,7 +166,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, associated_types: Vec::new(), }; - trait_def.expand(cx, mitem, item, push) + trait_def.expand(cx, item, push) } fn encodable_substructure(cx: &mut ExtCtxt, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index a5b12ce4c4d83..1d9e14b340dd1 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -397,15 +397,13 @@ fn find_type_parameters(ty: &ast::Ty, impl<'a> TraitDef<'a> { pub fn expand(self, cx: &mut ExtCtxt, - mitem: &ast::MetaItem, item: &'a Annotatable, push: &mut dyn FnMut(Annotatable)) { - self.expand_ext(cx, mitem, item, push, false); + self.expand_ext(cx, item, push, false); } pub fn expand_ext(self, cx: &mut ExtCtxt, - mitem: &ast::MetaItem, item: &'a Annotatable, push: &mut dyn FnMut(Annotatable), from_scratch: bool) { @@ -461,7 +459,7 @@ impl<'a> TraitDef<'a> { generics, from_scratch, use_temporaries) } else { - cx.span_err(mitem.span, + cx.span_err(self.span, "this trait cannot be derived for unions"); return; } diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index 950e8c84f1765..ac2469871f344 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -12,7 +12,7 @@ use deriving::{self, pathvec_std, path_std}; use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{Expr, MetaItem, Mutability}; +use syntax::ast::{Expr, Mutability}; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; @@ -20,7 +20,6 @@ use syntax_pos::Span; pub fn expand_deriving_hash(cx: &mut ExtCtxt, span: Span, - mitem: &MetaItem, item: &Annotatable, push: &mut dyn FnMut(Annotatable)) { @@ -57,7 +56,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, associated_types: Vec::new(), }; - hash_trait_def.expand(cx, mitem, item, push); + hash_trait_def.expand(cx, item, push); } fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P { diff --git a/src/libsyntax_ext/proc_macro_decls.rs b/src/libsyntax_ext/proc_macro_decls.rs index c859275ed020c..e6c161f600b27 100644 --- a/src/libsyntax_ext/proc_macro_decls.rs +++ b/src/libsyntax_ext/proc_macro_decls.rs @@ -265,8 +265,8 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { for attr in &item.attrs { if is_proc_macro_attr(&attr) { if let Some(prev_attr) = found_attr { - let msg = if attr.path.segments[0].ident.name == - prev_attr.path.segments[0].ident.name { + let msg = if attr.path.segments[0].name == + prev_attr.path.segments[0].name { format!("Only one `#[{}]` attribute is allowed on any given function", attr.path) } else { diff --git a/src/test/mir-opt/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline-closure-borrows-arg.rs index ba1712f4ca398..a3289706af93c 100644 --- a/src/test/mir-opt/inline-closure-borrows-arg.rs +++ b/src/test/mir-opt/inline-closure-borrows-arg.rs @@ -30,7 +30,7 @@ fn foo(_t: T, q: &i32) -> i32 { // ... // bb0: { // ... -// _3 = [closure@NodeId(53)]; +// _3 = [closure@NodeId(51)]; // ... // _4 = &_3; // ... diff --git a/src/test/mir-opt/inline-closure.rs b/src/test/mir-opt/inline-closure.rs index 9cb0a4dc2bfac..868fb2787faf9 100644 --- a/src/test/mir-opt/inline-closure.rs +++ b/src/test/mir-opt/inline-closure.rs @@ -26,7 +26,7 @@ fn foo(_t: T, q: i32) -> i32 { // ... // bb0: { // ... -// _3 = [closure@NodeId(39)]; +// _3 = [closure@NodeId(37)]; // ... // _4 = &_3; // ... diff --git a/src/test/mir-opt/retag.rs b/src/test/mir-opt/retag.rs index 7da55c0868cd2..a9aa9d3e9bd16 100644 --- a/src/test/mir-opt/retag.rs +++ b/src/test/mir-opt/retag.rs @@ -108,7 +108,7 @@ fn main() { // } // END rustc.main.EraseRegions.after.mir // START rustc.main-{{closure}}.EraseRegions.after.mir -// fn main::{{closure}}(_1: &[closure@NodeId(124)], _2: &i32) -> &i32 { +// fn main::{{closure}}(_1: &[closure@NodeId(121)], _2: &i32) -> &i32 { // ... // bb0: { // Retag([fn entry] _1); diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs index 985f31296fb87..86ec96b6b629d 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs @@ -34,7 +34,7 @@ pub fn plugin_registrar(reg: &mut Registry) { MultiDecorator(Box::new(expand_deriving_partial_eq))); } -fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, +fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, item: &Annotatable, push: &mut FnMut(Annotatable)) { // structures are equal if all fields are equal, and non equal, if // any fields are not equal or if the enum variants are different diff --git a/src/test/ui/issues/issue-43424.stderr b/src/test/ui/issues/issue-43424.stderr index 3a9a316470399..b65ab587131e2 100644 --- a/src/test/ui/issues/issue-43424.stderr +++ b/src/test/ui/issues/issue-43424.stderr @@ -1,8 +1,8 @@ error: unexpected generic arguments in path - --> $DIR/issue-43424.rs:20:4 + --> $DIR/issue-43424.rs:20:10 | LL | m!(inline); //~ ERROR: unexpected generic arguments in path - | ^^^^^^^^^^ + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/span/import-ty-params.stderr b/src/test/ui/span/import-ty-params.stderr index 7e2c2d382fd69..f3ed1bcfcdd2b 100644 --- a/src/test/ui/span/import-ty-params.stderr +++ b/src/test/ui/span/import-ty-params.stderr @@ -1,14 +1,14 @@ error: unexpected generic arguments in path - --> $DIR/import-ty-params.rs:24:15 + --> $DIR/import-ty-params.rs:24:25 | LL | import! { a::b::c::S } //~ ERROR unexpected generic arguments in path - | ^^^^^^^^^^^^^^ + | ^^^^ error: unexpected generic arguments in path - --> $DIR/import-ty-params.rs:27:15 + --> $DIR/import-ty-params.rs:27:25 | LL | import! { a::b::c::S<> } //~ ERROR unexpected generic arguments in path - | ^^^^^^^^^^^^ + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/macro-ty-params.rs b/src/test/ui/span/macro-ty-params.rs index 5d93b1266a4ae..fc2b780245abe 100644 --- a/src/test/ui/span/macro-ty-params.rs +++ b/src/test/ui/span/macro-ty-params.rs @@ -17,6 +17,5 @@ macro_rules! m { fn main() { foo::!(); //~ ERROR generic arguments in macro path foo::<>!(); //~ ERROR generic arguments in macro path - m!(MyTrait<>); //~ ERROR generic arguments in macro path - //~^ ERROR unexpected generic arguments in path + m!(MyTrait<>); //~ ERROR unexpected generic arguments in path } diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 8a40556a6cd0e..fba55efe832ff 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,13 +1,7 @@ error: unexpected generic arguments in path - --> $DIR/macro-ty-params.rs:20:8 - | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^^^^^^^^ - -error: generic arguments in macro path --> $DIR/macro-ty-params.rs:20:15 | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path +LL | m!(MyTrait<>); //~ ERROR unexpected generic arguments in path | ^^ error: generic arguments in macro path @@ -22,5 +16,5 @@ error: generic arguments in macro path LL | foo::<>!(); //~ ERROR generic arguments in macro path | ^^^^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/span/visibility-ty-params.stderr b/src/test/ui/span/visibility-ty-params.stderr index 7719bd48c85bb..4b3f9e21c1c44 100644 --- a/src/test/ui/span/visibility-ty-params.stderr +++ b/src/test/ui/span/visibility-ty-params.stderr @@ -1,14 +1,14 @@ error: unexpected generic arguments in path - --> $DIR/visibility-ty-params.rs:16:5 + --> $DIR/visibility-ty-params.rs:16:6 | LL | m!{ S } //~ ERROR unexpected generic arguments in path - | ^^^^^ + | ^^^^ error: unexpected generic arguments in path - --> $DIR/visibility-ty-params.rs:19:9 + --> $DIR/visibility-ty-params.rs:19:10 | LL | m!{ m<> } //~ ERROR unexpected generic arguments in path - | ^^^ + | ^^ error: aborting due to 2 previous errors