From 8762fba317922e7346fecad2981e79a8677b8ef4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 27 Nov 2025 19:33:29 +0200 Subject: [PATCH 1/7] expand valid edition range for use-path-segment-kw.rs --- tests/ui/use/use-path-segment-kw.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/use/use-path-segment-kw.rs b/tests/ui/use/use-path-segment-kw.rs index 137a9e18aef30..680ecd3d03d49 100644 --- a/tests/ui/use/use-path-segment-kw.rs +++ b/tests/ui/use/use-path-segment-kw.rs @@ -1,4 +1,4 @@ -//@ edition: 2021 +//@ edition: 2018.. macro_rules! macro_dollar_crate { () => { From 85e24b0d3625f6ae16f61a7e352384b8419401b5 Mon Sep 17 00:00:00 2001 From: Sasha Pourcelot Date: Fri, 28 Nov 2025 19:45:07 +0100 Subject: [PATCH 2/7] Make the capitalization explicit on keyword misspell error --- compiler/rustc_errors/src/emitter.rs | 2 ++ compiler/rustc_parse/messages.ftl | 2 +- compiler/rustc_parse/src/errors.rs | 23 ++++++++++++++-- compiler/rustc_parse/src/parser/mod.rs | 15 ++++++++++- tests/ui/parser/item-kw-case-mismatch.stderr | 28 ++++++++++---------- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index d9132ca123490..d08d5a5a1ea29 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -3544,6 +3544,8 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu let mut has_digit_letter_confusable = false; let mut has_other_diff = false; + // Letters whose lowercase version is very similar to the uppercase + // version. let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z']; let digit_letter_confusables = [('0', 'O'), ('1', 'l'), ('5', 'S'), ('8', 'B'), ('9', 'g')]; diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 7055e60956a9c..bc81acefef743 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -512,7 +512,7 @@ parse_keyword_lifetime = lifetimes cannot use keyword names parse_kw_bad_case = keyword `{$kw}` is written in the wrong case - .suggestion = write it in the correct case + .suggestion = write it in {$case} parse_label_inner_attr_does_not_annotate_this = the inner attribute doesn't annotate this {$item} parse_label_unexpected_token = unexpected token diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 62a333fbf81d7..9344848c76531 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -1,14 +1,15 @@ // ignore-tidy-filelength use std::borrow::Cow; +use std::path::PathBuf; use rustc_ast::token::Token; use rustc_ast::util::parser::ExprPrecedence; use rustc_ast::{Path, Visibility}; use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic, - SuggestionStyle, + Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, + Level, Subdiagnostic, SuggestionStyle, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_session::errors::ExprParenthesesNeeded; @@ -3335,6 +3336,24 @@ pub(crate) struct KwBadCase<'a> { #[suggestion(code = "{kw}", style = "verbose", applicability = "machine-applicable")] pub span: Span, pub kw: &'a str, + pub case: Case, +} + +pub(crate) enum Case { + Upper, + Lower, + Mixed, +} + +impl IntoDiagArg for Case { + fn into_diag_arg(self, path: &mut Option) -> DiagArgValue { + match self { + Case::Upper => "uppercase", + Case::Lower => "lowercase", + Case::Mixed => "the correct case", + } + .into_diag_arg(path) + } } #[derive(Diagnostic)] diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 14a738fb9d247..8577ea40589a8 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -606,7 +606,20 @@ impl<'a> Parser<'a> { // Do an ASCII case-insensitive match, because all keywords are ASCII. && ident.as_str().eq_ignore_ascii_case(exp.kw.as_str()) { - self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw: exp.kw.as_str() }); + let kw = exp.kw.as_str(); + let is_upper = kw.chars().all(char::is_uppercase); + let is_lower = kw.chars().all(char::is_lowercase); + + let case = match (is_upper, is_lower) { + (true, true) => { + unreachable!("keyword that is both fully upper- and fully lowercase") + } + (true, false) => errors::Case::Upper, + (false, true) => errors::Case::Lower, + (false, false) => errors::Case::Mixed, + }; + + self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw, case }); self.bump(); true } else { diff --git a/tests/ui/parser/item-kw-case-mismatch.stderr b/tests/ui/parser/item-kw-case-mismatch.stderr index d2a1eb7f2f521..55cbc6be943cc 100644 --- a/tests/ui/parser/item-kw-case-mismatch.stderr +++ b/tests/ui/parser/item-kw-case-mismatch.stderr @@ -4,7 +4,7 @@ error: keyword `use` is written in the wrong case LL | Use std::ptr::read; | ^^^ | -help: write it in the correct case (notice the capitalization) +help: write it in lowercase (notice the capitalization) | LL - Use std::ptr::read; LL + use std::ptr::read; @@ -16,7 +16,7 @@ error: keyword `use` is written in the wrong case LL | USE std::ptr::write; | ^^^ | -help: write it in the correct case +help: write it in lowercase | LL - USE std::ptr::write; LL + use std::ptr::write; @@ -28,7 +28,7 @@ error: keyword `fn` is written in the wrong case LL | async Fn _a() {} | ^^ | -help: write it in the correct case (notice the capitalization) +help: write it in lowercase (notice the capitalization) | LL - async Fn _a() {} LL + async fn _a() {} @@ -40,7 +40,7 @@ error: keyword `fn` is written in the wrong case LL | Fn _b() {} | ^^ | -help: write it in the correct case (notice the capitalization) +help: write it in lowercase (notice the capitalization) | LL - Fn _b() {} LL + fn _b() {} @@ -52,7 +52,7 @@ error: keyword `async` is written in the wrong case LL | aSYNC fN _c() {} | ^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - aSYNC fN _c() {} LL + async fN _c() {} @@ -64,7 +64,7 @@ error: keyword `fn` is written in the wrong case LL | aSYNC fN _c() {} | ^^ | -help: write it in the correct case +help: write it in lowercase | LL - aSYNC fN _c() {} LL + aSYNC fn _c() {} @@ -76,7 +76,7 @@ error: keyword `async` is written in the wrong case LL | Async fn _d() {} | ^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - Async fn _d() {} LL + async fn _d() {} @@ -88,7 +88,7 @@ error: keyword `const` is written in the wrong case LL | CONST UNSAFE FN _e() {} | ^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - CONST UNSAFE FN _e() {} LL + const UNSAFE FN _e() {} @@ -100,7 +100,7 @@ error: keyword `unsafe` is written in the wrong case LL | CONST UNSAFE FN _e() {} | ^^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - CONST UNSAFE FN _e() {} LL + CONST unsafe FN _e() {} @@ -112,7 +112,7 @@ error: keyword `fn` is written in the wrong case LL | CONST UNSAFE FN _e() {} | ^^ | -help: write it in the correct case +help: write it in lowercase | LL - CONST UNSAFE FN _e() {} LL + CONST UNSAFE fn _e() {} @@ -124,7 +124,7 @@ error: keyword `unsafe` is written in the wrong case LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - unSAFE EXTern "C" fn _f() {} LL + unsafe EXTern "C" fn _f() {} @@ -136,7 +136,7 @@ error: keyword `extern` is written in the wrong case LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - unSAFE EXTern "C" fn _f() {} LL + unSAFE extern "C" fn _f() {} @@ -148,7 +148,7 @@ error: keyword `extern` is written in the wrong case LL | EXTERN "C" FN _g() {} | ^^^^^^ | -help: write it in the correct case +help: write it in lowercase | LL - EXTERN "C" FN _g() {} LL + extern "C" FN _g() {} @@ -160,7 +160,7 @@ error: keyword `fn` is written in the wrong case LL | EXTERN "C" FN _g() {} | ^^ | -help: write it in the correct case +help: write it in lowercase | LL - EXTERN "C" FN _g() {} LL + EXTERN "C" fn _g() {} From 673be1b82a4169ffae9cf4b0bd4ab7435e842a1f Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 28 Nov 2025 14:49:42 -0800 Subject: [PATCH 3/7] Use a delayed bug for this layout ICE Fixes 144501 --- compiler/rustc_errors/src/lib.rs | 2 +- .../rustc_ty_utils/src/layout/invariant.rs | 14 ++++-- .../invalid-niche-discriminant.normal.stderr | 35 ++++++++++++++ .../invalid-niche-discriminant.rs | 25 ++++++++++ ...lid-niche-discriminant.with_delayed.stderr | 47 +++++++++++++++++++ 5 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 tests/ui/enum-discriminant/invalid-niche-discriminant.normal.stderr create mode 100644 tests/ui/enum-discriminant/invalid-niche-discriminant.rs create mode 100644 tests/ui/enum-discriminant/invalid-niche-discriminant.with_delayed.stderr diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index bbdda155496fa..41679e3a68e56 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1366,7 +1366,7 @@ impl<'a> DiagCtxtHandle<'a> { self.create_err(err).emit() } - /// Ensures that an error is printed. See `Level::DelayedBug`. + /// Ensures that an error is printed. See [`Level::DelayedBug`]. // // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't // user-facing. diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index d1484aed16718..01435f7e67a46 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -281,10 +281,16 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou } // Ensure that for niche encoded tags the discriminant coincides with the variant index. - assert_eq!( - layout.ty.discriminant_for_variant(tcx, idx).unwrap().val, - u128::from(idx.as_u32()), - ); + let val = layout.ty.discriminant_for_variant(tcx, idx).unwrap().val; + if val != u128::from(idx.as_u32()) { + let adt_def = layout.ty.ty_adt_def().unwrap(); + cx.tcx().dcx().span_delayed_bug( + cx.tcx().def_span(adt_def.did()), + format!( + "variant {idx:?} has discriminant {val:?} in niche-encoded type" + ), + ); + } } } for variant in variants.iter() { diff --git a/tests/ui/enum-discriminant/invalid-niche-discriminant.normal.stderr b/tests/ui/enum-discriminant/invalid-niche-discriminant.normal.stderr new file mode 100644 index 0000000000000..9c66c1782e4dc --- /dev/null +++ b/tests/ui/enum-discriminant/invalid-niche-discriminant.normal.stderr @@ -0,0 +1,35 @@ +error[E0732]: `#[repr(inttype)]` must be specified for enums with explicit discriminants and non-unit variants + --> $DIR/invalid-niche-discriminant.rs:11:1 + | +LL | enum E { + | ^^^^^^ +... +LL | S0 { + | -- non-unit discriminant declared here +... +LL | Bar = { + | ___________- +LL | | let x = 1; +LL | | 3 +LL | | }, + | |_____- explicit discriminant specified here + +error[E0599]: no variant named `S1` found for enum `E` + --> $DIR/invalid-niche-discriminant.rs:23:18 + | +LL | enum E { + | ------ variant `S1` not found here +... +LL | static C: E = E::S1 { u: 23 }; + | ^^ + | +help: there is a variant with a similar name + | +LL - static C: E = E::S1 { u: 23 }; +LL + static C: E = E::S0 { u: 23 }; + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0599, E0732. +For more information about an error, try `rustc --explain E0599`. diff --git a/tests/ui/enum-discriminant/invalid-niche-discriminant.rs b/tests/ui/enum-discriminant/invalid-niche-discriminant.rs new file mode 100644 index 0000000000000..f70f7d1736bae --- /dev/null +++ b/tests/ui/enum-discriminant/invalid-niche-discriminant.rs @@ -0,0 +1,25 @@ +//@ needs-rustc-debug-assertions +//@ revisions: normal with_delayed +//@ [with_delayed] compile-flags: -Z eagerly-emit-delayed-bugs + +#![crate_type = "lib"] + +// Repro for +// which ICEd because the calculated layout is invalid +// but which we needn't care about as the discriminant already was. + +enum E { +//~^ ERROR must be specified +//[with_delayed]~| ERROR variant 1 has discriminant 3 + S0 { + s: String, + }, + Bar = { + let x = 1; + 3 + }, +} + +static C: E = E::S1 { u: 23 }; +//~^ ERROR no variant named +//[with_delayed]~| ERROR but no error emitted diff --git a/tests/ui/enum-discriminant/invalid-niche-discriminant.with_delayed.stderr b/tests/ui/enum-discriminant/invalid-niche-discriminant.with_delayed.stderr new file mode 100644 index 0000000000000..20f118655a17a --- /dev/null +++ b/tests/ui/enum-discriminant/invalid-niche-discriminant.with_delayed.stderr @@ -0,0 +1,47 @@ +error[E0732]: `#[repr(inttype)]` must be specified for enums with explicit discriminants and non-unit variants + --> $DIR/invalid-niche-discriminant.rs:11:1 + | +LL | enum E { + | ^^^^^^ +... +LL | S0 { + | -- non-unit discriminant declared here +... +LL | Bar = { + | ___________- +LL | | let x = 1; +LL | | 3 +LL | | }, + | |_____- explicit discriminant specified here + +error: variant 1 has discriminant 3 in niche-encoded type + --> $DIR/invalid-niche-discriminant.rs:11:1 + | +LL | enum E { + | ^^^^^^ + +error[E0599]: no variant named `S1` found for enum `E` + --> $DIR/invalid-niche-discriminant.rs:23:18 + | +LL | enum E { + | ------ variant `S1` not found here +... +LL | static C: E = E::S1 { u: 23 }; + | ^^ + | +help: there is a variant with a similar name + | +LL - static C: E = E::S1 { u: 23 }; +LL + static C: E = E::S0 { u: 23 }; + | + +error: `Res::Err` but no error emitted + --> $DIR/invalid-niche-discriminant.rs:23:15 + | +LL | static C: E = E::S1 { u: 23 }; + | ^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0599, E0732. +For more information about an error, try `rustc --explain E0599`. From 77afccf73b0a6eed56ed08768de17434f625ff4a Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 30 Nov 2025 14:14:35 +0900 Subject: [PATCH 4/7] moved and delete test tests/ui/invalid-module-declaration/invalid-module-declaration.rs duplicated of tests/ui/modules/missing_non_modrs_mod_inline.rs --- tests/ui/README.md | 26 ------------------- .../explicit-call-to-dtor.fixed | 0 .../explicit-call-to-dtor.rs | 0 .../explicit-call-to-dtor.stderr | 0 .../explicit-call-to-supertrait-dtor.fixed | 0 .../explicit-call-to-supertrait-dtor.rs | 0 .../explicit-call-to-supertrait-dtor.stderr | 0 .../auxiliary/foo/bar.rs | 1 - .../auxiliary/foo/mod.rs | 1 - .../invalid-module-declaration.rs | 7 ----- .../invalid-module-declaration.stderr | 12 --------- .../explicit-self-lifetime-mismatch.rs | 0 .../explicit-self-lifetime-mismatch.stderr | 0 .../bare-fn-start.rs | 0 .../bare-fn-start.stderr | 0 .../invalid-self-argument.rs} | 0 .../invalid-self-argument.stderr} | 0 .../trait-fn.rs | 0 .../trait-fn.stderr | 0 .../catch-unwind-cell-interior-mut.rs} | 0 .../catch-unwind-cell-interior-mut.stderr} | 0 21 files changed, 47 deletions(-) rename tests/ui/{explicit => drop}/explicit-call-to-dtor.fixed (100%) rename tests/ui/{explicit => drop}/explicit-call-to-dtor.rs (100%) rename tests/ui/{explicit => drop}/explicit-call-to-dtor.stderr (100%) rename tests/ui/{explicit => drop}/explicit-call-to-supertrait-dtor.fixed (100%) rename tests/ui/{explicit => drop}/explicit-call-to-supertrait-dtor.rs (100%) rename tests/ui/{explicit => drop}/explicit-call-to-supertrait-dtor.stderr (100%) delete mode 100644 tests/ui/invalid-module-declaration/auxiliary/foo/bar.rs delete mode 100644 tests/ui/invalid-module-declaration/auxiliary/foo/mod.rs delete mode 100644 tests/ui/invalid-module-declaration/invalid-module-declaration.rs delete mode 100644 tests/ui/invalid-module-declaration/invalid-module-declaration.stderr rename tests/ui/{explicit => lifetimes}/explicit-self-lifetime-mismatch.rs (100%) rename tests/ui/{explicit => lifetimes}/explicit-self-lifetime-mismatch.stderr (100%) rename tests/ui/{invalid-self-argument => self}/bare-fn-start.rs (100%) rename tests/ui/{invalid-self-argument => self}/bare-fn-start.stderr (100%) rename tests/ui/{invalid-self-argument/bare-fn.rs => self/invalid-self-argument.rs} (100%) rename tests/ui/{invalid-self-argument/bare-fn.stderr => self/invalid-self-argument.stderr} (100%) rename tests/ui/{invalid-self-argument => self}/trait-fn.rs (100%) rename tests/ui/{invalid-self-argument => self}/trait-fn.stderr (100%) rename tests/ui/{interior-mutability/interior-mutability.rs => traits/catch-unwind-cell-interior-mut.rs} (100%) rename tests/ui/{interior-mutability/interior-mutability.stderr => traits/catch-unwind-cell-interior-mut.stderr} (100%) diff --git a/tests/ui/README.md b/tests/ui/README.md index 11003bbef9928..344b0b2500df9 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -113,12 +113,6 @@ See [Tracking Issue for autodiff #124509](https://github.com/rust-lang/rust/issu Tests for automatic referencing and dereferencing behavior, such as automatically adding reference operations (`&` or `&mut`) to make a value match a method's receiver type. Sometimes abbreviated as "auto-ref" or "auto-deref". -## `tests/ui/auxiliary/`: Auxiliary files for tests directly under `tests/ui`. - -This top-level `auxiliary` subdirectory contains support files for tests immediately under `tests/ui/`. - -**FIXME(#133895)**: tests immediately under `tests/ui/` should be rehomed to more suitable subdirectories, after which this subdirectory can be removed. - ## `tests/ui/backtrace/`: Backtraces Runtime panics and error handling generate backtraces to assist in debugging and diagnostics. @@ -542,12 +536,6 @@ These tests are about very different topics, only unified by the fact that they Accompanies `tests/ui/error-codes/`, exercises the `--explain` cli flag. -## `tests/ui/explicit/`: Errors involving the concept of "explicit" - -This category contains three tests: two which are about the specific error `explicit use of destructor method`, and one which is about explicit annotation of lifetimes: https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/explicit.html. - -**FIXME**: Rehome the two tests about the destructor method with `drop`-related categories, and rehome the last test with a category related to lifetimes. - ## `tests/ui/explicit-tail-calls/` Exercises `#![feature(explicit_tail_calls)]` and the `become` keyword. See [Explicit Tail Calls #3407](https://github.com/rust-lang/rfcs/pull/3407). @@ -733,10 +721,6 @@ See [Instrument coverage | The rustc book](https://doc.rust-lang.org/rustc/instr See [Tracking issue for `-Z instrument-xray` #102921](https://github.com/rust-lang/rust/issues/102921). -## `tests/ui/interior-mutability/` - -**FIXME**: contains a single test, probably better rehomed. - ## `tests/ui/internal/` Tests for `internal_unstable` and the attribute header `#![feature(allow_internal_unstable)]`, which lets compiler developers mark features as internal to the compiler, and unstable for standard library use. @@ -759,16 +743,6 @@ Various tests related to rejecting invalid inputs. Tests for checking that invalid usage of compiler flags are rejected. -## `tests/ui/invalid-module-declaration/` - -**FIXME**: Consider merging into module/resolve directories. - -## `tests/ui/invalid-self-argument/`: `self` as a function argument incorrectly - -Tests with erroneous ways of using `self`, such as having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). - -**FIXME**: Maybe merge with `ui/self`. - ## `tests/ui/io-checks/` Contains a single test. The test tries to output a file into an invalid directory with `-o`, then checks that the result is an error, not an internal compiler error. diff --git a/tests/ui/explicit/explicit-call-to-dtor.fixed b/tests/ui/drop/explicit-call-to-dtor.fixed similarity index 100% rename from tests/ui/explicit/explicit-call-to-dtor.fixed rename to tests/ui/drop/explicit-call-to-dtor.fixed diff --git a/tests/ui/explicit/explicit-call-to-dtor.rs b/tests/ui/drop/explicit-call-to-dtor.rs similarity index 100% rename from tests/ui/explicit/explicit-call-to-dtor.rs rename to tests/ui/drop/explicit-call-to-dtor.rs diff --git a/tests/ui/explicit/explicit-call-to-dtor.stderr b/tests/ui/drop/explicit-call-to-dtor.stderr similarity index 100% rename from tests/ui/explicit/explicit-call-to-dtor.stderr rename to tests/ui/drop/explicit-call-to-dtor.stderr diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed b/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed similarity index 100% rename from tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed rename to tests/ui/drop/explicit-call-to-supertrait-dtor.fixed diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs b/tests/ui/drop/explicit-call-to-supertrait-dtor.rs similarity index 100% rename from tests/ui/explicit/explicit-call-to-supertrait-dtor.rs rename to tests/ui/drop/explicit-call-to-supertrait-dtor.rs diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr b/tests/ui/drop/explicit-call-to-supertrait-dtor.stderr similarity index 100% rename from tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr rename to tests/ui/drop/explicit-call-to-supertrait-dtor.stderr diff --git a/tests/ui/invalid-module-declaration/auxiliary/foo/bar.rs b/tests/ui/invalid-module-declaration/auxiliary/foo/bar.rs deleted file mode 100644 index bcfd7dc0ade75..0000000000000 --- a/tests/ui/invalid-module-declaration/auxiliary/foo/bar.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod baz; diff --git a/tests/ui/invalid-module-declaration/auxiliary/foo/mod.rs b/tests/ui/invalid-module-declaration/auxiliary/foo/mod.rs deleted file mode 100644 index 46f285ca47d69..0000000000000 --- a/tests/ui/invalid-module-declaration/auxiliary/foo/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod bar; diff --git a/tests/ui/invalid-module-declaration/invalid-module-declaration.rs b/tests/ui/invalid-module-declaration/invalid-module-declaration.rs deleted file mode 100644 index 1c6c282f4b7e6..0000000000000 --- a/tests/ui/invalid-module-declaration/invalid-module-declaration.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod auxiliary { - mod foo; -} - -fn main() {} - -//~? ERROR file not found for module `baz` diff --git a/tests/ui/invalid-module-declaration/invalid-module-declaration.stderr b/tests/ui/invalid-module-declaration/invalid-module-declaration.stderr deleted file mode 100644 index a8f65883d6364..0000000000000 --- a/tests/ui/invalid-module-declaration/invalid-module-declaration.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0583]: file not found for module `baz` - --> $DIR/auxiliary/foo/bar.rs:1:1 - | -LL | pub mod baz; - | ^^^^^^^^^^^^ - | - = help: to create the module `baz`, create file "$DIR/auxiliary/foo/bar/baz.rs" or "$DIR/auxiliary/foo/bar/baz/mod.rs" - = note: if there is a `mod baz` elsewhere in the crate already, import it with `use crate::...` instead - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0583`. diff --git a/tests/ui/explicit/explicit-self-lifetime-mismatch.rs b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs similarity index 100% rename from tests/ui/explicit/explicit-self-lifetime-mismatch.rs rename to tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs diff --git a/tests/ui/explicit/explicit-self-lifetime-mismatch.stderr b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr similarity index 100% rename from tests/ui/explicit/explicit-self-lifetime-mismatch.stderr rename to tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr diff --git a/tests/ui/invalid-self-argument/bare-fn-start.rs b/tests/ui/self/bare-fn-start.rs similarity index 100% rename from tests/ui/invalid-self-argument/bare-fn-start.rs rename to tests/ui/self/bare-fn-start.rs diff --git a/tests/ui/invalid-self-argument/bare-fn-start.stderr b/tests/ui/self/bare-fn-start.stderr similarity index 100% rename from tests/ui/invalid-self-argument/bare-fn-start.stderr rename to tests/ui/self/bare-fn-start.stderr diff --git a/tests/ui/invalid-self-argument/bare-fn.rs b/tests/ui/self/invalid-self-argument.rs similarity index 100% rename from tests/ui/invalid-self-argument/bare-fn.rs rename to tests/ui/self/invalid-self-argument.rs diff --git a/tests/ui/invalid-self-argument/bare-fn.stderr b/tests/ui/self/invalid-self-argument.stderr similarity index 100% rename from tests/ui/invalid-self-argument/bare-fn.stderr rename to tests/ui/self/invalid-self-argument.stderr diff --git a/tests/ui/invalid-self-argument/trait-fn.rs b/tests/ui/self/trait-fn.rs similarity index 100% rename from tests/ui/invalid-self-argument/trait-fn.rs rename to tests/ui/self/trait-fn.rs diff --git a/tests/ui/invalid-self-argument/trait-fn.stderr b/tests/ui/self/trait-fn.stderr similarity index 100% rename from tests/ui/invalid-self-argument/trait-fn.stderr rename to tests/ui/self/trait-fn.stderr diff --git a/tests/ui/interior-mutability/interior-mutability.rs b/tests/ui/traits/catch-unwind-cell-interior-mut.rs similarity index 100% rename from tests/ui/interior-mutability/interior-mutability.rs rename to tests/ui/traits/catch-unwind-cell-interior-mut.rs diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/traits/catch-unwind-cell-interior-mut.stderr similarity index 100% rename from tests/ui/interior-mutability/interior-mutability.stderr rename to tests/ui/traits/catch-unwind-cell-interior-mut.stderr From a4a79500b5e8e848bb9a0db67604d03e9de38ad9 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 30 Nov 2025 14:36:05 +0900 Subject: [PATCH 5/7] Cleaned up some tests fix explicit-call-to-dtor.rs fix explicit-call-to-supertrait-dtor.rs merge issues/issue-17740.rs with lifetimes/explicit-self-lifetime-mismatch.rs merge bare-fn-start.rs and trait-fn.rs into invalid-self-argument.rs add comment tests/ui/traits/catch-unwind-cell-interior-mut --- tests/ui/drop/explicit-call-to-dtor.fixed | 4 +- tests/ui/drop/explicit-call-to-dtor.rs | 4 +- .../explicit-call-to-supertrait-dtor.fixed | 4 +- .../drop/explicit-call-to-supertrait-dtor.rs | 4 +- tests/ui/issues/issue-17740.rs | 20 ------ tests/ui/issues/issue-17740.stderr | 41 ----------- .../explicit-self-lifetime-mismatch.rs | 45 ++++++++---- .../explicit-self-lifetime-mismatch.stderr | 72 ++++++++++++++----- tests/ui/self/bare-fn-start.rs | 6 -- tests/ui/self/bare-fn-start.stderr | 10 --- tests/ui/self/invalid-self-argument.rs | 21 +++++- tests/ui/self/invalid-self-argument.stderr | 20 +++++- tests/ui/self/trait-fn.rs | 11 --- tests/ui/self/trait-fn.stderr | 8 --- .../traits/catch-unwind-cell-interior-mut.rs | 1 + .../catch-unwind-cell-interior-mut.stderr | 4 +- 16 files changed, 134 insertions(+), 141 deletions(-) delete mode 100644 tests/ui/issues/issue-17740.rs delete mode 100644 tests/ui/issues/issue-17740.stderr delete mode 100644 tests/ui/self/bare-fn-start.rs delete mode 100644 tests/ui/self/bare-fn-start.stderr delete mode 100644 tests/ui/self/trait-fn.rs delete mode 100644 tests/ui/self/trait-fn.stderr diff --git a/tests/ui/drop/explicit-call-to-dtor.fixed b/tests/ui/drop/explicit-call-to-dtor.fixed index 4c4142c79811d..167f557a6125a 100644 --- a/tests/ui/drop/explicit-call-to-dtor.fixed +++ b/tests/ui/drop/explicit-call-to-dtor.fixed @@ -1,6 +1,6 @@ //@ run-rustfix struct Foo { - x: isize + x: isize, } impl Drop for Foo { @@ -12,5 +12,5 @@ impl Drop for Foo { fn main() { let x = Foo { x: 3 }; println!("{}", x.x); - drop(x); //~ ERROR explicit use of destructor method + drop(x); //~ ERROR explicit use of destructor method } diff --git a/tests/ui/drop/explicit-call-to-dtor.rs b/tests/ui/drop/explicit-call-to-dtor.rs index 262dde54c7f6a..2c4e013f5c94d 100644 --- a/tests/ui/drop/explicit-call-to-dtor.rs +++ b/tests/ui/drop/explicit-call-to-dtor.rs @@ -1,6 +1,6 @@ //@ run-rustfix struct Foo { - x: isize + x: isize, } impl Drop for Foo { @@ -12,5 +12,5 @@ impl Drop for Foo { fn main() { let x = Foo { x: 3 }; println!("{}", x.x); - x.drop(); //~ ERROR explicit use of destructor method + x.drop(); //~ ERROR explicit use of destructor method } diff --git a/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed b/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed index 57cb858aa0895..1526f7b46ea1b 100644 --- a/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed +++ b/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed @@ -4,7 +4,7 @@ #![allow(dropping_references)] struct Foo { - x: isize + x: isize, } #[allow(drop_bounds)] @@ -20,7 +20,7 @@ impl Drop for Foo { impl Bar for Foo { fn blah(&self) { - drop(self); //~ ERROR explicit use of destructor method + drop(self); //~ ERROR explicit use of destructor method } } diff --git a/tests/ui/drop/explicit-call-to-supertrait-dtor.rs b/tests/ui/drop/explicit-call-to-supertrait-dtor.rs index bb29e49524205..2de3d008aaaea 100644 --- a/tests/ui/drop/explicit-call-to-supertrait-dtor.rs +++ b/tests/ui/drop/explicit-call-to-supertrait-dtor.rs @@ -4,7 +4,7 @@ #![allow(dropping_references)] struct Foo { - x: isize + x: isize, } #[allow(drop_bounds)] @@ -20,7 +20,7 @@ impl Drop for Foo { impl Bar for Foo { fn blah(&self) { - self.drop(); //~ ERROR explicit use of destructor method + self.drop(); //~ ERROR explicit use of destructor method } } diff --git a/tests/ui/issues/issue-17740.rs b/tests/ui/issues/issue-17740.rs deleted file mode 100644 index 20a73756ea3ea..0000000000000 --- a/tests/ui/issues/issue-17740.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ dont-require-annotations: NOTE - -struct Foo<'a> { - data: &'a[u8], -} - -impl <'a> Foo<'a>{ - fn bar(self: &mut Foo) { - //~^ ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a>` - //~| NOTE found struct `Foo<'_>` - //~| NOTE lifetime mismatch - //~| ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a>` - //~| NOTE found struct `Foo<'_>` - //~| NOTE lifetime mismatch - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-17740.stderr b/tests/ui/issues/issue-17740.stderr deleted file mode 100644 index 198d7d5b37cc7..0000000000000 --- a/tests/ui/issues/issue-17740.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:8:18 - | -LL | fn bar(self: &mut Foo) { - | ^^^^^^^^ lifetime mismatch - | - = note: expected struct `Foo<'a>` - found struct `Foo<'_>` -note: the anonymous lifetime defined here... - --> $DIR/issue-17740.rs:8:23 - | -LL | fn bar(self: &mut Foo) { - | ^^^ -note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/issue-17740.rs:7:7 - | -LL | impl <'a> Foo<'a>{ - | ^^ - -error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:8:18 - | -LL | fn bar(self: &mut Foo) { - | ^^^^^^^^ lifetime mismatch - | - = note: expected struct `Foo<'a>` - found struct `Foo<'_>` -note: the lifetime `'a` as defined here... - --> $DIR/issue-17740.rs:7:7 - | -LL | impl <'a> Foo<'a>{ - | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-17740.rs:8:23 - | -LL | fn bar(self: &mut Foo) { - | ^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs index aa5e352b6ebef..88b9d86a9fdf6 100644 --- a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs +++ b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs @@ -1,22 +1,41 @@ //@ dont-require-annotations: NOTE +//! regression test for -struct Foo<'a,'b> { +struct Foo<'a, 'b> { x: &'a isize, y: &'b isize, } -impl<'a,'b> Foo<'a,'b> { - fn bar(self: - Foo<'b,'a> - //~^ ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a, 'b>` - //~| NOTE found struct `Foo<'b, 'a>` - //~| NOTE lifetime mismatch - //~| ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a, 'b>` - //~| NOTE found struct `Foo<'b, 'a>` - //~| NOTE lifetime mismatch - ) {} +impl<'a, 'b> Foo<'a, 'b> { + fn bar( + self: Foo<'b, 'a>, + //~^ ERROR mismatched `self` parameter type + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch + //~| ERROR mismatched `self` parameter type + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch + ) { + } +} + +struct Bar<'a> { + data: &'a [u8], +} + +impl<'a> Bar<'a> { + fn bar(self: &mut Bar) { + //~^ ERROR mismatched `self` parameter type + //~| NOTE expected struct `Bar<'a>` + //~| NOTE found struct `Bar<'_>` + //~| NOTE lifetime mismatch + //~| ERROR mismatched `self` parameter type + //~| NOTE expected struct `Bar<'a>` + //~| NOTE found struct `Bar<'_>` + //~| NOTE lifetime mismatch + } } fn main() {} diff --git a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr index a20901e8c74d2..ebd6383cb4de5 100644 --- a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr +++ b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr @@ -1,41 +1,79 @@ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:11:15 | -LL | Foo<'b,'a> - | ^^^^^^^^^^ lifetime mismatch +LL | self: Foo<'b, 'a>, + | ^^^^^^^^^^^ lifetime mismatch | = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'b` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:10 | -LL | impl<'a,'b> Foo<'a,'b> { - | ^^ +LL | impl<'a, 'b> Foo<'a, 'b> { + | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:6 | -LL | impl<'a,'b> Foo<'a,'b> { +LL | impl<'a, 'b> Foo<'a, 'b> { | ^^ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:11:15 | -LL | Foo<'b,'a> - | ^^^^^^^^^^ lifetime mismatch +LL | self: Foo<'b, 'a>, + | ^^^^^^^^^^^ lifetime mismatch | = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'a` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:6 | -LL | impl<'a,'b> Foo<'a,'b> { +LL | impl<'a, 'b> Foo<'a, 'b> { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:10 | -LL | impl<'a,'b> Foo<'a,'b> { - | ^^ +LL | impl<'a, 'b> Foo<'a, 'b> { + | ^^ -error: aborting due to 2 previous errors +error[E0308]: mismatched `self` parameter type + --> $DIR/explicit-self-lifetime-mismatch.rs:29:18 + | +LL | fn bar(self: &mut Bar) { + | ^^^^^^^^ lifetime mismatch + | + = note: expected struct `Bar<'a>` + found struct `Bar<'_>` +note: the anonymous lifetime defined here... + --> $DIR/explicit-self-lifetime-mismatch.rs:29:23 + | +LL | fn bar(self: &mut Bar) { + | ^^^ +note: ...does not necessarily outlive the lifetime `'a` as defined here + --> $DIR/explicit-self-lifetime-mismatch.rs:28:6 + | +LL | impl<'a> Bar<'a> { + | ^^ + +error[E0308]: mismatched `self` parameter type + --> $DIR/explicit-self-lifetime-mismatch.rs:29:18 + | +LL | fn bar(self: &mut Bar) { + | ^^^^^^^^ lifetime mismatch + | + = note: expected struct `Bar<'a>` + found struct `Bar<'_>` +note: the lifetime `'a` as defined here... + --> $DIR/explicit-self-lifetime-mismatch.rs:28:6 + | +LL | impl<'a> Bar<'a> { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime defined here + --> $DIR/explicit-self-lifetime-mismatch.rs:29:23 + | +LL | fn bar(self: &mut Bar) { + | ^^^ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/self/bare-fn-start.rs b/tests/ui/self/bare-fn-start.rs deleted file mode 100644 index 7c580bc5a5dea..0000000000000 --- a/tests/ui/self/bare-fn-start.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn a(&self) { } -//~^ ERROR `self` parameter is only allowed in associated functions -//~| NOTE not semantically valid as function parameter -//~| NOTE associated functions are those in `impl` or `trait` definitions - -fn main() { } diff --git a/tests/ui/self/bare-fn-start.stderr b/tests/ui/self/bare-fn-start.stderr deleted file mode 100644 index bf7160bcd2d35..0000000000000 --- a/tests/ui/self/bare-fn-start.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `self` parameter is only allowed in associated functions - --> $DIR/bare-fn-start.rs:1:6 - | -LL | fn a(&self) { } - | ^^^^^ not semantically valid as function parameter - | - = note: associated functions are those in `impl` or `trait` definitions - -error: aborting due to 1 previous error - diff --git a/tests/ui/self/invalid-self-argument.rs b/tests/ui/self/invalid-self-argument.rs index 342bdc31a7c82..fef687e194cbb 100644 --- a/tests/ui/self/invalid-self-argument.rs +++ b/tests/ui/self/invalid-self-argument.rs @@ -1,5 +1,22 @@ -fn b(foo: u32, &mut self) { } +//! regression test for + +fn a(&self) {} +//~^ ERROR `self` parameter is only allowed in associated functions +//~| NOTE not semantically valid as function parameter +//~| NOTE associated functions are those in `impl` or `trait` definitions + +fn b(foo: u32, &mut self) {} //~^ ERROR unexpected `self` parameter in function //~| NOTE must be the first parameter of an associated function -fn main() { } +struct Foo {} + +impl Foo { + fn c(foo: u32, self) {} + //~^ ERROR unexpected `self` parameter in function + //~| NOTE must be the first parameter of an associated function + + fn good(&mut self, foo: u32) {} +} + +fn main() {} diff --git a/tests/ui/self/invalid-self-argument.stderr b/tests/ui/self/invalid-self-argument.stderr index 7abb56602d4bc..c92e5b2492bff 100644 --- a/tests/ui/self/invalid-self-argument.stderr +++ b/tests/ui/self/invalid-self-argument.stderr @@ -1,8 +1,22 @@ error: unexpected `self` parameter in function - --> $DIR/bare-fn.rs:1:16 + --> $DIR/invalid-self-argument.rs:8:16 | -LL | fn b(foo: u32, &mut self) { } +LL | fn b(foo: u32, &mut self) {} | ^^^^^^^^^ must be the first parameter of an associated function -error: aborting due to 1 previous error +error: unexpected `self` parameter in function + --> $DIR/invalid-self-argument.rs:15:20 + | +LL | fn c(foo: u32, self) {} + | ^^^^ must be the first parameter of an associated function + +error: `self` parameter is only allowed in associated functions + --> $DIR/invalid-self-argument.rs:3:6 + | +LL | fn a(&self) {} + | ^^^^^ not semantically valid as function parameter + | + = note: associated functions are those in `impl` or `trait` definitions + +error: aborting due to 3 previous errors diff --git a/tests/ui/self/trait-fn.rs b/tests/ui/self/trait-fn.rs deleted file mode 100644 index 5ccea589561cb..0000000000000 --- a/tests/ui/self/trait-fn.rs +++ /dev/null @@ -1,11 +0,0 @@ -struct Foo {} - -impl Foo { - fn c(foo: u32, self) {} - //~^ ERROR unexpected `self` parameter in function - //~| NOTE must be the first parameter of an associated function - - fn good(&mut self, foo: u32) {} -} - -fn main() { } diff --git a/tests/ui/self/trait-fn.stderr b/tests/ui/self/trait-fn.stderr deleted file mode 100644 index c9d0a338ef428..0000000000000 --- a/tests/ui/self/trait-fn.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected `self` parameter in function - --> $DIR/trait-fn.rs:4:20 - | -LL | fn c(foo: u32, self) {} - | ^^^^ must be the first parameter of an associated function - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/catch-unwind-cell-interior-mut.rs b/tests/ui/traits/catch-unwind-cell-interior-mut.rs index 7e4fe76852d76..cfc52322399fd 100644 --- a/tests/ui/traits/catch-unwind-cell-interior-mut.rs +++ b/tests/ui/traits/catch-unwind-cell-interior-mut.rs @@ -1,3 +1,4 @@ +//! related issue: //@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::panic::catch_unwind; diff --git a/tests/ui/traits/catch-unwind-cell-interior-mut.stderr b/tests/ui/traits/catch-unwind-cell-interior-mut.stderr index b307d608a1fd9..6f58c880554a6 100644 --- a/tests/ui/traits/catch-unwind-cell-interior-mut.stderr +++ b/tests/ui/traits/catch-unwind-cell-interior-mut.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:6:18 + --> $DIR/catch-unwind-cell-interior-mut.rs:7:18 | LL | catch_unwind(|| { x.set(23); }); | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary @@ -11,7 +11,7 @@ note: required because it appears within the type `Cell` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell` to implement `UnwindSafe` note: required because it's used within this closure - --> $DIR/interior-mutability.rs:6:18 + --> $DIR/catch-unwind-cell-interior-mut.rs:7:18 | LL | catch_unwind(|| { x.set(23); }); | ^^ From 31106eb75252ef0bb8c2be5ef62af75b78746158 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 1 Dec 2025 21:49:40 +0900 Subject: [PATCH 6/7] Update the comment in the add_typo_suggestion function --- compiler/rustc_resolve/src/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 2f4a18f9cfa6b..c8e5fd3a21f8f 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1900,7 +1900,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if span.overlaps(def_span) { // Don't suggest typo suggestion for itself like in the following: // error[E0423]: expected function, tuple struct or tuple variant, found struct `X` - // --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14 + // --> $DIR/unicode-string-literal-syntax-error-64792.rs:4:14 // | // LL | struct X {} // | ----------- `X` defined here From c435a5f17fe5a5028aedac0b56f57f45da0710cb Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 1 Dec 2025 16:28:18 +0100 Subject: [PATCH 7/7] fix: Fix proc-macro-srv passing invalid extra none group to proc-macros --- .../src/legacy_protocol/msg/flat.rs | 4 +--- .../crates/proc-macro-srv/src/tests/mod.rs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs index 425bd9bb37a52..92e9038554eb6 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs @@ -962,8 +962,6 @@ impl Reader<'_, T> { }; res[i] = Some(g); } - proc_macro_srv::TokenStream::new(vec![proc_macro_srv::TokenTree::Group( - res[0].take().unwrap(), - )]) + res[0].take().unwrap().stream.unwrap_or_default() } } diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs index ad3d9eef957f2..20507a6def54d 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs @@ -297,26 +297,38 @@ fn test_fn_like_macro_noop() { fn test_fn_like_macro_clone_ident_subtree() { assert_expand( "fn_like_clone_tokens", - r#"ident, []"#, + r#"ident, [ident2, ident3]"#, expect![[r#" IDENT 1 ident PUNCT 1 , [alone] GROUP [] 1 1 1 + IDENT 1 ident2 + PUNCT 1 , [alone] + IDENT 1 ident3 IDENT 1 ident PUNCT 1 , [alone] GROUP [] 1 1 1 + IDENT 1 ident2 + PUNCT 1 , [alone] + IDENT 1 ident3 "#]], expect![[r#" IDENT 42:Root[0000, 0]@0..5#ROOT2024 ident PUNCT 42:Root[0000, 0]@5..6#ROOT2024 , [alone] - GROUP [] 42:Root[0000, 0]@7..8#ROOT2024 42:Root[0000, 0]@8..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024 + GROUP [] 42:Root[0000, 0]@7..8#ROOT2024 42:Root[0000, 0]@22..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024 + IDENT 42:Root[0000, 0]@8..14#ROOT2024 ident2 + PUNCT 42:Root[0000, 0]@14..15#ROOT2024 , [alone] + IDENT 42:Root[0000, 0]@16..22#ROOT2024 ident3 IDENT 42:Root[0000, 0]@0..5#ROOT2024 ident PUNCT 42:Root[0000, 0]@5..6#ROOT2024 , [alone] - GROUP [] 42:Root[0000, 0]@7..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024 42:Root[0000, 0]@7..9#ROOT2024 + GROUP [] 42:Root[0000, 0]@7..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024 42:Root[0000, 0]@7..23#ROOT2024 + IDENT 42:Root[0000, 0]@8..14#ROOT2024 ident2 + PUNCT 42:Root[0000, 0]@14..15#ROOT2024 , [alone] + IDENT 42:Root[0000, 0]@16..22#ROOT2024 ident3 "#]], ); }