From 52ae740c6b7fae9fba26236e319315d873a142c8 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Wed, 19 Nov 2025 10:52:23 -0800 Subject: [PATCH 01/17] Ranged subspan helper --- compiler/rustc_span/src/lib.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 2e03ccb1aa1a3..72631f1050ee6 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -77,7 +77,7 @@ use std::cmp::{self, Ordering}; use std::fmt::Display; use std::hash::Hash; use std::io::{self, Read}; -use std::ops::{Add, Range, Sub}; +use std::ops::{Add, Bound, Range, RangeBounds, Sub}; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; @@ -1176,6 +1176,37 @@ impl Span { pub fn normalize_to_macro_rules(self) -> Span { self.map_ctxt(|ctxt| ctxt.normalize_to_macro_rules()) } + + /// This function is similar to `Span::from_inner`, but it + /// will return `None` if the relative Range span exceeds + /// the bounds of span. + pub fn subspan>(self, subspan: R) -> Option + where + u32: TryFrom, + { + let lo = self.lo().0; + let hi = self.hi().0; + + let start = match subspan.start_bound() { + Bound::Included(s) => u32::try_from(*s).ok()?, + Bound::Excluded(s) => u32::try_from(*s).ok()?.checked_add(1)?, + Bound::Unbounded => 0, + }; + + let end = match subspan.end_bound() { + Bound::Included(e) => u32::try_from(*e).ok()?.checked_add(1)?, + Bound::Excluded(e) => u32::try_from(*e).ok()?, + Bound::Unbounded => hi - lo, + }; + + let new_lo = lo.checked_add(start)?; + let new_hi = lo.checked_add(end)?; + if new_lo > hi || new_hi > hi { + return None; + } + + Some(self.with_lo(BytePos(new_lo)).with_hi(BytePos(new_hi))) + } } impl Default for Span { From 3cb83cfd2b2d2c6ae9cd2f3b1db8ac1c673c830b Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Wed, 19 Nov 2025 10:52:53 -0800 Subject: [PATCH 02/17] Smarter for DelimSpan::from_single --- compiler/rustc_ast/src/tokenstream.rs | 49 ++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 4111182c3b7dc..055b32de45cbe 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -978,7 +978,54 @@ pub struct DelimSpan { impl DelimSpan { pub fn from_single(sp: Span) -> Self { - DelimSpan { open: sp, close: sp } + let default_open = sp.shrink_to_lo(); + let default_close = sp.shrink_to_hi(); + + let Some(sm) = rustc_span::source_map::get_source_map() else { + // No source map available. + return Self { open: default_open, close: default_close }; + }; + + let (open, close) = sm + .span_to_source(sp, |src, start, end| { + let Some(src) = src.get(start..end) else { + return Ok((default_close, default_close)); + }; + + // Only check the first and last characters. + // If there is white space or other characters + // other than `( ... )`, `[ ... ]`, and `{ ... }`. + // I assume that is intentionally included in this + // span so we don't want to shrink the span by + // searching for the delimiters, and setting + // the open and close spans to some more interior + // position. + let mut chars = src.chars(); + // just using '_' as a place holder. + let first = chars.next().unwrap_or('_'); + let last = chars.last().unwrap_or('_'); + + // Thought maybe scan through if first is '(', '[', or '{' + // and see if the last matches up e.g. make sure it's not some + // extra mismatched delimiter. + + let open = sp.subspan(0..first.len_utf8()).unwrap_or(default_open); + + let len = (sp.hi() - sp.lo()).0 as usize; + let pos = len.checked_sub(last.len_utf8()).unwrap_or(0); + let close = sp.subspan(pos..).unwrap_or(default_close); + + Ok(match (first, last) { + ('(', ')') | ('{', '}') | ('[', ']') => (open, close), + ('(', _) | ('{', _) | ('[', _) => (open, default_close), + (_, ')') | (_, '}') | (_, ']') => (default_open, close), + (_, _) => (default_close, default_open), + }) + }) + .ok() + .unwrap_or((default_open, default_close)); + + DelimSpan { open, close } } pub fn from_pair(open: Span, close: Span) -> Self { From e71d104b3b3917e574f04f5f8b76295bcc1a2c1c Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Wed, 19 Nov 2025 12:42:02 -0800 Subject: [PATCH 03/17] Update Failing UI tests, but I would not call these fixed this is a test to see how the dianostics change. I would say a lot these are cause by using DelimSpan::open or DelimSpan::close instead of Delimspan::entire when looking at the diffs. --- .../attributes/nonterminal-expansion.stderr | 4 +-- .../span-semicolon-issue-139049.stderr | 4 +-- .../cfg-attr-syntax-validation.stderr | 4 +-- .../cfg_attr-attr-syntax-validation.stderr | 4 +-- tests/ui/did_you_mean/bad-assoc-expr.stderr | 6 ++-- tests/ui/did_you_mean/bad-assoc-pat.stderr | 6 ++-- .../bad-assoc-ty.edition2015.stderr | 6 ++-- .../bad-assoc-ty.edition2021.stderr | 6 ++-- ...pats-inclusive-dotdotdot-bad-syntax.stderr | 2 +- ...lf-open-range-pats-inclusive-no-end.stderr | 8 ++--- tests/ui/imports/import-prefix-macro-2.stderr | 4 +-- .../lint/lint-double-negations-macro.stderr | 6 ++-- tests/ui/lint/unreachable_pub.stderr | 4 +-- tests/ui/macros/issue-29084.stderr | 2 +- tests/ui/macros/macro-interpolation.stderr | 4 +-- tests/ui/macros/nonterminal-matching.stderr | 24 +++++++-------- tests/ui/macros/syntax-error-recovery.stderr | 8 ++--- tests/ui/macros/trace_faulty_macros.stderr | 8 ++--- .../parser/attribute/attr-bad-meta-4.stderr | 4 +-- ...-trailing-outer-attribute-in-body-2.stderr | 8 ++--- tests/ui/parser/bad-interpolated-block.stderr | 24 +++++++-------- .../ui/parser/float-field-interpolated.stderr | 16 +++++----- ...sue-65122-mac-invoc-in-mut-patterns.stderr | 4 +-- .../ui/parser/issues/issue-87812-path.stderr | 4 +-- tests/ui/parser/issues/issue-87812.stderr | 4 +-- tests/ui/parser/labeled-no-colon-expr.stderr | 13 ++++---- .../break-in-unlabeled-block-in-macro.stderr | 4 +-- tests/ui/parser/macro/issue-37113.stderr | 4 +-- .../parser/macro/macro-doc-comments-2.stderr | 7 ++--- .../parser/macro/trait-non-item-macros.stderr | 4 +-- tests/ui/parser/mut-patterns.stderr | 4 +-- .../parser/recover/recover-range-pats.stderr | 30 +++++++++---------- .../ui/tuple/tuple-struct-fields/test2.stderr | 6 ++-- 33 files changed, 122 insertions(+), 124 deletions(-) diff --git a/tests/ui/attributes/nonterminal-expansion.stderr b/tests/ui/attributes/nonterminal-expansion.stderr index 21912de210610..c16c5257e442d 100644 --- a/tests/ui/attributes/nonterminal-expansion.stderr +++ b/tests/ui/attributes/nonterminal-expansion.stderr @@ -1,8 +1,8 @@ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/nonterminal-expansion.rs:7:22 + --> $DIR/nonterminal-expansion.rs:7:24 | LL | #[repr(align($n))] - | ^^ + | ^ ... LL | pass_nonterminal!(n!()); | ----------------------- in this macro invocation diff --git a/tests/ui/borrowck/span-semicolon-issue-139049.stderr b/tests/ui/borrowck/span-semicolon-issue-139049.stderr index 8d2de67382bd8..0d800baf4a53f 100644 --- a/tests/ui/borrowck/span-semicolon-issue-139049.stderr +++ b/tests/ui/borrowck/span-semicolon-issue-139049.stderr @@ -2,7 +2,7 @@ error[E0597]: `l` does not live long enough --> $DIR/span-semicolon-issue-139049.rs:11:41 | LL | macro_rules! perform { ($e:expr) => { D(&$e).end() } } - | --^^^- + | --^--- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... @@ -24,7 +24,7 @@ error[E0597]: `l` does not live long enough --> $DIR/span-semicolon-issue-139049.rs:11:41 | LL | macro_rules! perform { ($e:expr) => { D(&$e).end() } } - | --^^^- + | --^--- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr index e73b20f2d5d31..0061be11d47bb 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr @@ -92,10 +92,10 @@ LL | #[cfg(a = b"hi")] = note: expected a normal string literal, not a byte string literal error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/cfg-attr-syntax-validation.rs:51:25 + --> $DIR/cfg-attr-syntax-validation.rs:51:30 | LL | #[cfg(feature = $expr)] - | ^^^^^ + | ^ ... LL | generate_s10!(concat!("nonexistent")); | ------------------------------------- in this macro invocation diff --git a/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr index fd03fa62864af..e8d55ba56a13a 100644 --- a/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr @@ -92,10 +92,10 @@ LL | #[cfg_attr(true)] = note: for more information, visit error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/cfg_attr-attr-syntax-validation.rs:30:30 + --> $DIR/cfg_attr-attr-syntax-validation.rs:30:35 | LL | #[cfg_attr(feature = $expr)] - | ---------------------^^^^^-- help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | --------------------------^- help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` ... LL | generate_s10!(concat!("nonexistent")); | ------------------------------------- in this macro invocation diff --git a/tests/ui/did_you_mean/bad-assoc-expr.stderr b/tests/ui/did_you_mean/bad-assoc-expr.stderr index b83078e21b6a1..5f9e85d557c74 100644 --- a/tests/ui/did_you_mean/bad-assoc-expr.stderr +++ b/tests/ui/did_you_mean/bad-assoc-expr.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:23:19 | LL | ($ty: ty) => ($ty::clone(&0)) - | ^^^ + | ^ ... LL | expr!(u8); | --------- in this macro invocation @@ -98,8 +98,8 @@ LL | expr!(u8); = note: this error originates in the macro `expr` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<$ty>::clone(&0)) - | + + +LL | ($ty: ty) => (<>$ty::clone(&0)) + | ++ error: aborting due to 9 previous errors diff --git a/tests/ui/did_you_mean/bad-assoc-pat.stderr b/tests/ui/did_you_mean/bad-assoc-pat.stderr index 8bdeb8ffdd0a8..6e29eca04d639 100644 --- a/tests/ui/did_you_mean/bad-assoc-pat.stderr +++ b/tests/ui/did_you_mean/bad-assoc-pat.stderr @@ -57,7 +57,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:21:19 | LL | ($ty: ty) => ($ty::AssocItem) - | ^^^ + | ^ ... LL | pat!(u8) => {} | -------- in this macro invocation @@ -65,8 +65,8 @@ LL | pat!(u8) => {} = note: this error originates in the macro `pat` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<$ty>::AssocItem) - | + + +LL | ($ty: ty) => (<>$ty::AssocItem) + | ++ error[E0599]: no associated item named `AssocItem` found for slice `[u8]` in the current scope --> $DIR/bad-assoc-pat.rs:3:15 diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr index af0a9d064d571..b68b24ad220c5 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); - | ^^^ + | ^ ... LL | type J = ty!(u8); | ------- in this macro invocation @@ -98,8 +98,8 @@ LL | type J = ty!(u8); = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<$ty>::AssocTy); - | + + +LL | ($ty: ty) => (<>$ty::AssocTy); + | ++ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:5:10 diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr index 2ee8ab2760a92..c88a16a72894d 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); - | ^^^ + | ^ ... LL | type J = ty!(u8); | ------- in this macro invocation @@ -98,8 +98,8 @@ LL | type J = ty!(u8); = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<$ty>::AssocTy); - | + + +LL | ($ty: ty) => (<>$ty::AssocTy); + | ++ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:5:10 diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr index ec0e09a302ea1..85daf49016edf 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr @@ -66,7 +66,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:25:17 | LL | let ...$e; - | ^^^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr index 63258f3538313..956ef9fccba1a 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr @@ -85,10 +85,10 @@ LL + let $e..; | error[E0005]: refutable pattern in local binding - --> $DIR/half-open-range-pats-inclusive-no-end.rs:18:17 + --> $DIR/half-open-range-pats-inclusive-no-end.rs:18:19 | LL | let $e...; - | ^^^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -99,10 +99,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/half-open-range-pats-inclusive-no-end.rs:20:17 + --> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19 | LL | let $e..=; - | ^^^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/imports/import-prefix-macro-2.stderr b/tests/ui/imports/import-prefix-macro-2.stderr index fbeca99b13800..fb682e9268564 100644 --- a/tests/ui/imports/import-prefix-macro-2.stderr +++ b/tests/ui/imports/import-prefix-macro-2.stderr @@ -1,8 +1,8 @@ error: expected identifier, found metavariable - --> $DIR/import-prefix-macro-2.rs:11:26 + --> $DIR/import-prefix-macro-2.rs:11:28 | LL | ($p: path) => (use ::$p {S, Z}); - | ^^ expected identifier, found metavariable + | ^ expected identifier, found metavariable ... LL | import! { a::b::c } | ------------------- in this macro invocation diff --git a/tests/ui/lint/lint-double-negations-macro.stderr b/tests/ui/lint/lint-double-negations-macro.stderr index d6ac9be48f304..a8fc0850e21e9 100644 --- a/tests/ui/lint/lint-double-negations-macro.stderr +++ b/tests/ui/lint/lint-double-negations-macro.stderr @@ -2,7 +2,7 @@ warning: use of a double negation --> $DIR/lint-double-negations-macro.rs:9:9 | LL | --$e - | ^^^^ + | ^^ ... LL | bad_macro!(1); | ------------- in this macro invocation @@ -13,8 +13,8 @@ LL | bad_macro!(1); = note: this warning originates in the macro `bad_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: add parentheses for clarity | -LL | -(-$e) - | + + +LL | -(-)$e + | + + warning: 1 warning emitted diff --git a/tests/ui/lint/unreachable_pub.stderr b/tests/ui/lint/unreachable_pub.stderr index 5173ff1f0264d..30d696816624b 100644 --- a/tests/ui/lint/unreachable_pub.stderr +++ b/tests/ui/lint/unreachable_pub.stderr @@ -112,10 +112,10 @@ LL | pub type Oxygen = bool; = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:44:47 + --> $DIR/unreachable_pub.rs:44:58 | LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ ... LL | define_empty_struct_with_visibility!(pub, Fluorine); | --------------------------------------------------- diff --git a/tests/ui/macros/issue-29084.stderr b/tests/ui/macros/issue-29084.stderr index 6e7474c5b3f74..b7faedae5f249 100644 --- a/tests/ui/macros/issue-29084.stderr +++ b/tests/ui/macros/issue-29084.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-29084.rs:6:13 | LL | bar(&mut $d); - | --- ^^^^^^^ expected `u8`, found `&mut u8` + | --- ^^^^^ expected `u8`, found `&mut u8` | | | arguments to this function are incorrect ... diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr index bc24a15861295..f4164555906ee 100644 --- a/tests/ui/macros/macro-interpolation.stderr +++ b/tests/ui/macros/macro-interpolation.stderr @@ -1,8 +1,8 @@ error: expected identifier, found metavariable - --> $DIR/macro-interpolation.rs:21:19 + --> $DIR/macro-interpolation.rs:21:25 | LL | <$type as $trait>::$name - | ^^^^^^ expected identifier, found metavariable + | ^ expected identifier, found metavariable ... LL | let _: qpath!(ty, ::Owned); | ----------------------------- diff --git a/tests/ui/macros/nonterminal-matching.stderr b/tests/ui/macros/nonterminal-matching.stderr index d01561415664c..cb24b046f0ec0 100644 --- a/tests/ui/macros/nonterminal-matching.stderr +++ b/tests/ui/macros/nonterminal-matching.stderr @@ -1,20 +1,20 @@ error: no rules expected `item` metavariable - --> $DIR/nonterminal-matching.rs:19:10 + --> $DIR/nonterminal-matching.rs:19:18 | LL | macro n(a $nt_item b) { | --------------------- when calling this macro ... LL | n!(a $nt_item b); - | ^^^^^^^^ no rules expected this token in macro call + | ^ no rules expected this token in macro call ... LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation | note: while trying to match `item` metavariable - --> $DIR/nonterminal-matching.rs:15:15 + --> $DIR/nonterminal-matching.rs:15:23 | LL | macro n(a $nt_item b) { - | ^^^^^^^^ + | ^ ... LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation @@ -24,10 +24,10 @@ LL | complex_nonterminal!(enum E {}); = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `expr` metavariable - --> $DIR/nonterminal-matching.rs:32:35 + --> $DIR/nonterminal-matching.rs:32:37 | LL | (expr $x:expr) => { bar!(expr $x); }; - | ^^ no rules expected this token in macro call + | ^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -46,10 +46,10 @@ LL | (expr 3) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `literal` metavariable - --> $DIR/nonterminal-matching.rs:33:44 + --> $DIR/nonterminal-matching.rs:33:46 | LL | (literal $x:literal) => { bar!(literal $x); }; - | ^^ no rules expected this token in macro call + | ^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -68,10 +68,10 @@ LL | (literal 4) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `path` metavariable - --> $DIR/nonterminal-matching.rs:34:35 + --> $DIR/nonterminal-matching.rs:34:37 | LL | (path $x:path) => { bar!(path $x); }; - | ^^ no rules expected this token in macro call + | ^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -90,10 +90,10 @@ LL | (path a::b::c) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `stmt` metavariable - --> $DIR/nonterminal-matching.rs:35:35 + --> $DIR/nonterminal-matching.rs:35:37 | LL | (stmt $x:stmt) => { bar!(stmt $x); }; - | ^^ no rules expected this token in macro call + | ^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro diff --git a/tests/ui/macros/syntax-error-recovery.stderr b/tests/ui/macros/syntax-error-recovery.stderr index a2059aa1aa802..869a050eb8775 100644 --- a/tests/ui/macros/syntax-error-recovery.stderr +++ b/tests/ui/macros/syntax-error-recovery.stderr @@ -1,8 +1,8 @@ error: expected one of `(`, `,`, `=`, `{`, or `}`, found `ty` metavariable - --> $DIR/syntax-error-recovery.rs:7:26 + --> $DIR/syntax-error-recovery.rs:7:32 | LL | $token $($inner)? = $value, - | ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}` + | ^ expected one of `(`, `,`, `=`, `{`, or `}` ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation @@ -11,10 +11,10 @@ LL | values!(STRING(1) as (String) => cfg(test),); = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores `ty` metavariable and any tokens following - --> $DIR/syntax-error-recovery.rs:7:26 + --> $DIR/syntax-error-recovery.rs:7:32 | LL | $token $($inner)? = $value, - | ^^^^^^ + | ^ ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- caused by the macro expansion here diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index e90d7a98db4c7..c459c6743612b 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -51,10 +51,10 @@ LL | my_recursive_macro!(); = note: to `my_recursive_macro! ();` error: expected expression, found `pat` metavariable - --> $DIR/trace_faulty_macros.rs:16:9 + --> $DIR/trace_faulty_macros.rs:16:11 | LL | $a - | ^^ expected expression + | ^ expected expression ... LL | let a = pat_macro!(); | ------------ in this macro invocation @@ -70,10 +70,10 @@ LL | fn use_derive_macro_as_attr() {} | -------------------------------- not a `struct`, `enum` or `union` error: expected expression, found `pat` metavariable - --> $DIR/trace_faulty_macros.rs:49:37 + --> $DIR/trace_faulty_macros.rs:49:39 | LL | (($p:pat, $e:pat)) => {let $p = $e;}; - | ^^ expected expression + | ^ expected expression ... LL | test!(let x = 1+1); | ------------------ in this macro invocation diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.stderr b/tests/ui/parser/attribute/attr-bad-meta-4.stderr index 1d939942fb9a9..50d1d890c39c6 100644 --- a/tests/ui/parser/attribute/attr-bad-meta-4.stderr +++ b/tests/ui/parser/attribute/attr-bad-meta-4.stderr @@ -11,10 +11,10 @@ LL + #[cfg(feature = 1)] | error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable - --> $DIR/attr-bad-meta-4.rs:3:15 + --> $DIR/attr-bad-meta-4.rs:3:25 | LL | #[cfg($attr_item)] - | ^^^^^^^^^^ + | ^ ... LL | mac!(an(arbitrary token stream)); | -------------------------------- in this macro invocation diff --git a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr index 41e7b5ab759dd..ba2ebef3e5758 100644 --- a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr +++ b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr @@ -1,10 +1,10 @@ error: expected `;`, found `#` - --> $DIR/properly-recover-from-trailing-outer-attribute-in-body-2.rs:6:13 + --> $DIR/properly-recover-from-trailing-outer-attribute-in-body-2.rs:6:9 | LL | #[cfg()] | -------- only `;` terminated statements or tail expressions are allowed after this attribute LL | $foo - | ^ expected `;` here + | ^ expected `;` here LL | LL | #[cfg(false)] | - unexpected token @@ -15,8 +15,8 @@ LL | the_macro!( (); (); ); = note: this error originates in the macro `the_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: add `;` here | -LL | $foo; - | + +LL | ;$foo + | + help: alternatively, consider surrounding the expression with a block | LL | the_macro!( { () }; (); ); diff --git a/tests/ui/parser/bad-interpolated-block.stderr b/tests/ui/parser/bad-interpolated-block.stderr index 651036c51c948..a9b323395cd12 100644 --- a/tests/ui/parser/bad-interpolated-block.stderr +++ b/tests/ui/parser/bad-interpolated-block.stderr @@ -1,8 +1,8 @@ error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:5:15 + --> $DIR/bad-interpolated-block.rs:5:17 | LL | 'lab: $b; - | ------^^ + | --------^ | | | the `block` fragment is within this context ... @@ -12,14 +12,14 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | 'lab: { $b }; - | + + +LL | 'lab: $b{ }; + | + + error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:6:16 + --> $DIR/bad-interpolated-block.rs:6:18 | LL | unsafe $b; - | -------^^ + | ---------^ | | | the `block` fragment is within this context ... @@ -29,14 +29,14 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | unsafe { $b }; - | + + +LL | unsafe $b{ }; + | + + error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:7:23 + --> $DIR/bad-interpolated-block.rs:7:25 | LL | |x: u8| -> () $b; - | ^^ the `block` fragment is within this context + | ^ the `block` fragment is within this context ... LL | m!({}); | ------ in this macro invocation @@ -44,8 +44,8 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | |x: u8| -> () { $b }; - | + + +LL | |x: u8| -> () $b{ }; + | + + error: aborting due to 3 previous errors diff --git a/tests/ui/parser/float-field-interpolated.stderr b/tests/ui/parser/float-field-interpolated.stderr index e2b7e3a7dbe75..0b403f2aac94d 100644 --- a/tests/ui/parser/float-field-interpolated.stderr +++ b/tests/ui/parser/float-field-interpolated.stderr @@ -1,8 +1,8 @@ error: unexpected token: `literal` metavariable - --> $DIR/float-field-interpolated.rs:8:13 + --> $DIR/float-field-interpolated.rs:8:15 | LL | { s.$b; } - | ^^ + | ^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -10,10 +10,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `.`, `;`, `?`, `}`, or an operator, found `literal` metavariable - --> $DIR/float-field-interpolated.rs:8:13 + --> $DIR/float-field-interpolated.rs:8:15 | LL | { s.$b; } - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -21,10 +21,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: unexpected token: `expr` metavariable - --> $DIR/float-field-interpolated.rs:10:13 + --> $DIR/float-field-interpolated.rs:10:15 | LL | { s.$c; } - | ^^ + | ^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -32,10 +32,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `.`, `;`, `?`, `}`, or an operator, found `expr` metavariable - --> $DIR/float-field-interpolated.rs:10:13 + --> $DIR/float-field-interpolated.rs:10:15 | LL | { s.$c; } - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation diff --git a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr index 59e1b64686b46..5501ff584bb54 100644 --- a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr +++ b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr @@ -16,10 +16,10 @@ LL + let $eval = (); | error: expected identifier, found metavariable - --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17 + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:22 | LL | let mut $eval = (); - | ^^^^^ expected identifier, found metavariable + | ^ expected identifier, found metavariable ... LL | mac2! { does_not_exist!() } | --------------------------- in this macro invocation diff --git a/tests/ui/parser/issues/issue-87812-path.stderr b/tests/ui/parser/issues/issue-87812-path.stderr index fbe26ea39595a..2fe205e30171a 100644 --- a/tests/ui/parser/issues/issue-87812-path.stderr +++ b/tests/ui/parser/issues/issue-87812-path.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/issue-87812-path.rs:3:24 + --> $DIR/issue-87812-path.rs:3:26 | LL | let _: usize = $f; - | ----- ^^ expected `usize`, found `Baz` + | ----- ^ expected `usize`, found `Baz` | | | expected due to this ... diff --git a/tests/ui/parser/issues/issue-87812.stderr b/tests/ui/parser/issues/issue-87812.stderr index 35dc66a528a99..362116730f087 100644 --- a/tests/ui/parser/issues/issue-87812.stderr +++ b/tests/ui/parser/issues/issue-87812.stderr @@ -15,8 +15,8 @@ LL | #![deny(break_with_label_and_loop)] = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this expression in parentheses | -LL | break '_l ($f); - | + + +LL | break '_l $f(); + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/parser/labeled-no-colon-expr.stderr b/tests/ui/parser/labeled-no-colon-expr.stderr index 2478319281569..4f8d1f69636a0 100644 --- a/tests/ui/parser/labeled-no-colon-expr.stderr +++ b/tests/ui/parser/labeled-no-colon-expr.stderr @@ -81,10 +81,10 @@ LL | 'l4: 0; | + error: cannot use a `block` macro fragment here - --> $DIR/labeled-no-colon-expr.rs:11:17 + --> $DIR/labeled-no-colon-expr.rs:11:19 | LL | 'l5 $b; - | ----^^ + | ------^ | | | the `block` fragment is within this context ... @@ -94,8 +94,8 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | 'l5 { $b }; - | + + +LL | 'l5 $b{ }; + | + + error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:14:8 @@ -109,8 +109,9 @@ LL | m!({}); = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them help: add `:` after the label | -LL | 'l5: $b; - | + +LL - 'l5 $b; +LL + 'l5: ; + | error: aborting due to 8 previous errors diff --git a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr index 2f46cb36750be..72e97514350b6 100644 --- a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr +++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr @@ -13,7 +13,7 @@ error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-in-unlabeled-block-in-macro.rs:6:9 | LL | break $e; - | ^^^^^^^^ cannot `break` outside of a loop or labeled block + | ^^^^^^ cannot `break` outside of a loop or labeled block ... LL | foo!(()); | -------- in this macro invocation @@ -41,7 +41,7 @@ error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-in-unlabeled-block-in-macro.rs:12:11 | LL | { break $e; } - | ^^^^^^^^ cannot `break` outside of a loop or labeled block + | ^^^^^^ cannot `break` outside of a loop or labeled block ... LL | foo!(@ ()); | ---------- in this macro invocation diff --git a/tests/ui/parser/macro/issue-37113.stderr b/tests/ui/parser/macro/issue-37113.stderr index 560329df5ccbd..e073d55f23bd7 100644 --- a/tests/ui/parser/macro/issue-37113.stderr +++ b/tests/ui/parser/macro/issue-37113.stderr @@ -1,10 +1,10 @@ error: expected identifier, found metavariable - --> $DIR/issue-37113.rs:4:16 + --> $DIR/issue-37113.rs:4:18 | LL | enum SomeEnum { | -------- while parsing this enum LL | $( $t, )* - | ^^ expected identifier, found metavariable + | ^ expected identifier, found metavariable ... LL | test_macro!(String,); | -------------------- in this macro invocation diff --git a/tests/ui/parser/macro/macro-doc-comments-2.stderr b/tests/ui/parser/macro/macro-doc-comments-2.stderr index 02c12bf959114..f29fab1e8800d 100644 --- a/tests/ui/parser/macro/macro-doc-comments-2.stderr +++ b/tests/ui/parser/macro/macro-doc-comments-2.stderr @@ -1,14 +1,11 @@ error: no rules expected `[` - --> $DIR/macro-doc-comments-2.rs:6:5 + --> $DIR/macro-doc-comments-2.rs:6:14 | LL | macro_rules! inner { | ------------------ when calling this macro ... LL | /// Outer - | ^^^^^^^^^ - | | - | no rules expected this token in macro call - | outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match + | ^ no rules expected this token in macro call | note: while trying to match `!` --> $DIR/macro-doc-comments-2.rs:2:7 diff --git a/tests/ui/parser/macro/trait-non-item-macros.stderr b/tests/ui/parser/macro/trait-non-item-macros.stderr index 62b42fa8b8dd7..3b5e694c2ab56 100644 --- a/tests/ui/parser/macro/trait-non-item-macros.stderr +++ b/tests/ui/parser/macro/trait-non-item-macros.stderr @@ -1,8 +1,8 @@ error: macro expansion ignores `expr` metavariable and any tokens following - --> $DIR/trait-non-item-macros.rs:3:9 + --> $DIR/trait-non-item-macros.rs:3:11 | LL | $a - | ^^ + | ^ ... LL | bah!(2); | ------- caused by the macro expansion here diff --git a/tests/ui/parser/mut-patterns.stderr b/tests/ui/parser/mut-patterns.stderr index 70099989c9ff0..29ba6e3336e23 100644 --- a/tests/ui/parser/mut-patterns.stderr +++ b/tests/ui/parser/mut-patterns.stderr @@ -159,10 +159,10 @@ LL + let W(mut a, W(mut b, W(ref c, W(mut d, B { box mut f })))) | error: expected identifier, found metavariable - --> $DIR/mut-patterns.rs:49:21 + --> $DIR/mut-patterns.rs:49:23 | LL | let mut $p = 0; - | ^^ expected identifier, found metavariable + | ^ expected identifier, found metavariable ... LL | foo!(x); | ------- in this macro invocation diff --git a/tests/ui/parser/recover/recover-range-pats.stderr b/tests/ui/parser/recover/recover-range-pats.stderr index 1570475a0989b..7e0dd1c8979d0 100644 --- a/tests/ui/parser/recover/recover-range-pats.stderr +++ b/tests/ui/parser/recover/recover-range-pats.stderr @@ -609,10 +609,10 @@ LL | if let ....3 = 0 {} | expected integer, found floating-point number error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:135:17 + --> $DIR/recover-range-pats.rs:135:20 | LL | let $e1..$e2; - | ^^^^^^^^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -623,10 +623,10 @@ LL | mac2!(0, 1); = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:137:17 + --> $DIR/recover-range-pats.rs:137:20 | LL | let $e1...$e2; - | ^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered + | ^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -637,10 +637,10 @@ LL | mac2!(0, 1); = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:141:17 + --> $DIR/recover-range-pats.rs:141:20 | LL | let $e1..=$e2; - | ^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered + | ^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -654,7 +654,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:150:17 | LL | let ..$e; - | ^^^^ pattern `0_i32..=i32::MAX` not covered + | ^^ pattern `0_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -668,7 +668,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:152:17 | LL | let ...$e; - | ^^^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -682,7 +682,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:155:17 | LL | let ..=$e; - | ^^^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -693,10 +693,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:157:17 + --> $DIR/recover-range-pats.rs:157:19 | LL | let $e..; - | ^^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -707,10 +707,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:159:17 + --> $DIR/recover-range-pats.rs:159:19 | LL | let $e...; - | ^^^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -721,10 +721,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:161:17 + --> $DIR/recover-range-pats.rs:161:19 | LL | let $e..=; - | ^^^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/tuple/tuple-struct-fields/test2.stderr b/tests/ui/tuple/tuple-struct-fields/test2.stderr index 784411aba8f8a..b658b8856d178 100644 --- a/tests/ui/tuple/tuple-struct-fields/test2.stderr +++ b/tests/ui/tuple/tuple-struct-fields/test2.stderr @@ -2,9 +2,9 @@ error: expected one of `)` or `,`, found `(` --> $DIR/test2.rs:5:26 | LL | struct S3(pub $t ()); - | -^ expected one of `)` or `,` - | | - | help: missing `,` + | - ^ expected one of `)` or `,` + | | + | help: missing `,` ... LL | define_struct! { (foo) } | ------------------------ in this macro invocation From e995f8e70278c08b438c87cb1746186fd7c3e120 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Wed, 19 Nov 2025 12:42:54 -0800 Subject: [PATCH 04/17] Don't like this at all but just changing so tests pass to test output. --- .../closure-body-macro-fragment.fixed | 33 ------------------- .../migrations/closure-body-macro-fragment.rs | 2 -- .../closure-body-macro-fragment.stderr | 10 +++--- 3 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed deleted file mode 100644 index e9e16ce951b24..0000000000000 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed +++ /dev/null @@ -1,33 +0,0 @@ -//@ run-rustfix -//@ edition:2018 -//@ check-pass -#![warn(rust_2021_compatibility)] - -#[derive(Debug)] -struct Foo(i32); -impl Drop for Foo { - fn drop(&mut self) { - println!("{:?} dropped", self.0); - } -} - -macro_rules! m { - (@ $body:expr) => {{ - let f = || $body; - //~^ WARNING: drop order - f(); - }}; - ($body:block) => {{ - m!(@ $body); - }}; -} - -fn main() { - let a = (Foo(0), Foo(1)); - m!({ - let _ = &a; - //~^ HELP: add a dummy - let x = a.0; - println!("{:?}", x); - }); -} diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs index 0cb5351f595e0..4ec17ca69e123 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs @@ -1,4 +1,3 @@ -//@ run-rustfix //@ edition:2018 //@ check-pass #![warn(rust_2021_compatibility)] @@ -25,7 +24,6 @@ macro_rules! m { fn main() { let a = (Foo(0), Foo(1)); m!({ - //~^ HELP: add a dummy let x = a.0; println!("{:?}", x); }); diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr index c49b1d2d0e069..5bc5a0244e146 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr @@ -1,5 +1,5 @@ warning: changes to closure capture in Rust 2021 will affect drop order - --> $DIR/closure-body-macro-fragment.rs:16:17 + --> $DIR/closure-body-macro-fragment.rs:15:17 | LL | let f = || $body; | ^^ @@ -8,7 +8,6 @@ LL | }}; | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure ... LL | / m!({ -LL | | LL | | let x = a.0; | | --- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0` LL | | println!("{:?}", x); @@ -17,7 +16,7 @@ LL | | }); | = note: for more information, see note: the lint level is defined here - --> $DIR/closure-body-macro-fragment.rs:4:9 + --> $DIR/closure-body-macro-fragment.rs:3:9 | LL | #![warn(rust_2021_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,9 +24,8 @@ LL | #![warn(rust_2021_compatibility)] = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: add a dummy let to cause `a` to be fully captured | -LL ~ m!({ -LL + let _ = &a; - | +LL | m!(@ $body{ let _ = &a; }); + | +++++++++++++ + warning: 1 warning emitted From f2819360ead1f76950d1160087f2636c25724cb4 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Wed, 19 Nov 2025 14:22:42 -0800 Subject: [PATCH 05/17] Update uninhabited_references.stderr --- src/tools/clippy/tests/ui/uninhabited_references.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/tests/ui/uninhabited_references.stderr b/src/tools/clippy/tests/ui/uninhabited_references.stderr index ac05ab5bb4d40..120911cc94e4a 100644 --- a/src/tools/clippy/tests/ui/uninhabited_references.stderr +++ b/src/tools/clippy/tests/ui/uninhabited_references.stderr @@ -11,7 +11,7 @@ error: dereferencing a reference to an uninhabited type would be undefined behav --> tests/ui/uninhabited_references.rs:12:30 | LL | fn $name(x: &$ty) -> &$ty { - | ^^^^ + | ^ ... LL | ret_something!(id_never, !); | --------------------------- in this macro invocation From 05774debbecf84883742c2335189cd3071a325f2 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Thu, 20 Nov 2025 17:17:51 -0800 Subject: [PATCH 06/17] Revert "Update Failing UI tests, but I would not call these fixed this is a test to see how the dianostics change." This reverts commit e71d104b3b3917e574f04f5f8b76295bcc1a2c1c. --- .../attributes/nonterminal-expansion.stderr | 4 +-- .../span-semicolon-issue-139049.stderr | 4 +-- .../cfg-attr-syntax-validation.stderr | 4 +-- .../cfg_attr-attr-syntax-validation.stderr | 4 +-- tests/ui/did_you_mean/bad-assoc-expr.stderr | 6 ++-- tests/ui/did_you_mean/bad-assoc-pat.stderr | 6 ++-- .../bad-assoc-ty.edition2015.stderr | 6 ++-- .../bad-assoc-ty.edition2021.stderr | 6 ++-- ...pats-inclusive-dotdotdot-bad-syntax.stderr | 2 +- ...lf-open-range-pats-inclusive-no-end.stderr | 8 ++--- tests/ui/imports/import-prefix-macro-2.stderr | 4 +-- .../lint/lint-double-negations-macro.stderr | 6 ++-- tests/ui/lint/unreachable_pub.stderr | 4 +-- tests/ui/macros/issue-29084.stderr | 2 +- tests/ui/macros/macro-interpolation.stderr | 4 +-- tests/ui/macros/nonterminal-matching.stderr | 24 +++++++-------- tests/ui/macros/syntax-error-recovery.stderr | 8 ++--- tests/ui/macros/trace_faulty_macros.stderr | 8 ++--- .../parser/attribute/attr-bad-meta-4.stderr | 4 +-- ...-trailing-outer-attribute-in-body-2.stderr | 8 ++--- tests/ui/parser/bad-interpolated-block.stderr | 24 +++++++-------- .../ui/parser/float-field-interpolated.stderr | 16 +++++----- ...sue-65122-mac-invoc-in-mut-patterns.stderr | 4 +-- .../ui/parser/issues/issue-87812-path.stderr | 4 +-- tests/ui/parser/issues/issue-87812.stderr | 4 +-- tests/ui/parser/labeled-no-colon-expr.stderr | 13 ++++---- .../break-in-unlabeled-block-in-macro.stderr | 4 +-- tests/ui/parser/macro/issue-37113.stderr | 4 +-- .../parser/macro/macro-doc-comments-2.stderr | 7 +++-- .../parser/macro/trait-non-item-macros.stderr | 4 +-- tests/ui/parser/mut-patterns.stderr | 4 +-- .../parser/recover/recover-range-pats.stderr | 30 +++++++++---------- .../ui/tuple/tuple-struct-fields/test2.stderr | 6 ++-- 33 files changed, 124 insertions(+), 122 deletions(-) diff --git a/tests/ui/attributes/nonterminal-expansion.stderr b/tests/ui/attributes/nonterminal-expansion.stderr index c16c5257e442d..21912de210610 100644 --- a/tests/ui/attributes/nonterminal-expansion.stderr +++ b/tests/ui/attributes/nonterminal-expansion.stderr @@ -1,8 +1,8 @@ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/nonterminal-expansion.rs:7:24 + --> $DIR/nonterminal-expansion.rs:7:22 | LL | #[repr(align($n))] - | ^ + | ^^ ... LL | pass_nonterminal!(n!()); | ----------------------- in this macro invocation diff --git a/tests/ui/borrowck/span-semicolon-issue-139049.stderr b/tests/ui/borrowck/span-semicolon-issue-139049.stderr index 0d800baf4a53f..8d2de67382bd8 100644 --- a/tests/ui/borrowck/span-semicolon-issue-139049.stderr +++ b/tests/ui/borrowck/span-semicolon-issue-139049.stderr @@ -2,7 +2,7 @@ error[E0597]: `l` does not live long enough --> $DIR/span-semicolon-issue-139049.rs:11:41 | LL | macro_rules! perform { ($e:expr) => { D(&$e).end() } } - | --^--- + | --^^^- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... @@ -24,7 +24,7 @@ error[E0597]: `l` does not live long enough --> $DIR/span-semicolon-issue-139049.rs:11:41 | LL | macro_rules! perform { ($e:expr) => { D(&$e).end() } } - | --^--- + | --^^^- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr index 0061be11d47bb..e73b20f2d5d31 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr @@ -92,10 +92,10 @@ LL | #[cfg(a = b"hi")] = note: expected a normal string literal, not a byte string literal error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/cfg-attr-syntax-validation.rs:51:30 + --> $DIR/cfg-attr-syntax-validation.rs:51:25 | LL | #[cfg(feature = $expr)] - | ^ + | ^^^^^ ... LL | generate_s10!(concat!("nonexistent")); | ------------------------------------- in this macro invocation diff --git a/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr index e8d55ba56a13a..fd03fa62864af 100644 --- a/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr @@ -92,10 +92,10 @@ LL | #[cfg_attr(true)] = note: for more information, visit error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable - --> $DIR/cfg_attr-attr-syntax-validation.rs:30:35 + --> $DIR/cfg_attr-attr-syntax-validation.rs:30:30 | LL | #[cfg_attr(feature = $expr)] - | --------------------------^- help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | ---------------------^^^^^-- help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` ... LL | generate_s10!(concat!("nonexistent")); | ------------------------------------- in this macro invocation diff --git a/tests/ui/did_you_mean/bad-assoc-expr.stderr b/tests/ui/did_you_mean/bad-assoc-expr.stderr index 5f9e85d557c74..b83078e21b6a1 100644 --- a/tests/ui/did_you_mean/bad-assoc-expr.stderr +++ b/tests/ui/did_you_mean/bad-assoc-expr.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:23:19 | LL | ($ty: ty) => ($ty::clone(&0)) - | ^ + | ^^^ ... LL | expr!(u8); | --------- in this macro invocation @@ -98,8 +98,8 @@ LL | expr!(u8); = note: this error originates in the macro `expr` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<>$ty::clone(&0)) - | ++ +LL | ($ty: ty) => (<$ty>::clone(&0)) + | + + error: aborting due to 9 previous errors diff --git a/tests/ui/did_you_mean/bad-assoc-pat.stderr b/tests/ui/did_you_mean/bad-assoc-pat.stderr index 6e29eca04d639..8bdeb8ffdd0a8 100644 --- a/tests/ui/did_you_mean/bad-assoc-pat.stderr +++ b/tests/ui/did_you_mean/bad-assoc-pat.stderr @@ -57,7 +57,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:21:19 | LL | ($ty: ty) => ($ty::AssocItem) - | ^ + | ^^^ ... LL | pat!(u8) => {} | -------- in this macro invocation @@ -65,8 +65,8 @@ LL | pat!(u8) => {} = note: this error originates in the macro `pat` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<>$ty::AssocItem) - | ++ +LL | ($ty: ty) => (<$ty>::AssocItem) + | + + error[E0599]: no associated item named `AssocItem` found for slice `[u8]` in the current scope --> $DIR/bad-assoc-pat.rs:3:15 diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr index b68b24ad220c5..af0a9d064d571 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); - | ^ + | ^^^ ... LL | type J = ty!(u8); | ------- in this macro invocation @@ -98,8 +98,8 @@ LL | type J = ty!(u8); = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<>$ty::AssocTy); - | ++ +LL | ($ty: ty) => (<$ty>::AssocTy); + | + + error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:5:10 diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr index c88a16a72894d..2ee8ab2760a92 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr @@ -90,7 +90,7 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); - | ^ + | ^^^ ... LL | type J = ty!(u8); | ------- in this macro invocation @@ -98,8 +98,8 @@ LL | type J = ty!(u8); = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths | -LL | ($ty: ty) => (<>$ty::AssocTy); - | ++ +LL | ($ty: ty) => (<$ty>::AssocTy); + | + + error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:5:10 diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr index 85daf49016edf..ec0e09a302ea1 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr @@ -66,7 +66,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:25:17 | LL | let ...$e; - | ^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr index 956ef9fccba1a..63258f3538313 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr @@ -85,10 +85,10 @@ LL + let $e..; | error[E0005]: refutable pattern in local binding - --> $DIR/half-open-range-pats-inclusive-no-end.rs:18:19 + --> $DIR/half-open-range-pats-inclusive-no-end.rs:18:17 | LL | let $e...; - | ^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -99,10 +99,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19 + --> $DIR/half-open-range-pats-inclusive-no-end.rs:20:17 | LL | let $e..=; - | ^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/imports/import-prefix-macro-2.stderr b/tests/ui/imports/import-prefix-macro-2.stderr index fb682e9268564..fbeca99b13800 100644 --- a/tests/ui/imports/import-prefix-macro-2.stderr +++ b/tests/ui/imports/import-prefix-macro-2.stderr @@ -1,8 +1,8 @@ error: expected identifier, found metavariable - --> $DIR/import-prefix-macro-2.rs:11:28 + --> $DIR/import-prefix-macro-2.rs:11:26 | LL | ($p: path) => (use ::$p {S, Z}); - | ^ expected identifier, found metavariable + | ^^ expected identifier, found metavariable ... LL | import! { a::b::c } | ------------------- in this macro invocation diff --git a/tests/ui/lint/lint-double-negations-macro.stderr b/tests/ui/lint/lint-double-negations-macro.stderr index a8fc0850e21e9..d6ac9be48f304 100644 --- a/tests/ui/lint/lint-double-negations-macro.stderr +++ b/tests/ui/lint/lint-double-negations-macro.stderr @@ -2,7 +2,7 @@ warning: use of a double negation --> $DIR/lint-double-negations-macro.rs:9:9 | LL | --$e - | ^^ + | ^^^^ ... LL | bad_macro!(1); | ------------- in this macro invocation @@ -13,8 +13,8 @@ LL | bad_macro!(1); = note: this warning originates in the macro `bad_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: add parentheses for clarity | -LL | -(-)$e - | + + +LL | -(-$e) + | + + warning: 1 warning emitted diff --git a/tests/ui/lint/unreachable_pub.stderr b/tests/ui/lint/unreachable_pub.stderr index 30d696816624b..5173ff1f0264d 100644 --- a/tests/ui/lint/unreachable_pub.stderr +++ b/tests/ui/lint/unreachable_pub.stderr @@ -112,10 +112,10 @@ LL | pub type Oxygen = bool; = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:44:58 + --> $DIR/unreachable_pub.rs:44:47 | LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} } - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | define_empty_struct_with_visibility!(pub, Fluorine); | --------------------------------------------------- diff --git a/tests/ui/macros/issue-29084.stderr b/tests/ui/macros/issue-29084.stderr index b7faedae5f249..6e7474c5b3f74 100644 --- a/tests/ui/macros/issue-29084.stderr +++ b/tests/ui/macros/issue-29084.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-29084.rs:6:13 | LL | bar(&mut $d); - | --- ^^^^^ expected `u8`, found `&mut u8` + | --- ^^^^^^^ expected `u8`, found `&mut u8` | | | arguments to this function are incorrect ... diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr index f4164555906ee..bc24a15861295 100644 --- a/tests/ui/macros/macro-interpolation.stderr +++ b/tests/ui/macros/macro-interpolation.stderr @@ -1,8 +1,8 @@ error: expected identifier, found metavariable - --> $DIR/macro-interpolation.rs:21:25 + --> $DIR/macro-interpolation.rs:21:19 | LL | <$type as $trait>::$name - | ^ expected identifier, found metavariable + | ^^^^^^ expected identifier, found metavariable ... LL | let _: qpath!(ty, ::Owned); | ----------------------------- diff --git a/tests/ui/macros/nonterminal-matching.stderr b/tests/ui/macros/nonterminal-matching.stderr index cb24b046f0ec0..d01561415664c 100644 --- a/tests/ui/macros/nonterminal-matching.stderr +++ b/tests/ui/macros/nonterminal-matching.stderr @@ -1,20 +1,20 @@ error: no rules expected `item` metavariable - --> $DIR/nonterminal-matching.rs:19:18 + --> $DIR/nonterminal-matching.rs:19:10 | LL | macro n(a $nt_item b) { | --------------------- when calling this macro ... LL | n!(a $nt_item b); - | ^ no rules expected this token in macro call + | ^^^^^^^^ no rules expected this token in macro call ... LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation | note: while trying to match `item` metavariable - --> $DIR/nonterminal-matching.rs:15:23 + --> $DIR/nonterminal-matching.rs:15:15 | LL | macro n(a $nt_item b) { - | ^ + | ^^^^^^^^ ... LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation @@ -24,10 +24,10 @@ LL | complex_nonterminal!(enum E {}); = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `expr` metavariable - --> $DIR/nonterminal-matching.rs:32:37 + --> $DIR/nonterminal-matching.rs:32:35 | LL | (expr $x:expr) => { bar!(expr $x); }; - | ^ no rules expected this token in macro call + | ^^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -46,10 +46,10 @@ LL | (expr 3) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `literal` metavariable - --> $DIR/nonterminal-matching.rs:33:46 + --> $DIR/nonterminal-matching.rs:33:44 | LL | (literal $x:literal) => { bar!(literal $x); }; - | ^ no rules expected this token in macro call + | ^^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -68,10 +68,10 @@ LL | (literal 4) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `path` metavariable - --> $DIR/nonterminal-matching.rs:34:37 + --> $DIR/nonterminal-matching.rs:34:35 | LL | (path $x:path) => { bar!(path $x); }; - | ^ no rules expected this token in macro call + | ^^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro @@ -90,10 +90,10 @@ LL | (path a::b::c) => {}; = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `stmt` metavariable - --> $DIR/nonterminal-matching.rs:35:37 + --> $DIR/nonterminal-matching.rs:35:35 | LL | (stmt $x:stmt) => { bar!(stmt $x); }; - | ^ no rules expected this token in macro call + | ^^ no rules expected this token in macro call ... LL | macro_rules! bar { | ---------------- when calling this macro diff --git a/tests/ui/macros/syntax-error-recovery.stderr b/tests/ui/macros/syntax-error-recovery.stderr index 869a050eb8775..a2059aa1aa802 100644 --- a/tests/ui/macros/syntax-error-recovery.stderr +++ b/tests/ui/macros/syntax-error-recovery.stderr @@ -1,8 +1,8 @@ error: expected one of `(`, `,`, `=`, `{`, or `}`, found `ty` metavariable - --> $DIR/syntax-error-recovery.rs:7:32 + --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, - | ^ expected one of `(`, `,`, `=`, `{`, or `}` + | ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}` ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation @@ -11,10 +11,10 @@ LL | values!(STRING(1) as (String) => cfg(test),); = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores `ty` metavariable and any tokens following - --> $DIR/syntax-error-recovery.rs:7:32 + --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, - | ^ + | ^^^^^^ ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- caused by the macro expansion here diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index c459c6743612b..e90d7a98db4c7 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -51,10 +51,10 @@ LL | my_recursive_macro!(); = note: to `my_recursive_macro! ();` error: expected expression, found `pat` metavariable - --> $DIR/trace_faulty_macros.rs:16:11 + --> $DIR/trace_faulty_macros.rs:16:9 | LL | $a - | ^ expected expression + | ^^ expected expression ... LL | let a = pat_macro!(); | ------------ in this macro invocation @@ -70,10 +70,10 @@ LL | fn use_derive_macro_as_attr() {} | -------------------------------- not a `struct`, `enum` or `union` error: expected expression, found `pat` metavariable - --> $DIR/trace_faulty_macros.rs:49:39 + --> $DIR/trace_faulty_macros.rs:49:37 | LL | (($p:pat, $e:pat)) => {let $p = $e;}; - | ^ expected expression + | ^^ expected expression ... LL | test!(let x = 1+1); | ------------------ in this macro invocation diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.stderr b/tests/ui/parser/attribute/attr-bad-meta-4.stderr index 50d1d890c39c6..1d939942fb9a9 100644 --- a/tests/ui/parser/attribute/attr-bad-meta-4.stderr +++ b/tests/ui/parser/attribute/attr-bad-meta-4.stderr @@ -11,10 +11,10 @@ LL + #[cfg(feature = 1)] | error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable - --> $DIR/attr-bad-meta-4.rs:3:25 + --> $DIR/attr-bad-meta-4.rs:3:15 | LL | #[cfg($attr_item)] - | ^ + | ^^^^^^^^^^ ... LL | mac!(an(arbitrary token stream)); | -------------------------------- in this macro invocation diff --git a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr index ba2ebef3e5758..41e7b5ab759dd 100644 --- a/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr +++ b/tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.stderr @@ -1,10 +1,10 @@ error: expected `;`, found `#` - --> $DIR/properly-recover-from-trailing-outer-attribute-in-body-2.rs:6:9 + --> $DIR/properly-recover-from-trailing-outer-attribute-in-body-2.rs:6:13 | LL | #[cfg()] | -------- only `;` terminated statements or tail expressions are allowed after this attribute LL | $foo - | ^ expected `;` here + | ^ expected `;` here LL | LL | #[cfg(false)] | - unexpected token @@ -15,8 +15,8 @@ LL | the_macro!( (); (); ); = note: this error originates in the macro `the_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: add `;` here | -LL | ;$foo - | + +LL | $foo; + | + help: alternatively, consider surrounding the expression with a block | LL | the_macro!( { () }; (); ); diff --git a/tests/ui/parser/bad-interpolated-block.stderr b/tests/ui/parser/bad-interpolated-block.stderr index a9b323395cd12..651036c51c948 100644 --- a/tests/ui/parser/bad-interpolated-block.stderr +++ b/tests/ui/parser/bad-interpolated-block.stderr @@ -1,8 +1,8 @@ error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:5:17 + --> $DIR/bad-interpolated-block.rs:5:15 | LL | 'lab: $b; - | --------^ + | ------^^ | | | the `block` fragment is within this context ... @@ -12,14 +12,14 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | 'lab: $b{ }; - | + + +LL | 'lab: { $b }; + | + + error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:6:18 + --> $DIR/bad-interpolated-block.rs:6:16 | LL | unsafe $b; - | ---------^ + | -------^^ | | | the `block` fragment is within this context ... @@ -29,14 +29,14 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | unsafe $b{ }; - | + + +LL | unsafe { $b }; + | + + error: cannot use a `block` macro fragment here - --> $DIR/bad-interpolated-block.rs:7:25 + --> $DIR/bad-interpolated-block.rs:7:23 | LL | |x: u8| -> () $b; - | ^ the `block` fragment is within this context + | ^^ the `block` fragment is within this context ... LL | m!({}); | ------ in this macro invocation @@ -44,8 +44,8 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | |x: u8| -> () $b{ }; - | + + +LL | |x: u8| -> () { $b }; + | + + error: aborting due to 3 previous errors diff --git a/tests/ui/parser/float-field-interpolated.stderr b/tests/ui/parser/float-field-interpolated.stderr index 0b403f2aac94d..e2b7e3a7dbe75 100644 --- a/tests/ui/parser/float-field-interpolated.stderr +++ b/tests/ui/parser/float-field-interpolated.stderr @@ -1,8 +1,8 @@ error: unexpected token: `literal` metavariable - --> $DIR/float-field-interpolated.rs:8:15 + --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } - | ^ + | ^^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -10,10 +10,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `.`, `;`, `?`, `}`, or an operator, found `literal` metavariable - --> $DIR/float-field-interpolated.rs:8:15 + --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } - | ^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -21,10 +21,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: unexpected token: `expr` metavariable - --> $DIR/float-field-interpolated.rs:10:15 + --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } - | ^ + | ^^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -32,10 +32,10 @@ LL | generate_field_accesses!(1.1, 1.1, 1.1); = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `.`, `;`, `?`, `}`, or an operator, found `expr` metavariable - --> $DIR/float-field-interpolated.rs:10:15 + --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } - | ^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation diff --git a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr index 5501ff584bb54..59e1b64686b46 100644 --- a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr +++ b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr @@ -16,10 +16,10 @@ LL + let $eval = (); | error: expected identifier, found metavariable - --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:22 + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17 | LL | let mut $eval = (); - | ^ expected identifier, found metavariable + | ^^^^^ expected identifier, found metavariable ... LL | mac2! { does_not_exist!() } | --------------------------- in this macro invocation diff --git a/tests/ui/parser/issues/issue-87812-path.stderr b/tests/ui/parser/issues/issue-87812-path.stderr index 2fe205e30171a..fbe26ea39595a 100644 --- a/tests/ui/parser/issues/issue-87812-path.stderr +++ b/tests/ui/parser/issues/issue-87812-path.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/issue-87812-path.rs:3:26 + --> $DIR/issue-87812-path.rs:3:24 | LL | let _: usize = $f; - | ----- ^ expected `usize`, found `Baz` + | ----- ^^ expected `usize`, found `Baz` | | | expected due to this ... diff --git a/tests/ui/parser/issues/issue-87812.stderr b/tests/ui/parser/issues/issue-87812.stderr index 362116730f087..35dc66a528a99 100644 --- a/tests/ui/parser/issues/issue-87812.stderr +++ b/tests/ui/parser/issues/issue-87812.stderr @@ -15,8 +15,8 @@ LL | #![deny(break_with_label_and_loop)] = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this expression in parentheses | -LL | break '_l $f(); - | ++ +LL | break '_l ($f); + | + + error: aborting due to 1 previous error diff --git a/tests/ui/parser/labeled-no-colon-expr.stderr b/tests/ui/parser/labeled-no-colon-expr.stderr index 4f8d1f69636a0..2478319281569 100644 --- a/tests/ui/parser/labeled-no-colon-expr.stderr +++ b/tests/ui/parser/labeled-no-colon-expr.stderr @@ -81,10 +81,10 @@ LL | 'l4: 0; | + error: cannot use a `block` macro fragment here - --> $DIR/labeled-no-colon-expr.rs:11:19 + --> $DIR/labeled-no-colon-expr.rs:11:17 | LL | 'l5 $b; - | ------^ + | ----^^ | | | the `block` fragment is within this context ... @@ -94,8 +94,8 @@ LL | m!({}); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this in another block | -LL | 'l5 $b{ }; - | + + +LL | 'l5 { $b }; + | + + error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:14:8 @@ -109,9 +109,8 @@ LL | m!({}); = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them help: add `:` after the label | -LL - 'l5 $b; -LL + 'l5: ; - | +LL | 'l5: $b; + | + error: aborting due to 8 previous errors diff --git a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr index 72e97514350b6..2f46cb36750be 100644 --- a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr +++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr @@ -13,7 +13,7 @@ error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-in-unlabeled-block-in-macro.rs:6:9 | LL | break $e; - | ^^^^^^ cannot `break` outside of a loop or labeled block + | ^^^^^^^^ cannot `break` outside of a loop or labeled block ... LL | foo!(()); | -------- in this macro invocation @@ -41,7 +41,7 @@ error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-in-unlabeled-block-in-macro.rs:12:11 | LL | { break $e; } - | ^^^^^^ cannot `break` outside of a loop or labeled block + | ^^^^^^^^ cannot `break` outside of a loop or labeled block ... LL | foo!(@ ()); | ---------- in this macro invocation diff --git a/tests/ui/parser/macro/issue-37113.stderr b/tests/ui/parser/macro/issue-37113.stderr index e073d55f23bd7..560329df5ccbd 100644 --- a/tests/ui/parser/macro/issue-37113.stderr +++ b/tests/ui/parser/macro/issue-37113.stderr @@ -1,10 +1,10 @@ error: expected identifier, found metavariable - --> $DIR/issue-37113.rs:4:18 + --> $DIR/issue-37113.rs:4:16 | LL | enum SomeEnum { | -------- while parsing this enum LL | $( $t, )* - | ^ expected identifier, found metavariable + | ^^ expected identifier, found metavariable ... LL | test_macro!(String,); | -------------------- in this macro invocation diff --git a/tests/ui/parser/macro/macro-doc-comments-2.stderr b/tests/ui/parser/macro/macro-doc-comments-2.stderr index f29fab1e8800d..02c12bf959114 100644 --- a/tests/ui/parser/macro/macro-doc-comments-2.stderr +++ b/tests/ui/parser/macro/macro-doc-comments-2.stderr @@ -1,11 +1,14 @@ error: no rules expected `[` - --> $DIR/macro-doc-comments-2.rs:6:14 + --> $DIR/macro-doc-comments-2.rs:6:5 | LL | macro_rules! inner { | ------------------ when calling this macro ... LL | /// Outer - | ^ no rules expected this token in macro call + | ^^^^^^^^^ + | | + | no rules expected this token in macro call + | outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match | note: while trying to match `!` --> $DIR/macro-doc-comments-2.rs:2:7 diff --git a/tests/ui/parser/macro/trait-non-item-macros.stderr b/tests/ui/parser/macro/trait-non-item-macros.stderr index 3b5e694c2ab56..62b42fa8b8dd7 100644 --- a/tests/ui/parser/macro/trait-non-item-macros.stderr +++ b/tests/ui/parser/macro/trait-non-item-macros.stderr @@ -1,8 +1,8 @@ error: macro expansion ignores `expr` metavariable and any tokens following - --> $DIR/trait-non-item-macros.rs:3:11 + --> $DIR/trait-non-item-macros.rs:3:9 | LL | $a - | ^ + | ^^ ... LL | bah!(2); | ------- caused by the macro expansion here diff --git a/tests/ui/parser/mut-patterns.stderr b/tests/ui/parser/mut-patterns.stderr index 29ba6e3336e23..70099989c9ff0 100644 --- a/tests/ui/parser/mut-patterns.stderr +++ b/tests/ui/parser/mut-patterns.stderr @@ -159,10 +159,10 @@ LL + let W(mut a, W(mut b, W(ref c, W(mut d, B { box mut f })))) | error: expected identifier, found metavariable - --> $DIR/mut-patterns.rs:49:23 + --> $DIR/mut-patterns.rs:49:21 | LL | let mut $p = 0; - | ^ expected identifier, found metavariable + | ^^ expected identifier, found metavariable ... LL | foo!(x); | ------- in this macro invocation diff --git a/tests/ui/parser/recover/recover-range-pats.stderr b/tests/ui/parser/recover/recover-range-pats.stderr index 7e0dd1c8979d0..1570475a0989b 100644 --- a/tests/ui/parser/recover/recover-range-pats.stderr +++ b/tests/ui/parser/recover/recover-range-pats.stderr @@ -609,10 +609,10 @@ LL | if let ....3 = 0 {} | expected integer, found floating-point number error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:135:20 + --> $DIR/recover-range-pats.rs:135:17 | LL | let $e1..$e2; - | ^^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered + | ^^^^^^^^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -623,10 +623,10 @@ LL | mac2!(0, 1); = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:137:20 + --> $DIR/recover-range-pats.rs:137:17 | LL | let $e1...$e2; - | ^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered + | ^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -637,10 +637,10 @@ LL | mac2!(0, 1); = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:141:20 + --> $DIR/recover-range-pats.rs:141:17 | LL | let $e1..=$e2; - | ^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered + | ^^^^^^^^^ patterns `i32::MIN..=-1_i32` and `2_i32..=i32::MAX` not covered ... LL | mac2!(0, 1); | ----------- in this macro invocation @@ -654,7 +654,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:150:17 | LL | let ..$e; - | ^^ pattern `0_i32..=i32::MAX` not covered + | ^^^^ pattern `0_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -668,7 +668,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:152:17 | LL | let ...$e; - | ^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -682,7 +682,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/recover-range-pats.rs:155:17 | LL | let ..=$e; - | ^^^ pattern `1_i32..=i32::MAX` not covered + | ^^^^^ pattern `1_i32..=i32::MAX` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -693,10 +693,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:157:19 + --> $DIR/recover-range-pats.rs:157:17 | LL | let $e..; - | ^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -707,10 +707,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:159:19 + --> $DIR/recover-range-pats.rs:159:17 | LL | let $e...; - | ^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation @@ -721,10 +721,10 @@ LL | mac!(0); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0005]: refutable pattern in local binding - --> $DIR/recover-range-pats.rs:161:19 + --> $DIR/recover-range-pats.rs:161:17 | LL | let $e..=; - | ^^^ pattern `i32::MIN..=-1_i32` not covered + | ^^^^^ pattern `i32::MIN..=-1_i32` not covered ... LL | mac!(0); | ------- in this macro invocation diff --git a/tests/ui/tuple/tuple-struct-fields/test2.stderr b/tests/ui/tuple/tuple-struct-fields/test2.stderr index b658b8856d178..784411aba8f8a 100644 --- a/tests/ui/tuple/tuple-struct-fields/test2.stderr +++ b/tests/ui/tuple/tuple-struct-fields/test2.stderr @@ -2,9 +2,9 @@ error: expected one of `)` or `,`, found `(` --> $DIR/test2.rs:5:26 | LL | struct S3(pub $t ()); - | - ^ expected one of `)` or `,` - | | - | help: missing `,` + | -^ expected one of `)` or `,` + | | + | help: missing `,` ... LL | define_struct! { (foo) } | ------------------------ in this macro invocation From a678ff4a7b81b6b34bdc2425a31a962052cdd7f0 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Thu, 20 Nov 2025 17:18:00 -0800 Subject: [PATCH 07/17] Revert "Update uninhabited_references.stderr" This reverts commit f2819360ead1f76950d1160087f2636c25724cb4. --- src/tools/clippy/tests/ui/uninhabited_references.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/tests/ui/uninhabited_references.stderr b/src/tools/clippy/tests/ui/uninhabited_references.stderr index 120911cc94e4a..ac05ab5bb4d40 100644 --- a/src/tools/clippy/tests/ui/uninhabited_references.stderr +++ b/src/tools/clippy/tests/ui/uninhabited_references.stderr @@ -11,7 +11,7 @@ error: dereferencing a reference to an uninhabited type would be undefined behav --> tests/ui/uninhabited_references.rs:12:30 | LL | fn $name(x: &$ty) -> &$ty { - | ^ + | ^^^^ ... LL | ret_something!(id_never, !); | --------------------------- in this macro invocation From e07d74d20da01c76e05d398340d02b6c6a4cccd3 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Thu, 20 Nov 2025 17:18:12 -0800 Subject: [PATCH 08/17] Revert "Don't like this at all but just changing so tests pass to test output." This reverts commit e995f8e70278c08b438c87cb1746186fd7c3e120. --- .../closure-body-macro-fragment.fixed | 33 +++++++++++++++++++ .../migrations/closure-body-macro-fragment.rs | 2 ++ .../closure-body-macro-fragment.stderr | 10 +++--- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed new file mode 100644 index 0000000000000..e9e16ce951b24 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.fixed @@ -0,0 +1,33 @@ +//@ run-rustfix +//@ edition:2018 +//@ check-pass +#![warn(rust_2021_compatibility)] + +#[derive(Debug)] +struct Foo(i32); +impl Drop for Foo { + fn drop(&mut self) { + println!("{:?} dropped", self.0); + } +} + +macro_rules! m { + (@ $body:expr) => {{ + let f = || $body; + //~^ WARNING: drop order + f(); + }}; + ($body:block) => {{ + m!(@ $body); + }}; +} + +fn main() { + let a = (Foo(0), Foo(1)); + m!({ + let _ = &a; + //~^ HELP: add a dummy + let x = a.0; + println!("{:?}", x); + }); +} diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs index 4ec17ca69e123..0cb5351f595e0 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.rs @@ -1,3 +1,4 @@ +//@ run-rustfix //@ edition:2018 //@ check-pass #![warn(rust_2021_compatibility)] @@ -24,6 +25,7 @@ macro_rules! m { fn main() { let a = (Foo(0), Foo(1)); m!({ + //~^ HELP: add a dummy let x = a.0; println!("{:?}", x); }); diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr index 5bc5a0244e146..c49b1d2d0e069 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr @@ -1,5 +1,5 @@ warning: changes to closure capture in Rust 2021 will affect drop order - --> $DIR/closure-body-macro-fragment.rs:15:17 + --> $DIR/closure-body-macro-fragment.rs:16:17 | LL | let f = || $body; | ^^ @@ -8,6 +8,7 @@ LL | }}; | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure ... LL | / m!({ +LL | | LL | | let x = a.0; | | --- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0` LL | | println!("{:?}", x); @@ -16,7 +17,7 @@ LL | | }); | = note: for more information, see note: the lint level is defined here - --> $DIR/closure-body-macro-fragment.rs:3:9 + --> $DIR/closure-body-macro-fragment.rs:4:9 | LL | #![warn(rust_2021_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,8 +25,9 @@ LL | #![warn(rust_2021_compatibility)] = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: add a dummy let to cause `a` to be fully captured | -LL | m!(@ $body{ let _ = &a; }); - | +++++++++++++ + +LL ~ m!({ +LL + let _ = &a; + | warning: 1 warning emitted From 72e22b5a9f8c8ca29a82427aef461e5ab5de1b3b Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Fri, 21 Nov 2025 12:50:11 -0800 Subject: [PATCH 09/17] Delimiters are only ascii so we can get rid the utf8 length handling. --- compiler/rustc_ast/src/tokenstream.rs | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 055b32de45cbe..73545f33951e6 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -988,8 +988,9 @@ impl DelimSpan { let (open, close) = sm .span_to_source(sp, |src, start, end| { - let Some(src) = src.get(start..end) else { - return Ok((default_close, default_close)); + let src = match src.get(start..end) { + Some(s) if !s.is_empty() => s.as_bytes(), + _ => return Ok((default_open, default_close)), }; // Only check the first and last characters. @@ -1000,35 +1001,33 @@ impl DelimSpan { // searching for the delimiters, and setting // the open and close spans to some more interior // position. - let mut chars = src.chars(); - // just using '_' as a place holder. - let first = chars.next().unwrap_or('_'); - let last = chars.last().unwrap_or('_'); + let first = src[0]; + let last = src[src.len() - 1]; // Thought maybe scan through if first is '(', '[', or '{' // and see if the last matches up e.g. make sure it's not some // extra mismatched delimiter. - let open = sp.subspan(0..first.len_utf8()).unwrap_or(default_open); - - let len = (sp.hi() - sp.lo()).0 as usize; - let pos = len.checked_sub(last.len_utf8()).unwrap_or(0); + let open = sp.subspan(0..1).unwrap_or(default_open); + let pos = (sp.hi() - sp.lo()).0.checked_sub(1).unwrap_or(0); let close = sp.subspan(pos..).unwrap_or(default_close); Ok(match (first, last) { - ('(', ')') | ('{', '}') | ('[', ']') => (open, close), - ('(', _) | ('{', _) | ('[', _) => (open, default_close), - (_, ')') | (_, '}') | (_, ']') => (default_open, close), - (_, _) => (default_close, default_open), + (b'(', b')') | (b'{', b'}') | (b'[', b']') => (open, close), + (b'(', _) | (b'{', _) | (b'[', _) => (open, default_close), + (_, b')') | (_, b'}') | (_, b']') => (default_open, close), + (_, _) => (default_open, default_close), }) }) .ok() .unwrap_or((default_open, default_close)); + debug_assert!(open.lo() <= close.lo()); DelimSpan { open, close } } pub fn from_pair(open: Span, close: Span) -> Self { + debug_assert!(open.lo() <= close.lo()); DelimSpan { open, close } } @@ -1037,6 +1036,7 @@ impl DelimSpan { } pub fn entire(self) -> Span { + debug_assert!(self.open.lo() <= self.close.lo()); self.open.with_hi(self.close.hi()) } } From 2b4a54f031744d597aa383911460cba6509e75fb Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Fri, 21 Nov 2025 14:57:06 -0800 Subject: [PATCH 10/17] Fix bad-assoc UI tests --- compiler/rustc_parse/src/parser/mod.rs | 31 +++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 203a93b52012b..5ae25be7f9ed5 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -155,12 +155,23 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath { && let token::MetaVarKind::Ty { .. } = mv_kind && $self.check_noexpect_past_close_delim(&token::PathSep) { + // We want the span before it eat gets eaten. + // For example the current token has an OpenInvisible + // After being eaten the parsers previous token will + // then become a CloseInvisible which only has the + // close span and the current token will just be a + // a path separator. + + // Probably only need `$self.token.span` here because the Span::until(...) + let sp = $self.parent_tree_span().unwrap_or($self.token.span); + // Reparse the type, then move to recovery. let ty = $self .eat_metavar_seq(mv_kind, |this| this.parse_ty_no_question_mark_recover()) .expect("metavar seq ty"); - return $self.maybe_recover_from_bad_qpath_stage_2($self.prev_token.span, ty); + let span = sp.until($self.token.span); + return $self.maybe_recover_from_bad_qpath_stage_2(span, ty); } }; } @@ -1665,6 +1676,24 @@ impl<'a> Parser<'a> { _ => self.prev_token.span, } } + + /// Returns the full `Span` of the parent enclosing delimited construct, if any. + /// + /// The span covers both the opening and closing delimiters as well as everything + /// in between. + /// + /// This is primarily used fo improve diagnostics that need the outer syntactic context. + /// (e.g full span of `∅ ... ∅`, `( ... )`, `{ ... }`, or `[ ... ]`). + /// + /// Returns `None` if the parser is not currently inside a delimited group. + pub fn parent_tree_span(&self) -> Option { + //println!("{:#?}", self.token_cursor.stack.last()?); + match self.token_cursor.stack.last()?.curr()? { + TokenTree::Delimited(dspan, _, _, _) => return Some(dspan.entire()), + // I don't think this case is possible + _ => None, + } + } } // Metavar captures of various kinds. From 79ada77410f6d6e7ca64e749dc47fa94609b7e14 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Fri, 21 Nov 2025 15:09:49 -0800 Subject: [PATCH 11/17] Fix Attribut UI tests. --- compiler/rustc_attr_parsing/src/parser.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 7474471f2fe0f..15b2dbacdc32e 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -483,8 +483,13 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { } fn expected_lit(&mut self) -> Diag<'sess> { + let span = if self.parser.token.is_metavar_seq().is_some() { + self.parser.parent_tree_span().unwrap_or(self.parser.token.span) + } else { + self.parser.token.span + }; let mut err = InvalidMetaItem { - span: self.parser.token.span, + span, descr: token_descr(&self.parser.token), quote_ident_sugg: None, remove_neg_sugg: None, From a2b96aa20f1623bd04dd610533a8454a465c1483 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Fri, 21 Nov 2025 16:27:02 -0800 Subject: [PATCH 12/17] Fix expected Identifier UI tests. --- compiler/rustc_attr_parsing/src/parser.rs | 7 +------ compiler/rustc_parse/src/parser/diagnostics.rs | 5 +++-- compiler/rustc_parse/src/parser/mod.rs | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 15b2dbacdc32e..40086c869f2e5 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -483,13 +483,8 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { } fn expected_lit(&mut self) -> Diag<'sess> { - let span = if self.parser.token.is_metavar_seq().is_some() { - self.parser.parent_tree_span().unwrap_or(self.parser.token.span) - } else { - self.parser.token.span - }; let mut err = InvalidMetaItem { - span, + span: self.parser.token_diag_span(), descr: token_descr(&self.parser.token), quote_ident_sugg: None, remove_neg_sugg: None, diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index bd495f6ec1acb..a48828ee7f9a6 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -334,6 +334,7 @@ impl<'a> Parser<'a> { // we take this here so that the correct original token is retained in // the diagnostic, regardless of eager recovery. let bad_token = self.token; + let bad_span = self.token_diag_span(); // suggest prepending a keyword in identifier position with `r#` let suggest_raw = if let Some((ident, IdentIsRaw::No)) = self.token.ident() @@ -358,7 +359,7 @@ impl<'a> Parser<'a> { recovered_ident = self.ident_or_err(false).ok(); }; - Some(SuggRemoveComma { span: bad_token.span }) + Some(SuggRemoveComma { span: bad_span }) } else { None }; @@ -372,7 +373,7 @@ impl<'a> Parser<'a> { }); let err = ExpectedIdentifier { - span: bad_token.span, + span: bad_span, token: bad_token, suggest_raw, suggest_remove_comma, diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 5ae25be7f9ed5..ba69f1af97cc6 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1694,6 +1694,15 @@ impl<'a> Parser<'a> { _ => None, } } + + /// Get the full span of the current token for diagnostic purposes. + pub fn token_diag_span(&self) -> Span { + let sp = self.token.span; + if self.token.is_metavar_seq().is_some() { + return self.parent_tree_span().unwrap_or(sp); + } + sp + } } // Metavar captures of various kinds. From 28330afa6d1603a75adebd6fa5f1398cbdefe9d8 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Fri, 21 Nov 2025 18:53:37 -0800 Subject: [PATCH 13/17] Fix tests/ui/macros/nonterminal-matching.rs --- compiler/rustc_expand/src/mbe/macro_parser.rs | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index ab8e059b7b77f..21a1e7ef1774a 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -77,7 +77,7 @@ use std::rc::Rc; pub(crate) use NamedMatch::*; pub(crate) use ParseResult::*; -use rustc_ast::token::{self, DocComment, NonterminalKind, Token, TokenKind}; +use rustc_ast::token::{self, Delimiter, DocComment, NonterminalKind, Token, TokenKind}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_lint_defs::pluralize; @@ -177,8 +177,25 @@ pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec { locs.push(MatcherLoc::Token { token: *token }); } TokenTree::Delimited(span, _, delimited) => { - let open_token = Token::new(delimited.delim.as_open_token_kind(), span.open); - let close_token = Token::new(delimited.delim.as_close_token_kind(), span.close); + // Is there a better way for MatcherLoc to store these?? + // I see we push a `MatcherLoc::Delimited` would it be + // better to to store the entire span for all delimiters + // types in that instead just leaving it as an empty enum + // variant? + // The diagnostics currently use `MatcherLoc::Span()` + // however for invisible delimiters they seem to expect + // that is the whole span. It would make more sense to me + // if they got that data from `MatcherLoc::Delimited` that + // also means any diagnostics for non-invisible delims could + // get that entire span information if needed as well. + // However for now I am just going to do this to make + // existing diagnostics happy. + let (open, close) = match delimited.delim { + Delimiter::Invisible(_) => (span.entire(), span.entire()), + _ => (span.open, span.close), + }; + let open_token = Token::new(delimited.delim.as_open_token_kind(), open); + let close_token = Token::new(delimited.delim.as_close_token_kind(), close); locs.push(MatcherLoc::Delimited); locs.push(MatcherLoc::Token { token: open_token }); @@ -479,7 +496,7 @@ impl TtParser { MatcherLoc::Token { token: t } => { // If it's a doc comment, we just ignore it and move on to the next tt in the // matcher. This is a bug, but #95267 showed that existing programs rely on - // this behaviour, and changing it would require some care and a transition + // this behavior, and changing it would require some care and a transition // period. // // If the token matches, we can just advance the parser. @@ -649,10 +666,12 @@ impl TtParser { // Error messages here could be improved with links to original rules. match (self.next_mps.len(), self.bb_mps.len()) { (0, 0) => { + let mut tok = parser.token; + tok.span = parser.token_diag_span(); // There are no possible next positions AND we aren't waiting for the black-box // parser: syntax error. return Failure(T::build_failure( - parser.token, + tok, parser.approx_token_stream_pos(), "no rules expected this token in macro call", )); From b1b884042267e8ece81953bb67783c35f1a6d08b Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 13:19:15 -0800 Subject: [PATCH 14/17] Fix UI Tests Issue-87812 --- compiler/rustc_parse/src/parser/expr.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 9e7d4bca37d05..9fcf5b516ab10 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1414,7 +1414,7 @@ impl<'a> Parser<'a> { fn parse_expr_bottom(&mut self) -> PResult<'a, Box> { maybe_recover_from_interpolated_ty_qpath!(self, true); - let span = self.token.span; + let span = self.token_diag_span(); if let Some(expr) = self.eat_metavar_seq_with_matcher( |mv_kind| matches!(mv_kind, MetaVarKind::Expr { .. }), |this| { @@ -1910,9 +1910,9 @@ impl<'a> Parser<'a> { { self.psess.buffer_lint( BREAK_WITH_LABEL_AND_LOOP, - lo.to(expr.span), + lo.until(self.token.span), ast::CRATE_NODE_ID, - BuiltinLintDiag::BreakWithLabelAndLoop(expr.span), + BuiltinLintDiag::BreakWithLabelAndLoop(expr.span.until(self.token.span)), ); } From fbb9ab6e293b0eaff910c395b0d1e4e4bdb1eb67 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 13:56:09 -0800 Subject: [PATCH 15/17] This is exactly the same code for the sp variable, so just use it. --- compiler/rustc_parse/src/parser/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index ba69f1af97cc6..a9636f880e472 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -919,7 +919,7 @@ impl<'a> Parser<'a> { ); expect_err .with_span_suggestion_verbose( - self.prev_token.span.shrink_to_hi().until(self.token.span), + sp.until(self.token.span), msg, " @ ", Applicability::MaybeIncorrect, From 7810c402477b7473419e916cad3160328ff4022b Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 14:22:22 -0800 Subject: [PATCH 16/17] Fix UI test labeled-no-colon-expr --- compiler/rustc_parse/src/parser/expr.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 9fcf5b516ab10..8642397253d6d 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2357,13 +2357,11 @@ impl<'a> Parser<'a> { } if self.token.is_metavar_block() { + let sp = self.token_diag_span(); self.dcx().emit_err(errors::InvalidBlockMacroSegment { - span: self.token.span, - context: lo.to(self.token.span), - wrap: errors::WrapInExplicitBlock { - lo: self.token.span.shrink_to_lo(), - hi: self.token.span.shrink_to_hi(), - }, + span: sp, + context: lo.to(sp), + wrap: errors::WrapInExplicitBlock { lo: sp.shrink_to_lo(), hi: sp.shrink_to_hi() }, }); } From 38bf89c67b45e332392287aa6c340c22265c0cae Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 15:30:47 -0800 Subject: [PATCH 17/17] I am just going to update the failing UI tests for now since I revereted them earlier. --- .../ui/checked_unwrap/simple_conditionals.stderr | 4 ++-- .../clippy/tests/ui/cognitive_complexity.stderr | 10 +++++++++- src/tools/clippy/tests/ui/string_lit_as_bytes.fixed | 2 +- src/tools/clippy/tests/ui/string_lit_as_bytes.stderr | 4 ++-- tests/ui/borrowck/issue-25793.stderr | 4 ++-- tests/ui/issues/issue-26237.stderr | 2 +- tests/ui/issues/issue-39848.stderr | 4 ++-- tests/ui/lint/unused/must-use-macros.stderr | 4 ++-- tests/ui/lint/wide_pointer_comparisons.stderr | 4 ++-- tests/ui/macros/syntax-error-recovery.stderr | 4 ++-- tests/ui/macros/trace_faulty_macros.stderr | 4 ++-- tests/ui/mismatched_types/issue-26480.stderr | 12 ++++++------ tests/ui/parser/float-field-interpolated.stderr | 8 ++++---- tests/ui/parser/macro/macro-doc-comments-2.stderr | 5 +---- tests/ui/parser/macro/trait-non-item-macros.stderr | 2 +- tests/ui/suggestions/issue-114701.stderr | 2 +- 16 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr index 2007a85954137..38b0a97704918 100644 --- a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -65,13 +65,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_some` - --> tests/ui/checked_unwrap/simple_conditionals.rs:13:13 + --> tests/ui/checked_unwrap/simple_conditionals.rs:13:15 | LL | if $a.is_some() { | --------------- help: try: `if let Some() = x` LL | // unnecessary LL | $a.unwrap(); - | ^^^^^^^^^^^ + | ^^^^^^^^^ ... LL | m!(x); | ----- in this macro invocation diff --git a/src/tools/clippy/tests/ui/cognitive_complexity.stderr b/src/tools/clippy/tests/ui/cognitive_complexity.stderr index 67ef4e5655bd6..55d4b95d1ea5c 100644 --- a/src/tools/clippy/tests/ui/cognitive_complexity.stderr +++ b/src/tools/clippy/tests/ui/cognitive_complexity.stderr @@ -16,6 +16,14 @@ LL | fn kaboom() { | = help: you could split it up into multiple smaller functions +error: the function has a cognitive complexity of (2/1) + --> tests/ui/cognitive_complexity.rs:121:4 + | +LL | fn bloo() { + | ^^^^ + | + = help: you could split it up into multiple smaller functions + error: the function has a cognitive complexity of (2/1) --> tests/ui/cognitive_complexity.rs:158:4 | @@ -176,5 +184,5 @@ LL | fn bar() { | = help: you could split it up into multiple smaller functions -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors diff --git a/src/tools/clippy/tests/ui/string_lit_as_bytes.fixed b/src/tools/clippy/tests/ui/string_lit_as_bytes.fixed index 2a86dffbc7627..881eef89fbc78 100644 --- a/src/tools/clippy/tests/ui/string_lit_as_bytes.fixed +++ b/src/tools/clippy/tests/ui/string_lit_as_bytes.fixed @@ -8,7 +8,7 @@ extern crate macro_rules; macro_rules! b { ($b:literal) => { - const B: &[u8] = b"warning"; + const B: &[u8] = $bb"warning"; //~^ string_lit_as_bytes }; } diff --git a/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr b/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr index 9388fbdc775d3..1b54508520dd4 100644 --- a/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr +++ b/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr @@ -26,10 +26,10 @@ LL | let bs = "lit to owned".to_owned().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to owned".to_vec()` error: calling `as_bytes()` on a string literal - --> tests/ui/string_lit_as_bytes.rs:11:26 + --> tests/ui/string_lit_as_bytes.rs:11:28 | LL | const B: &[u8] = $b.as_bytes(); - | ^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"warning"` + | ^^^^^^^^^^^ help: consider using a byte string literal instead: `b"warning"` ... LL | b!("warning"); | ------------- in this macro invocation diff --git a/tests/ui/borrowck/issue-25793.stderr b/tests/ui/borrowck/issue-25793.stderr index e2efc405faba4..b07a42af94acf 100644 --- a/tests/ui/borrowck/issue-25793.stderr +++ b/tests/ui/borrowck/issue-25793.stderr @@ -1,8 +1,8 @@ error[E0503]: cannot use `self.width` because it was mutably borrowed - --> $DIR/issue-25793.rs:4:9 + --> $DIR/issue-25793.rs:4:14 | LL | $this.width.unwrap() - | ^^^^^^^^^^^ use of borrowed `*self` + | ^^^^^^ use of borrowed `*self` ... LL | let r = &mut *self; | ---------- `*self` is borrowed here diff --git a/tests/ui/issues/issue-26237.stderr b/tests/ui/issues/issue-26237.stderr index d15e5753a25e7..451c67f36f8fb 100644 --- a/tests/ui/issues/issue-26237.stderr +++ b/tests/ui/issues/issue-26237.stderr @@ -2,7 +2,7 @@ error[E0618]: expected function, found `{integer}` --> $DIR/issue-26237.rs:10:18 | LL | $not_a_function($some_argument) - | ------------------------------- call expression requires function + | ---------------- call expression requires function ... LL | let mut value_a = 0; | ----------- `value_a` has type `{integer}` diff --git a/tests/ui/issues/issue-39848.stderr b/tests/ui/issues/issue-39848.stderr index 1ffed2d4a1da1..db37769ff668a 100644 --- a/tests/ui/issues/issue-39848.stderr +++ b/tests/ui/issues/issue-39848.stderr @@ -8,10 +8,10 @@ LL | get_opt!(bar, foo); | ------------------ in this macro invocation | note: the `if` expression is missing a block after this condition - --> $DIR/issue-39848.rs:3:12 + --> $DIR/issue-39848.rs:3:16 | LL | if $tgt.has_$field() {} - | ^^^^^^^^^ + | ^^^^^ ... LL | get_opt!(bar, foo); | ------------------ in this macro invocation diff --git a/tests/ui/lint/unused/must-use-macros.stderr b/tests/ui/lint/unused/must-use-macros.stderr index 2ad174e10b501..242bbd18f6282 100644 --- a/tests/ui/lint/unused/must-use-macros.stderr +++ b/tests/ui/lint/unused/must-use-macros.stderr @@ -19,10 +19,10 @@ LL | let _ = cmp!(a, b); | +++++++ warning: unused comparison that must be used - --> $DIR/must-use-macros.rs:41:17 + --> $DIR/must-use-macros.rs:41:19 | LL | $a == $b - | ^^^^^^^^ the comparison produces a value + | ^^^^^^ the comparison produces a value ... LL | cmp!(1, 1); | ---------- in this macro invocation diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 4199ff62e2a30..efb0851594f9f 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -749,10 +749,10 @@ LL + ($a:ident, $b:ident) => { 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:167:37 + --> $DIR/wide_pointer_comparisons.rs:167:39 | LL | ($a:expr, $b:expr) => { $a == $b } - | ^^^^^^^^ + | ^^^^^^ ... LL | cmp!(&a, &b); | ------------ in this macro invocation diff --git a/tests/ui/macros/syntax-error-recovery.stderr b/tests/ui/macros/syntax-error-recovery.stderr index a2059aa1aa802..219cc7c2dd25c 100644 --- a/tests/ui/macros/syntax-error-recovery.stderr +++ b/tests/ui/macros/syntax-error-recovery.stderr @@ -2,7 +2,7 @@ error: expected one of `(`, `,`, `=`, `{`, or `}`, found `ty` metavariable --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, - | ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}` + | ^ expected one of `(`, `,`, `=`, `{`, or `}` ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation @@ -14,7 +14,7 @@ error: macro expansion ignores `ty` metavariable and any tokens following --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, - | ^^^^^^ + | ^ ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- caused by the macro expansion here diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index e90d7a98db4c7..396b2f1b620ff 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -54,7 +54,7 @@ error: expected expression, found `pat` metavariable --> $DIR/trace_faulty_macros.rs:16:9 | LL | $a - | ^^ expected expression + | ^ expected expression ... LL | let a = pat_macro!(); | ------------ in this macro invocation @@ -73,7 +73,7 @@ error: expected expression, found `pat` metavariable --> $DIR/trace_faulty_macros.rs:49:37 | LL | (($p:pat, $e:pat)) => {let $p = $e;}; - | ^^ expected expression + | ^ expected expression ... LL | test!(let x = 1+1); | ------------------ in this macro invocation diff --git a/tests/ui/mismatched_types/issue-26480.stderr b/tests/ui/mismatched_types/issue-26480.stderr index da8d73225f317..4223795df26a2 100644 --- a/tests/ui/mismatched_types/issue-26480.stderr +++ b/tests/ui/mismatched_types/issue-26480.stderr @@ -1,10 +1,10 @@ error[E0308]: mismatched types - --> $DIR/issue-26480.rs:16:19 + --> $DIR/issue-26480.rs:16:23 | LL | write(stdout, $arr.as_ptr() as *const i8, | ----- arguments to this function are incorrect LL | $arr.len() * size_of($arr[0])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `usize` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `usize` ... LL | write!(hello); | ------------- in this macro invocation @@ -17,14 +17,14 @@ LL | fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64; = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit | -LL | ($arr.len() * size_of($arr[0])).try_into().unwrap()); - | + +++++++++++++++++++++ +LL | $arr(.len() * size_of($arr[0])).try_into().unwrap()); + | + +++++++++++++++++++++ error[E0605]: non-primitive cast: `{integer}` as `()` - --> $DIR/issue-26480.rs:22:19 + --> $DIR/issue-26480.rs:22:21 | LL | ($x:expr) => ($x as ()) - | ^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | ^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object ... LL | cast!(2); | -------- in this macro invocation diff --git a/tests/ui/parser/float-field-interpolated.stderr b/tests/ui/parser/float-field-interpolated.stderr index e2b7e3a7dbe75..f0a9d7d82df37 100644 --- a/tests/ui/parser/float-field-interpolated.stderr +++ b/tests/ui/parser/float-field-interpolated.stderr @@ -2,7 +2,7 @@ error: unexpected token: `literal` metavariable --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } - | ^^ + | ^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -13,7 +13,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `literal` metav --> $DIR/float-field-interpolated.rs:8:13 | LL | { s.$b; } - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -24,7 +24,7 @@ error: unexpected token: `expr` metavariable --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } - | ^^ + | ^ ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation @@ -35,7 +35,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `expr` metavari --> $DIR/float-field-interpolated.rs:10:13 | LL | { s.$c; } - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + | ^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | generate_field_accesses!(1.1, 1.1, 1.1); | --------------------------------------- in this macro invocation diff --git a/tests/ui/parser/macro/macro-doc-comments-2.stderr b/tests/ui/parser/macro/macro-doc-comments-2.stderr index 02c12bf959114..0f2e38e9ae349 100644 --- a/tests/ui/parser/macro/macro-doc-comments-2.stderr +++ b/tests/ui/parser/macro/macro-doc-comments-2.stderr @@ -5,10 +5,7 @@ LL | macro_rules! inner { | ------------------ when calling this macro ... LL | /// Outer - | ^^^^^^^^^ - | | - | no rules expected this token in macro call - | outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match + | ^ no rules expected this token in macro call | note: while trying to match `!` --> $DIR/macro-doc-comments-2.rs:2:7 diff --git a/tests/ui/parser/macro/trait-non-item-macros.stderr b/tests/ui/parser/macro/trait-non-item-macros.stderr index 62b42fa8b8dd7..d92e2e97e80a8 100644 --- a/tests/ui/parser/macro/trait-non-item-macros.stderr +++ b/tests/ui/parser/macro/trait-non-item-macros.stderr @@ -2,7 +2,7 @@ error: macro expansion ignores `expr` metavariable and any tokens following --> $DIR/trait-non-item-macros.rs:3:9 | LL | $a - | ^^ + | ^ ... LL | bah!(2); | ------- caused by the macro expansion here diff --git a/tests/ui/suggestions/issue-114701.stderr b/tests/ui/suggestions/issue-114701.stderr index d2a7806b7c123..024c9ff4d1376 100644 --- a/tests/ui/suggestions/issue-114701.stderr +++ b/tests/ui/suggestions/issue-114701.stderr @@ -5,7 +5,7 @@ LL | enum Enum { SVariant { v: T }, UVariant } | -------- `Enum::UVariant` defined here ... LL | assert!(if let Enum::$variant::<()> $matcher = $expr () { true } else { false }, - | -------- call expression requires function + | --- call expression requires function ... LL | is_variant!(UVariant, Enum::<()>::UVariant); | ^^^^^^^^^^^^^^^^^^^^