diff --git a/compiler/rustc_ast/src/ast_traits.rs b/compiler/rustc_ast/src/ast_traits.rs index 4dc9c30a2c807..1ee67f2565d3a 100644 --- a/compiler/rustc_ast/src/ast_traits.rs +++ b/compiler/rustc_ast/src/ast_traits.rs @@ -240,7 +240,7 @@ impl HasTokens for Nonterminal { Nonterminal::NtPath(path) => path.tokens(), Nonterminal::NtVis(vis) => vis.tokens(), Nonterminal::NtBlock(block) => block.tokens(), - Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None, + Nonterminal::NtLifetime(..) => None, } } fn tokens_mut(&mut self) -> Option<&mut Option> { @@ -254,7 +254,7 @@ impl HasTokens for Nonterminal { Nonterminal::NtPath(path) => path.tokens_mut(), Nonterminal::NtVis(vis) => vis.tokens_mut(), Nonterminal::NtBlock(block) => block.tokens_mut(), - Nonterminal::NtIdent(..) | Nonterminal::NtLifetime(..) => None, + Nonterminal::NtLifetime(..) => None, } } } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index c42c41999732c..e7fd2417f608a 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -822,7 +822,6 @@ pub fn visit_nonterminal(nt: &mut token::Nonterminal, vis: &mut T token::NtPat(pat) => vis.visit_pat(pat), token::NtExpr(expr) => vis.visit_expr(expr), token::NtTy(ty) => vis.visit_ty(ty), - token::NtIdent(ident, _is_raw) => vis.visit_ident(ident), token::NtLifetime(ident) => vis.visit_ident(ident), token::NtLiteral(expr) => vis.visit_expr(expr), token::NtMeta(item) => { diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 50fe37dcdb6fc..b0935b83b740f 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -295,9 +295,6 @@ pub enum TokenKind { Literal(Lit), /// Identifier token. - /// Do not forget about `NtIdent` when you want to match on identifiers. - /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to - /// treat regular and interpolated identifiers in the same way. Ident(Symbol, /* is_raw */ bool), /// Lifetime identifier token. /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers. @@ -590,9 +587,6 @@ impl Token { pub fn uninterpolate(&self) -> Cow<'_, Token> { match &self.kind { Interpolated(nt) => match &nt.0 { - NtIdent(ident, is_raw) => { - Cow::Owned(Token::new(Ident(ident.name, *is_raw), ident.span)) - } NtLifetime(ident) => Cow::Owned(Token::new(Lifetime(ident.name), ident.span)), _ => Cow::Borrowed(self), }, @@ -606,10 +600,6 @@ impl Token { // We avoid using `Token::uninterpolate` here because it's slow. match &self.kind { &Ident(name, is_raw) => Some((Ident::new(name, self.span), is_raw)), - Interpolated(nt) => match &nt.0 { - NtIdent(ident, is_raw) => Some((*ident, *is_raw)), - _ => None, - }, _ => None, } } @@ -836,7 +826,6 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(Ident, /* is_raw */ bool), NtLifetime(Ident), NtLiteral(P), /// Stuff inside brackets for attributes @@ -932,7 +921,7 @@ impl Nonterminal { NtPat(pat) => pat.span, NtExpr(expr) | NtLiteral(expr) => expr.span, NtTy(ty) => ty.span, - NtIdent(ident, _) | NtLifetime(ident) => ident.span, + NtLifetime(ident) => ident.span, NtMeta(attr_item) => attr_item.span(), NtPath(path) => path.span, NtVis(vis) => vis.span, @@ -948,7 +937,6 @@ impl Nonterminal { NtExpr(..) => "expression", NtLiteral(..) => "literal", NtTy(..) => "type", - NtIdent(..) => "identifier", NtLifetime(..) => "lifetime", NtMeta(..) => "attribute", NtPath(..) => "path", @@ -960,9 +948,6 @@ impl Nonterminal { impl PartialEq for Nonterminal { fn eq(&self, rhs: &Self) -> bool { match (self, rhs) { - (NtIdent(ident_lhs, is_raw_lhs), NtIdent(ident_rhs, is_raw_rhs)) => { - ident_lhs == ident_rhs && is_raw_lhs == is_raw_rhs - } (NtLifetime(ident_lhs), NtLifetime(ident_rhs)) => ident_lhs == ident_rhs, // FIXME: Assume that all "complex" nonterminal are not equal, we can't compare them // correctly based on data from AST. This will prevent them from matching each other @@ -982,7 +967,6 @@ impl fmt::Debug for Nonterminal { NtPat(..) => f.pad("NtPat(..)"), NtExpr(..) => f.pad("NtExpr(..)"), NtTy(..) => f.pad("NtTy(..)"), - NtIdent(..) => f.pad("NtIdent(..)"), NtLiteral(..) => f.pad("NtLiteral(..)"), NtMeta(..) => f.pad("NtMeta(..)"), NtPath(..) => f.pad("NtPath(..)"), diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 298c01a456740..ec15a5c1cd1fa 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -478,9 +478,6 @@ impl TokenStream { pub fn from_nonterminal_ast(nt: &Nonterminal) -> TokenStream { match nt { - Nonterminal::NtIdent(ident, is_raw) => { - TokenStream::token_alone(token::Ident(ident.name, *is_raw), ident.span) - } Nonterminal::NtLifetime(ident) => { TokenStream::token_alone(token::Lifetime(ident.name), ident.span) } @@ -502,9 +499,6 @@ impl TokenStream { fn flatten_token(token: &Token, spacing: Spacing) -> TokenTree { match &token.kind { - token::Interpolated(nt) if let token::NtIdent(ident, is_raw) = nt.0 => { - TokenTree::Token(Token::new(token::Ident(ident.name, is_raw), ident.span), spacing) - } token::Interpolated(nt) => TokenTree::Delimited( DelimSpan::from_single(token.span), DelimSpacing::new(Spacing::JointHidden, spacing), diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 7ea0078ea3bb9..040052e6219e6 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -731,7 +731,6 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere token::NtBlock(e) => self.block_to_string(e), token::NtStmt(e) => self.stmt_to_string(e), token::NtPat(e) => self.pat_to_string(e), - token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(*e, *is_raw).to_string(), token::NtLifetime(e) => e.to_string(), token::NtLiteral(e) => self.expr_to_string(e), token::NtVis(e) => self.vis_to_string(e), diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 8f31b5801da7f..edac4559ef1b2 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -256,14 +256,6 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec { - trees.push(TokenTree::Ident(Ident { - sym: ident.name, - is_raw: *is_raw, - span: ident.span, - })) - } - Interpolated(nt) => { let stream = TokenStream::from_nonterminal_ast(&nt.0); // A hack used to pass AST fragments to attribute and derive diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index 2307f4cfffae6..1fff3eb0d5527 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -226,8 +226,7 @@ impl<'a> Parser<'a> { let (mut ret, trailing) = ret?; // When we're not in `capture-cfg` mode, then bail out early if: - // 1. Our target doesn't support tokens at all (e.g we're parsing an `NtIdent`) - // so there's nothing for us to do. + // 1. Our target doesn't support tokens at all, so there's nothing for us to do. // 2. Our target already has tokens set (e.g. we've parsed something // like `#[my_attr] $item`. The actual parsing code takes care of prepending // any attributes to the nonterminal, so we don't need to modify the diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 071d6b72f3b96..30b8c67075825 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -3,7 +3,7 @@ use rustc_ast::token::{self, Delimiter, Nonterminal::*, NonterminalKind, Token}; use rustc_ast::HasTokens; use rustc_ast_pretty::pprust; use rustc_errors::PResult; -use rustc_span::symbol::{kw, Ident}; +use rustc_span::symbol::kw; use crate::errors::UnexpectedNonterminal; use crate::parser::pat::{CommaRecoveryMode, RecoverColon, RecoverComma}; @@ -24,7 +24,6 @@ impl<'a> Parser<'a> { | NtPat(_) | NtExpr(_) | NtTy(_) - | NtIdent(..) | NtLiteral(_) // `true`, `false` | NtMeta(_) | NtPath(_) => true, @@ -45,7 +44,7 @@ impl<'a> Parser<'a> { && !token.is_keyword(kw::Const) } NonterminalKind::Ty => token.can_begin_type(), - NonterminalKind::Ident => get_macro_ident(token).is_some(), + NonterminalKind::Ident => is_macro_ident(token), NonterminalKind::Literal => token.can_begin_literal_maybe_minus(), NonterminalKind::Vis => match token.kind { // The follow-set of :vis + "priv" keyword + interpolated @@ -56,8 +55,7 @@ impl<'a> Parser<'a> { token::OpenDelim(Delimiter::Brace) => true, token::Interpolated(nt) => match &nt.0 { NtBlock(_) | NtLifetime(_) | NtStmt(_) | NtExpr(_) | NtLiteral(_) => true, - NtItem(_) | NtPat(_) | NtTy(_) | NtIdent(..) | NtMeta(_) | NtPath(_) - | NtVis(_) => false, + NtItem(_) | NtPat(_) | NtTy(_) | NtMeta(_) | NtPath(_) | NtVis(_) => false, }, _ => false, }, @@ -108,8 +106,17 @@ impl<'a> Parser<'a> { // in advance whether or not a proc-macro will be (transitively) invoked, // we always capture tokens for any `Nonterminal` which needs them. let mut nt = match kind { - // Note that TT is treated differently to all the others. + // Note that `tt` and `ident` are treated differently to all the others. NonterminalKind::TT => return Ok(ParseNtResult::Tt(self.parse_token_tree())), + NonterminalKind::Ident if is_macro_ident(&self.token) => { + return Ok(ParseNtResult::Tt(self.parse_token_tree())); + } + NonterminalKind::Ident => { + return Err(self.dcx().create_err(UnexpectedNonterminal::Ident { + span: self.token.span, + token: self.token.clone(), + })); + } NonterminalKind::Item => match self.parse_item(ForceCollect::Yes)? { Some(item) => NtItem(item), None => { @@ -153,18 +160,6 @@ impl<'a> Parser<'a> { NonterminalKind::Ty => { NtTy(self.collect_tokens_no_attrs(|this| this.parse_ty_no_question_mark_recover())?) } - - // this could be handled like a token, since it is one - NonterminalKind::Ident if let Some((ident, is_raw)) = get_macro_ident(&self.token) => { - self.bump(); - NtIdent(ident, is_raw) - } - NonterminalKind::Ident => { - return Err(self.dcx().create_err(UnexpectedNonterminal::Ident { - span: self.token.span, - token: self.token.clone(), - })); - } NonterminalKind::Path => { NtPath(P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type))?)) } @@ -201,6 +196,6 @@ impl<'a> Parser<'a> { /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { - token.ident().filter(|(ident, _)| ident.name != kw::Underscore) +fn is_macro_ident(token: &Token) -> bool { + token.ident().map_or(false, |(ident, _)| ident.name != kw::Underscore) } diff --git a/src/tools/clippy/tests/ui/manual_let_else.stderr b/src/tools/clippy/tests/ui/manual_let_else.stderr index 3beaf766efb13..637125167fb6d 100644 --- a/src/tools/clippy/tests/ui/manual_let_else.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else.stderr @@ -367,7 +367,7 @@ error: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:212:13 | LL | let $n = if let Some(v) = $e { v } else { return }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(w) = g() else { return };` ... LL | create_binding_if_some!(w, g()); | ------------------------------- in this macro invocation diff --git a/src/tools/clippy/tests/ui/needless_late_init.fixed b/src/tools/clippy/tests/ui/needless_late_init.fixed index 6db870490445e..44ef7e129cb6c 100644 --- a/src/tools/clippy/tests/ui/needless_late_init.fixed +++ b/src/tools/clippy/tests/ui/needless_late_init.fixed @@ -199,11 +199,12 @@ fn does_not_lint() { } y = 3; - let x; - inline!($x = 1;); + + inline!($let x = 1;); let x; if true { + #[cfg(FALSE)] // FIXME inline!($x = 1;); } else { x = 2; diff --git a/src/tools/clippy/tests/ui/needless_late_init.rs b/src/tools/clippy/tests/ui/needless_late_init.rs index c1e86212a08b8..4a679b133e1d7 100644 --- a/src/tools/clippy/tests/ui/needless_late_init.rs +++ b/src/tools/clippy/tests/ui/needless_late_init.rs @@ -204,6 +204,7 @@ fn does_not_lint() { let x; if true { + #[cfg(FALSE)] // FIXME inline!($x = 1;); } else { x = 2; diff --git a/src/tools/clippy/tests/ui/needless_late_init.stderr b/src/tools/clippy/tests/ui/needless_late_init.stderr index 602b1a683e51d..2cc28956f41e0 100644 --- a/src/tools/clippy/tests/ui/needless_late_init.stderr +++ b/src/tools/clippy/tests/ui/needless_late_init.stderr @@ -271,5 +271,19 @@ help: add a semicolon after the `match` expression LL | }; | + -error: aborting due to 16 previous errors +error: unneeded late initialization + --> $DIR/needless_late_init.rs:202:5 + | +LL | let x; + | ^^^^^^ created here +LL | inline!($x = 1;); + | ^^^^^^ initialised here + | + = note: this error originates in the macro `__inline_mac_fn_does_not_lint` (in Nightly builds, run with -Z macro-backtrace for more info) +help: declare `x` here + | +LL | inline!($let x = 1;); + | ~~~~~ + +error: aborting due to 17 previous errors diff --git a/src/tools/clippy/tests/ui/ptr_as_ptr.fixed b/src/tools/clippy/tests/ui/ptr_as_ptr.fixed index fa15c323540ff..a42aae73b923d 100644 --- a/src/tools/clippy/tests/ui/ptr_as_ptr.fixed +++ b/src/tools/clippy/tests/ui/ptr_as_ptr.fixed @@ -47,7 +47,8 @@ fn main() { let _: *mut i32 = mut_ptr.cast(); // Make sure the lint is triggered inside a macro - let _ = inline!($ptr.cast::()); + #[cfg(FALSE)] // FIXME + let _ = inline!($ptr as *const i32); // Do not lint inside macros from external crates let _ = external!($ptr as *const i32); diff --git a/src/tools/clippy/tests/ui/ptr_as_ptr.rs b/src/tools/clippy/tests/ui/ptr_as_ptr.rs index 7ab52e63da556..2df8fa9696dce 100644 --- a/src/tools/clippy/tests/ui/ptr_as_ptr.rs +++ b/src/tools/clippy/tests/ui/ptr_as_ptr.rs @@ -47,6 +47,7 @@ fn main() { let _: *mut i32 = mut_ptr as _; // Make sure the lint is triggered inside a macro + #[cfg(FALSE)] // FIXME let _ = inline!($ptr as *const i32); // Do not lint inside macros from external crates diff --git a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr index ef64347e9350c..68bd91ce342dd 100644 --- a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr +++ b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr @@ -38,168 +38,160 @@ LL | let _: *mut i32 = mut_ptr as _; | ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:50:21 - | -LL | let _ = inline!($ptr as *const i32); - | ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::()` - | - = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:71:13 + --> $DIR/ptr_as_ptr.rs:72:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:72:13 + --> $DIR/ptr_as_ptr.rs:73:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:79:9 + --> $DIR/ptr_as_ptr.rs:80:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:83:9 + --> $DIR/ptr_as_ptr.rs:84:9 | LL | std::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:88:9 + --> $DIR/ptr_as_ptr.rs:89:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:92:9 + --> $DIR/ptr_as_ptr.rs:93:9 | LL | core::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:97:9 + --> $DIR/ptr_as_ptr.rs:98:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:101:9 + --> $DIR/ptr_as_ptr.rs:102:9 | LL | std::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:106:9 + --> $DIR/ptr_as_ptr.rs:107:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:110:9 + --> $DIR/ptr_as_ptr.rs:111:9 | LL | core::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:117:9 + --> $DIR/ptr_as_ptr.rs:118:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:121:9 + --> $DIR/ptr_as_ptr.rs:122:9 | LL | std::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:126:9 + --> $DIR/ptr_as_ptr.rs:127:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:130:9 + --> $DIR/ptr_as_ptr.rs:131:9 | LL | core::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:135:9 + --> $DIR/ptr_as_ptr.rs:136:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:139:9 + --> $DIR/ptr_as_ptr.rs:140:9 | LL | std::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:144:9 + --> $DIR/ptr_as_ptr.rs:145:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:148:9 + --> $DIR/ptr_as_ptr.rs:149:9 | LL | core::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:155:9 + --> $DIR/ptr_as_ptr.rs:156:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:159:9 + --> $DIR/ptr_as_ptr.rs:160:9 | LL | std::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:164:9 + --> $DIR/ptr_as_ptr.rs:165:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:168:9 + --> $DIR/ptr_as_ptr.rs:169:9 | LL | core::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:173:9 + --> $DIR/ptr_as_ptr.rs:174:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:177:9 + --> $DIR/ptr_as_ptr.rs:178:9 | LL | std::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:182:9 + --> $DIR/ptr_as_ptr.rs:183:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:186:9 + --> $DIR/ptr_as_ptr.rs:187:9 | LL | core::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` -error: aborting due to 33 previous errors +error: aborting due to 32 previous errors diff --git a/src/tools/clippy/tests/ui/shadow.stderr b/src/tools/clippy/tests/ui/shadow.stderr index 26ace287b1f4a..1aedb15225ae5 100644 --- a/src/tools/clippy/tests/ui/shadow.stderr +++ b/src/tools/clippy/tests/ui/shadow.stderr @@ -146,6 +146,18 @@ note: previous binding is here LL | let y = 1; | ^ +error: `x` is shadowed + --> $DIR/shadow.rs:50:12 + | +LL | reuse!(x); + | ^ + | +note: previous binding is here + --> $DIR/shadow.rs:48:9 + | +LL | let x = 1; + | ^ + error: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:55:9 | @@ -280,5 +292,5 @@ note: previous binding is here LL | let x = 1; | ^ -error: aborting due to 23 previous errors +error: aborting due to 24 previous errors diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.fixed b/src/tools/clippy/tests/ui/unnecessary_cast.fixed index 18dd53bf2b42c..63744498a458c 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_cast.fixed @@ -142,6 +142,7 @@ fn main() { let _ = $e != 0usize; }} } + #[cfg(FALSE)] // FIXME bind_var!(x, (x as usize) + 1); } diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.rs b/src/tools/clippy/tests/ui/unnecessary_cast.rs index fcdd4c60ccd01..96d98ec47c8e8 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.rs +++ b/src/tools/clippy/tests/ui/unnecessary_cast.rs @@ -142,6 +142,7 @@ fn main() { let _ = $e != 0usize; }} } + #[cfg(FALSE)] // FIXME bind_var!(x, (x as usize) + 1); } diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.stderr b/src/tools/clippy/tests/ui/unnecessary_cast.stderr index d4786f66e4476..de47fe28c2952 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_cast.stderr @@ -104,139 +104,139 @@ LL | aaa() as u32; | ^^^^^^^^^^^^ help: try: `aaa()` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:155:9 + --> $DIR/unnecessary_cast.rs:156:9 | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:156:9 + --> $DIR/unnecessary_cast.rs:157:9 | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:157:9 + --> $DIR/unnecessary_cast.rs:158:9 | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:158:17 + --> $DIR/unnecessary_cast.rs:159:17 | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:159:17 + --> $DIR/unnecessary_cast.rs:160:17 | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:160:17 + --> $DIR/unnecessary_cast.rs:161:17 | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:161:9 + --> $DIR/unnecessary_cast.rs:162:9 | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:162:9 + --> $DIR/unnecessary_cast.rs:163:9 | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:174:9 + --> $DIR/unnecessary_cast.rs:175:9 | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:175:9 + --> $DIR/unnecessary_cast.rs:176:9 | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` error: casting integer literal to `usize` is unnecessary - --> $DIR/unnecessary_cast.rs:176:9 + --> $DIR/unnecessary_cast.rs:177:9 | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` error: casting integer literal to `u16` is unnecessary - --> $DIR/unnecessary_cast.rs:177:9 + --> $DIR/unnecessary_cast.rs:178:9 | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:178:9 + --> $DIR/unnecessary_cast.rs:179:9 | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:180:9 + --> $DIR/unnecessary_cast.rs:181:9 | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:181:9 + --> $DIR/unnecessary_cast.rs:182:9 | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:185:17 + --> $DIR/unnecessary_cast.rs:186:17 | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:186:17 + --> $DIR/unnecessary_cast.rs:187:17 | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/unnecessary_cast.rs:192:18 + --> $DIR/unnecessary_cast.rs:193:18 | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:198:22 + --> $DIR/unnecessary_cast.rs:199:22 | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i64` is unnecessary - --> $DIR/unnecessary_cast.rs:200:22 + --> $DIR/unnecessary_cast.rs:201:22 | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:207:22 + --> $DIR/unnecessary_cast.rs:208:22 | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:209:23 + --> $DIR/unnecessary_cast.rs:210:23 | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/unnecessary_cast.rs:217:20 + --> $DIR/unnecessary_cast.rs:218:20 | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr index 422dc24343612..40f43f0666b34 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr @@ -9,14 +9,8 @@ LL | unsafe { ptr.write(S(0)) }; help: was created by a SharedReadWrite retag at offsets [0x0..0x4] --> $DIR/arg_inplace_mutate.rs:LL:CC | -LL | / mir! { -LL | | let _unit: (); -LL | | { -LL | | let non_copy = S(42); -... | -LL | | -LL | | } - | |_____^ +LL | let ptr = std::ptr::addr_of_mut!(non_copy); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: is this argument --> $DIR/arg_inplace_mutate.rs:LL:CC | @@ -29,7 +23,6 @@ note: inside `main` | LL | Call(_unit = callee(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr index 4fe9b7b4728da..5551373926e71 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr @@ -11,14 +11,8 @@ LL | unsafe { ptr.write(S(0)) }; help: the accessed tag was created here --> $DIR/arg_inplace_mutate.rs:LL:CC | -LL | / mir! { -LL | | let _unit: (); -LL | | { -LL | | let non_copy = S(42); -... | -LL | | -LL | | } - | |_____^ +LL | let non_copy = S(42); + | ^^^^^^^^^^^^^^^^ help: the protected tag was created here, in the initial state Reserved --> $DIR/arg_inplace_mutate.rs:LL:CC | @@ -37,7 +31,6 @@ note: inside `main` | LL | Call(_unit = callee(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr index 09c9a777eca46..704a84384a9cc 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr @@ -9,14 +9,8 @@ LL | unsafe { ptr.read() }; help: was created by a SharedReadWrite retag at offsets [0x0..0x4] --> $DIR/arg_inplace_observe_during.rs:LL:CC | -LL | / mir! { -LL | | let _unit: (); -LL | | { -LL | | let non_copy = S(42); -... | -LL | | -LL | | } - | |_____^ +LL | let ptr = std::ptr::addr_of_mut!(non_copy); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: is this argument --> $DIR/arg_inplace_observe_during.rs:LL:CC | @@ -29,7 +23,6 @@ note: inside `main` | LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr index 67906f24bbd03..0db04761272aa 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr @@ -11,14 +11,8 @@ LL | unsafe { ptr.read() }; help: the accessed tag was created here --> $DIR/arg_inplace_observe_during.rs:LL:CC | -LL | / mir! { -LL | | let _unit: (); -LL | | { -LL | | let non_copy = S(42); -... | -LL | | -LL | | } - | |_____^ +LL | let non_copy = S(42); + | ^^^^^^^^^^^^^^^^ help: the protected tag was created here, in the initial state Reserved --> $DIR/arg_inplace_observe_during.rs:LL:CC | @@ -37,7 +31,6 @@ note: inside `main` | LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.stack.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.stack.stderr index 01357f430fc71..cd0d2af423c7a 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.stack.stderr @@ -9,14 +9,8 @@ LL | unsafe { ptr.read() }; help: was created by a SharedReadWrite retag at offsets [0x0..0x4] --> $DIR/return_pointer_aliasing.rs:LL:CC | -LL | / mir! { -LL | | { -LL | | let x = 0; -LL | | let ptr = &raw mut x; -... | -LL | | } -LL | | } - | |_____^ +LL | let ptr = &raw mut x; + | ^^^^^^^^^^^^^^^^ help: is this argument --> $DIR/return_pointer_aliasing.rs:LL:CC | @@ -29,7 +23,6 @@ note: inside `main` | LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.tree.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.tree.stderr index 6b3f5fbedee9c..126117309d7f8 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.tree.stderr @@ -11,14 +11,8 @@ LL | unsafe { ptr.read() }; help: the accessed tag was created here --> $DIR/return_pointer_aliasing.rs:LL:CC | -LL | / mir! { -LL | | { -LL | | let x = 0; -LL | | let ptr = &raw mut x; -... | -LL | | } -LL | | } - | |_____^ +LL | let ptr = &raw mut x; + | ^^^^^^^^^^^^^^^^ help: the protected tag was created here, in the initial state Reserved --> $DIR/return_pointer_aliasing.rs:LL:CC | @@ -37,7 +31,6 @@ note: inside `main` | LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.stack.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.stack.stderr index 04040827b0f97..26764f95d5c9e 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.stack.stderr @@ -12,14 +12,8 @@ LL | unsafe { ptr.write(0) }; help: was created by a SharedReadWrite retag at offsets [0x0..0x4] --> $DIR/return_pointer_aliasing2.rs:LL:CC | -LL | / mir! { -LL | | { -LL | | let _x = 0; -LL | | let ptr = &raw mut _x; -... | -LL | | } -LL | | } - | |_____^ +LL | let ptr = &raw mut _x; + | ^^^^^^^^^^^^^^^^^ help: was later invalidated at offsets [0x0..0x4] by a Unique in-place function argument/return passing protection --> $DIR/return_pointer_aliasing2.rs:LL:CC | @@ -32,7 +26,6 @@ note: inside `main` | LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.tree.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.tree.stderr index 37c98eabbec83..c9b3d5eaaf103 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.tree.stderr @@ -11,14 +11,8 @@ LL | unsafe { ptr.write(0) }; help: the accessed tag was created here --> $DIR/return_pointer_aliasing2.rs:LL:CC | -LL | / mir! { -LL | | { -LL | | let _x = 0; -LL | | let ptr = &raw mut _x; -... | -LL | | } -LL | | } - | |_____^ +LL | let ptr = &raw mut _x; + | ^^^^^^^^^^^^^^^^^ help: the protected tag was created here, in the initial state Reserved --> $DIR/return_pointer_aliasing2.rs:LL:CC | @@ -37,7 +31,6 @@ note: inside `main` | LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/tests/ui/borrowck/move-error-snippets.stderr b/tests/ui/borrowck/move-error-snippets.stderr index 83f9e19aa0d5c..61f5861bcce87 100644 --- a/tests/ui/borrowck/move-error-snippets.stderr +++ b/tests/ui/borrowck/move-error-snippets.stderr @@ -1,19 +1,17 @@ error[E0507]: cannot move out of static item `D` - --> $DIR/move-error-snippets-ext.rs:5:17 - | -LL | let a = $c; - | ^^ move occurs because `D` has type `A`, which does not implement the `Copy` trait - | - ::: $DIR/move-error-snippets.rs:21:1 + --> $DIR/move-error-snippets.rs:16:18 | +LL | aaa!(D); + | ^ move occurs because `D` has type `A`, which does not implement the `Copy` trait +... LL | sss!(); | ------ in this macro invocation | - = note: this error originates in the macro `aaa` which comes from the expansion of the macro `sss` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `sss` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider borrowing here | -LL | let a = &$c; - | + +LL | aaa!(&D); + | + error: aborting due to 1 previous error diff --git a/tests/ui/deriving/multiple-defaults.stderr b/tests/ui/deriving/multiple-defaults.stderr index 05fb6fecffaec..2fd1b209a8b25 100644 --- a/tests/ui/deriving/multiple-defaults.stderr +++ b/tests/ui/deriving/multiple-defaults.stderr @@ -45,14 +45,12 @@ error: multiple declared defaults LL | #[derive(Default)] | ^^^^^^^ ... -LL | $id, - | --- - | | - | first default - | additional default -... LL | m! { A B } - | ---------- in this macro invocation + | ---------- + | | | | + | | | additional default + | | first default + | in this macro invocation | = note: only one variant can be default = note: this error originates in the derive macro `Default` which comes from the expansion of the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/editions/edition-keywords-2018-2015-parsing.rs b/tests/ui/editions/edition-keywords-2018-2015-parsing.rs index 5918454327409..0a0fae1de0d9f 100644 --- a/tests/ui/editions/edition-keywords-2018-2015-parsing.rs +++ b/tests/ui/editions/edition-keywords-2018-2015-parsing.rs @@ -21,7 +21,7 @@ pub fn check_async() { r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` r#async = consumes_async_raw!(r#async); // OK - if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved + if passes_ident!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if passes_ident!(r#async) == 1 {} // OK if passes_tt!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if passes_tt!(r#async) == 1 {} // OK diff --git a/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr b/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr index 42db75f665973..9fd259d459859 100644 --- a/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -45,15 +45,10 @@ LL | (r#async) => (1) | ^^^^^^^ error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` - --> $DIR/auxiliary/edition-kw-macro-2015.rs:27:23 + --> $DIR/edition-keywords-2018-2015-parsing.rs:24:27 | -LL | ($i: ident) => ($i) - | ^ expected one of `move`, `|`, or `||` - | - ::: $DIR/edition-keywords-2018-2015-parsing.rs:24:8 - | -LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved - | -------------------- in this macro invocation +LL | if passes_ident!(async) == 1 {} + | ^ expected one of `move`, `|`, or `||` error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` --> $DIR/edition-keywords-2018-2015-parsing.rs:26:24 diff --git a/tests/ui/editions/edition-keywords-2018-2018-parsing.rs b/tests/ui/editions/edition-keywords-2018-2018-parsing.rs index 4975246fa9423..e2aef5c87f172 100644 --- a/tests/ui/editions/edition-keywords-2018-2018-parsing.rs +++ b/tests/ui/editions/edition-keywords-2018-2018-parsing.rs @@ -13,7 +13,7 @@ mod module { } macro_rules! local_passes_ident { - ($i: ident) => ($i) //~ ERROR macro expansion ends with an incomplete expression + ($i: ident) => ($i) } macro_rules! local_passes_tt { ($i: tt) => ($i) @@ -28,11 +28,11 @@ pub fn check_async() { r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` r#async = consumes_async_raw!(r#async); // OK - if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved + if passes_ident!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if passes_ident!(r#async) == 1 {} // OK if passes_tt!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if passes_tt!(r#async) == 1 {} // OK - if local_passes_ident!(async) == 1 {} // Error reported above in the macro + if local_passes_ident!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if local_passes_ident!(r#async) == 1 {} // OK if local_passes_tt!(async) == 1 {} //~ ERROR macro expansion ends with an incomplete expression if local_passes_tt!(r#async) == 1 {} // OK diff --git a/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr b/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr index 4bbe1597233cf..0b196ec72cc41 100644 --- a/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -45,15 +45,10 @@ LL | (r#async) => (1) | ^^^^^^^ error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` - --> $DIR/auxiliary/edition-kw-macro-2018.rs:27:23 + --> $DIR/edition-keywords-2018-2018-parsing.rs:31:27 | -LL | ($i: ident) => ($i) - | ^ expected one of `move`, `|`, or `||` - | - ::: $DIR/edition-keywords-2018-2018-parsing.rs:31:8 - | -LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved - | -------------------- in this macro invocation +LL | if passes_ident!(async) == 1 {} + | ^ expected one of `move`, `|`, or `||` error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` --> $DIR/edition-keywords-2018-2018-parsing.rs:33:24 @@ -62,10 +57,10 @@ LL | if passes_tt!(async) == 1 {} | ^ expected one of `move`, `|`, or `||` error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` - --> $DIR/edition-keywords-2018-2018-parsing.rs:16:23 + --> $DIR/edition-keywords-2018-2018-parsing.rs:35:33 | -LL | ($i: ident) => ($i) - | ^ expected one of `move`, `|`, or `||` +LL | if local_passes_ident!(async) == 1 {} + | ^ expected one of `move`, `|`, or `||` error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||` --> $DIR/edition-keywords-2018-2018-parsing.rs:37:30 diff --git a/tests/ui/hygiene/generate-mod.rs b/tests/ui/hygiene/generate-mod.rs index 8826293542c97..9238c07ac2a27 100644 --- a/tests/ui/hygiene/generate-mod.rs +++ b/tests/ui/hygiene/generate-mod.rs @@ -7,7 +7,9 @@ macro genmod($FromOutside: ident, $Outer: ident) { struct $Outer; mod inner { type A = $FromOutside; // `FromOutside` shouldn't be available from here + //~^ ERROR cannot find type `FromOutside` in this scope type Inner = $Outer; // `Outer` shouldn't be available from here + //~^ ERROR cannot find type `Outer` in this scope } } @@ -32,8 +34,7 @@ macro_rules! genmod_legacy { () => { fn check() { struct FromOutside; - genmod!(FromOutside, Outer); //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `Outer` in this scope + genmod!(FromOutside, Outer); } fn check_transparent() { diff --git a/tests/ui/hygiene/generate-mod.stderr b/tests/ui/hygiene/generate-mod.stderr index 32a2e145ca942..1b420724c1d2e 100644 --- a/tests/ui/hygiene/generate-mod.stderr +++ b/tests/ui/hygiene/generate-mod.stderr @@ -1,17 +1,17 @@ error[E0412]: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:35:13 + --> $DIR/generate-mod.rs:9:18 | -LL | genmod!(FromOutside, Outer); - | ^^^^^^^^^^^ not found in this scope +LL | type A = $FromOutside; // `FromOutside` shouldn't be available from here + | ^^^^^^^^^^^^ not found in this scope error[E0412]: cannot find type `Outer` in this scope - --> $DIR/generate-mod.rs:35:26 + --> $DIR/generate-mod.rs:11:22 | -LL | genmod!(FromOutside, Outer); - | ^^^^^ not found in this scope +LL | type Inner = $Outer; // `Outer` shouldn't be available from here + | ^^^^^^ not found in this scope error[E0412]: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:19:18 + --> $DIR/generate-mod.rs:21:18 | LL | type A = FromOutside; | ^^^^^^^^^^^ not found in this scope @@ -22,7 +22,7 @@ LL | genmod_transparent!(); = note: this error originates in the macro `genmod_transparent` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Outer` in this scope - --> $DIR/generate-mod.rs:20:22 + --> $DIR/generate-mod.rs:22:22 | LL | type Inner = Outer; | ^^^^^ not found in this scope @@ -33,7 +33,7 @@ LL | genmod_transparent!(); = note: this error originates in the macro `genmod_transparent` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:28:18 + --> $DIR/generate-mod.rs:30:18 | LL | type A = FromOutside; | ^^^^^^^^^^^ not found in this scope @@ -44,7 +44,7 @@ LL | genmod_legacy!(); = note: this error originates in the macro `genmod_legacy` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Outer` in this scope - --> $DIR/generate-mod.rs:29:22 + --> $DIR/generate-mod.rs:31:22 | LL | type Inner = Outer; | ^^^^^ not found in this scope diff --git a/tests/ui/issues/issue-39848.rs b/tests/ui/issues/issue-39848.rs index 2a059120e8175..ec054de95bf21 100644 --- a/tests/ui/issues/issue-39848.rs +++ b/tests/ui/issues/issue-39848.rs @@ -1,9 +1,9 @@ macro_rules! get_opt { ($tgt:expr, $field:ident) => { - if $tgt.has_$field() {} //~ ERROR expected `{`, found identifier `foo` + if $tgt.has_$field() {} } } fn main() { - get_opt!(bar, foo); + get_opt!(bar, foo); //~ ERROR expected `{`, found `foo` } diff --git a/tests/ui/issues/issue-39848.stderr b/tests/ui/issues/issue-39848.stderr index a6c6c61f17095..04577e3500598 100644 --- a/tests/ui/issues/issue-39848.stderr +++ b/tests/ui/issues/issue-39848.stderr @@ -1,11 +1,8 @@ -error: expected `{`, found identifier `foo` - --> $DIR/issue-39848.rs:3:21 +error: expected `{`, found `foo` + --> $DIR/issue-39848.rs:8:19 | -LL | if $tgt.has_$field() {} - | ^^^^^^ expected `{` -... LL | get_opt!(bar, foo); - | ------------------ in this macro invocation + | ^^^ expected `{` | note: the `if` expression is missing a block after this condition --> $DIR/issue-39848.rs:3:12 diff --git a/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr b/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr index 84efaa4f3687b..f6df1d59fbe27 100644 --- a/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr +++ b/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr @@ -2,22 +2,13 @@ error: unused variable: `var` --> $DIR/issue-117284-arg-in-macro.rs:15:18 | LL | make_var!(s, var); - | ^^^ + | ^^^ help: if this is intentional, prefix it with an underscore: `_var` | -help: `var` is captured in macro and introduced a unused variable - --> $DIR/issue-117284-arg-in-macro.rs:4:13 - | -LL | let $var = $struct.$var; - | ^^^^ -... -LL | make_var!(s, var); - | ----------------- in this macro invocation note: the lint level is defined here --> $DIR/issue-117284-arg-in-macro.rs:1:9 | LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `make_var` (in Nightly builds, run with -Z macro-backtrace for more info) error: unused variable: `a` --> $DIR/issue-117284-arg-in-macro.rs:16:9 diff --git a/tests/ui/lint/wide_pointer_comparisons.rs b/tests/ui/lint/wide_pointer_comparisons.rs index 313690010754e..38463e41df089 100644 --- a/tests/ui/lint/wide_pointer_comparisons.rs +++ b/tests/ui/lint/wide_pointer_comparisons.rs @@ -121,10 +121,10 @@ fn main() { { macro_rules! cmp { ($a:ident, $b:ident) => { $a == $b } - //~^ WARN ambiguous wide pointer comparison } cmp!(a, b); + //~^ WARN ambiguous wide pointer comparison } { diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 6ef117c63c5b8..9ba83bf8d746a 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -432,19 +432,15 @@ LL | cmp!(std::ptr::addr_eq(a, b)); | ++++++++++++++++++ ~ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected - --> $DIR/wide_pointer_comparisons.rs:123:39 + --> $DIR/wide_pointer_comparisons.rs:126:14 | -LL | ($a:ident, $b:ident) => { $a == $b } - | ^^^^^^^^ -... LL | cmp!(a, b); - | ---------- in this macro invocation + | ^^^^ | - = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | ($a:ident, $b:ident) => { std::ptr::addr_eq($a, $b) } - | ++++++++++++++++++ ~ + +LL | cmp!(std::ptr::addr_eq(a, b)); + | ++++++++++++++++++ ~ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:133:37 diff --git a/tests/ui/macros/span-covering-argument-1.stderr b/tests/ui/macros/span-covering-argument-1.stderr index 9ad2bc73a4ff5..a77e18ddf8e3b 100644 --- a/tests/ui/macros/span-covering-argument-1.stderr +++ b/tests/ui/macros/span-covering-argument-1.stderr @@ -10,8 +10,8 @@ LL | bad!(foo whatever); = note: this error originates in the macro `bad` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider changing this to be mutable | -LL | let mut $s = 0; - | +++ +LL | bad!(mut foo whatever); + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/methods/method-on-ambiguous-numeric-type.stderr b/tests/ui/methods/method-on-ambiguous-numeric-type.stderr index 124270402727d..13421ad46f03e 100644 --- a/tests/ui/methods/method-on-ambiguous-numeric-type.stderr +++ b/tests/ui/methods/method-on-ambiguous-numeric-type.stderr @@ -36,8 +36,8 @@ LL | local_bar.pow(2); | help: you must specify a type for this binding, like `i32` | -LL | ($ident:ident) => { let $ident: i32 = 42; } - | +++++ +LL | local_mac!(local_bar: i32); + | +++++ error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}` --> $DIR/method-on-ambiguous-numeric-type.rs:31:18 @@ -57,10 +57,9 @@ LL | bar.pow(2); | ^^^ | help: you must specify a type for this binding, like `i32` - --> $DIR/auxiliary/macro-in-other-crate.rs:3:35 | -LL | ($ident:ident) => { let $ident: i32 = 42; } - | +++++ +LL | mac!(bar: i32); + | +++++ error: aborting due to 6 previous errors diff --git a/tests/ui/modules/issue-56411.stderr b/tests/ui/modules/issue-56411.stderr index 6732a8a3d7324..5632e76138496 100644 --- a/tests/ui/modules/issue-56411.stderr +++ b/tests/ui/modules/issue-56411.stderr @@ -4,16 +4,17 @@ error[E0255]: the name `issue_56411_aux` is defined multiple times LL | mod $name; | ---------- previous definition of the module `issue_56411_aux` here LL | pub use self::$name; - | ^^^^^^^^^^^ - | | - | `issue_56411_aux` reimported here - | you can use `as` to change the binding name of the import + | ^^^^^^^^^^^ `issue_56411_aux` reimported here ... LL | import!(("issue-56411-aux.rs", issue_56411_aux)); | ------------------------------------------------ in this macro invocation | = note: `issue_56411_aux` must be defined only once in the type namespace of this module = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info) +help: you can use `as` to change the binding name of the import + | +LL | pub use self::$name as other_issue_56411_aux; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0365]: `issue_56411_aux` is only public within the crate, and cannot be re-exported outside --> $DIR/issue-56411.rs:6:21 diff --git a/tests/ui/proc-macro/input-interpolated.stdout b/tests/ui/proc-macro/input-interpolated.stdout index 1bccd8806be91..ea535309015c5 100644 --- a/tests/ui/proc-macro/input-interpolated.stdout +++ b/tests/ui/proc-macro/input-interpolated.stdout @@ -5,7 +5,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: #0 bytes(506..507), }, ] -PRINT-ATTR INPUT (DISPLAY): const A : u8 = 0; +PRINT-ATTR INPUT (DISPLAY): const A: u8 = 0; +PRINT-ATTR RE-COLLECTED (DISPLAY): const A : u8 = 0; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "const", @@ -13,7 +14,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ }, Ident { ident: "A", - span: #0 bytes(506..507), + span: #0 bytes(425..427), }, Punct { ch: ':', @@ -41,7 +42,8 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: #3 bytes(435..436), }, ] -PRINT-DERIVE INPUT (DISPLAY): struct A {} +PRINT-DERIVE INPUT (DISPLAY): struct A{} +PRINT-DERIVE RE-COLLECTED (DISPLAY): struct A {} PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -49,7 +51,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ }, Ident { ident: "A", - span: #0 bytes(506..507), + span: #0 bytes(478..480), }, Group { delimiter: Brace, diff --git a/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.rs b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.rs index cc66b5fd6f2b8..ba9f9227aac8e 100644 --- a/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.rs +++ b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.rs @@ -71,12 +71,12 @@ macro_rules! nested2_tt_args_in_first_macro { // instead of the enum variant macro_rules! nested1_ident_args_in_first_macro { () => (nested2_ident_args_in_first_macro!(i32, u32)); + //~^ ERROR type arguments are not allowed on this type } macro_rules! nested2_ident_args_in_first_macro { ($arg1:ident, $arg2:ident) => (if let EnumUnit::VariantB::<$arg1, $arg2> {} - //~^ ERROR type arguments are not allowed on this type - //~| ERROR mismatched types + //~^ ERROR mismatched types = 5 { true } else { false }); } diff --git a/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr index cb7666657ef4a..9e18830cfa3eb 100644 --- a/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr +++ b/tests/ui/typeck/issue-116473-ice-wrong-span-variant-args.stderr @@ -173,18 +173,19 @@ LL | nested1_tt_args_in_first_macro!(); = note: this error originates in the macro `nested2_tt_args_in_first_macro` which comes from the expansion of the macro `nested1_tt_args_in_first_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0109]: type arguments are not allowed on this type - --> $DIR/issue-116473-ice-wrong-span-variant-args.rs:77:64 + --> $DIR/issue-116473-ice-wrong-span-variant-args.rs:73:47 | +LL | () => (nested2_ident_args_in_first_macro!(i32, u32)); + | ^^^ ^^^ type argument not allowed +... LL | ($arg1:ident, $arg2:ident) => (if let EnumUnit::VariantB::<$arg1, $arg2> {} - | -------- ^^^^^ ^^^^^ type argument not allowed - | | - | not allowed on this type + | -------- not allowed on this type ... LL | nested1_ident_args_in_first_macro!(); | ------------------------------------ in this macro invocation | = note: enum variants can't have type parameters - = note: this error originates in the macro `nested2_ident_args_in_first_macro` which comes from the expansion of the macro `nested1_ident_args_in_first_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `nested1_ident_args_in_first_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might have meant to specify type parameters on enum `Enum` | LL - ($arg1:ident, $arg2:ident) => (if let EnumUnit::VariantB::<$arg1, $arg2> {} @@ -192,11 +193,11 @@ LL + ($arg1:ident, $arg2:ident) => (if let EnumUnit::<$arg1, $arg2>::Variant | error[E0308]: mismatched types - --> $DIR/issue-116473-ice-wrong-span-variant-args.rs:77:43 + --> $DIR/issue-116473-ice-wrong-span-variant-args.rs:78:43 | LL | ($arg1:ident, $arg2:ident) => (if let EnumUnit::VariantB::<$arg1, $arg2> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected integer, found `Enum<(), ()>` -... +LL | LL | = 5 { true } else { false }); | - this expression has type `{integer}` ...