From f01082b8fb1e94ff5fd2162d62f8b6679ead2b86 Mon Sep 17 00:00:00 2001 From: Nia Deckers Date: Fri, 28 Aug 2026 20:13:12 +0200 Subject: [PATCH 01/13] generalise impls on box --- library/alloc/src/boxed.rs | 2 +- library/alloc/src/io/impls.rs | 8 ++++---- library/std/src/os/fd/owned.rs | 3 ++- library/std/src/os/fd/raw.rs | 3 ++- library/std/src/os/solid/io.rs | 3 ++- library/std/src/os/windows/io/handle.rs | 3 ++- library/std/src/os/windows/io/socket.rs | 3 ++- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 613791448eb5b..e5fc3246f0192 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2473,7 +2473,7 @@ impl Future for Box { } #[stable(feature = "box_error", since = "1.8.0")] -impl Error for Box { +impl Error for Box { #[allow(deprecated)] fn cause(&self) -> Option<&dyn Error> { Error::cause(&**self) diff --git a/library/alloc/src/io/impls.rs b/library/alloc/src/io/impls.rs index 0296cada74171..b16d7b424c163 100644 --- a/library/alloc/src/io/impls.rs +++ b/library/alloc/src/io/impls.rs @@ -92,7 +92,7 @@ impl BufRead for &mut B { } #[stable(feature = "rust1", since = "1.0.0")] -impl Read for Box { +impl Read for Box { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { (**self).read(buf) @@ -148,7 +148,7 @@ impl SizeHint for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl Write for Box { +impl Write for Box { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) @@ -185,7 +185,7 @@ impl Write for Box { } } #[stable(feature = "rust1", since = "1.0.0")] -impl Seek for Box { +impl Seek for Box { #[inline] fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) @@ -212,7 +212,7 @@ impl Seek for Box { } } #[stable(feature = "rust1", since = "1.0.0")] -impl BufRead for Box { +impl BufRead for Box { #[inline] fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index 4ed5c43616a29..87a8e20bad0d3 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -7,6 +7,7 @@ use moto_rt::libc; use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use crate::alloc::Allocator; #[cfg(not(target_os = "trusty"))] use crate::fs; use crate::marker::PhantomData; @@ -474,7 +475,7 @@ impl AsFd for crate::rc::UniqueRc { } #[stable(feature = "asfd_ptrs", since = "1.64.0")] -impl AsFd for Box { +impl AsFd for Box { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { (**self).as_fd() diff --git a/library/std/src/os/fd/raw.rs b/library/std/src/os/fd/raw.rs index a0c96e2836fc5..a8d981520efd2 100644 --- a/library/std/src/os/fd/raw.rs +++ b/library/std/src/os/fd/raw.rs @@ -9,6 +9,7 @@ use moto_rt::libc; #[cfg(target_os = "motor")] use super::owned::OwnedFd; +use crate::alloc::Allocator; #[cfg(not(target_os = "trusty"))] use crate::fs; use crate::io; @@ -282,7 +283,7 @@ impl AsRawFd for crate::rc::UniqueRc { } #[stable(feature = "asrawfd_ptrs", since = "1.63.0")] -impl AsRawFd for Box { +impl AsRawFd for Box { #[inline] fn as_raw_fd(&self) -> RawFd { (**self).as_raw_fd() diff --git a/library/std/src/os/solid/io.rs b/library/std/src/os/solid/io.rs index d4defb5f47fb0..ff79f192819ce 100644 --- a/library/std/src/os/solid/io.rs +++ b/library/std/src/os/solid/io.rs @@ -46,6 +46,7 @@ #![unstable(feature = "solid_ext", issue = "none")] +use crate::alloc::Allocator; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; use crate::sys::{AsInner, FromInner, IntoInner}; @@ -283,7 +284,7 @@ impl AsFd for crate::rc::Rc { } } -impl AsFd for Box { +impl AsFd for Box { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { (**self).as_fd() diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs index 29697bbb5f8fc..01bd36155b110 100644 --- a/library/std/src/os/windows/io/handle.rs +++ b/library/std/src/os/windows/io/handle.rs @@ -3,6 +3,7 @@ #![stable(feature = "io_safety", since = "1.63.0")] use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; +use crate::alloc::Allocator; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; use crate::sys::{AsInner, FromInner, IntoInner, cvt}; @@ -491,7 +492,7 @@ impl AsHandle for crate::rc::UniqueRc { } #[stable(feature = "as_windows_ptrs", since = "1.71.0")] -impl AsHandle for Box { +impl AsHandle for Box { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { (**self).as_handle() diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs index ae1b7eaee8d12..d625a9ac52730 100644 --- a/library/std/src/os/windows/io/socket.rs +++ b/library/std/src/os/windows/io/socket.rs @@ -3,6 +3,7 @@ #![stable(feature = "io_safety", since = "1.63.0")] use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; +use crate::alloc::Allocator; use crate::marker::PhantomData; use crate::mem::{self, ManuallyDrop}; #[cfg(not(target_vendor = "uwp"))] @@ -275,7 +276,7 @@ impl AsSocket for crate::rc::UniqueRc { } #[stable(feature = "as_windows_ptrs", since = "1.71.0")] -impl AsSocket for Box { +impl AsSocket for Box { #[inline] fn as_socket(&self) -> BorrowedSocket<'_> { (**self).as_socket() From 61b55327cf2640a1da2ebba487f22f277035e7b8 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Tue, 4 Aug 2026 22:22:22 +0530 Subject: [PATCH 02/13] fix: fix no resolution for self import in namespaced crates --- compiler/rustc_resolve/src/ident.rs | 5 +++++ tests/ui/resolve/auxiliary/namespaced_crate_utils.rs | 1 + tests/ui/resolve/namespaced-crate-self-import.rs | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/ui/resolve/auxiliary/namespaced_crate_utils.rs create mode 100644 tests/ui/resolve/namespaced-crate-self-import.rs diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index ebcdb8603eccd..243fcc8f9c0ab 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1030,6 +1030,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) } ModuleOrUniformRoot::OpenModule(sym) => { + if ident.name == kw::SelfLower && ns == TypeNS { + let res = Res::OpenMod(sym); + return Ok(self.arenas.new_pub_def_decl(res, ident.span, LocalExpnId::ROOT)); + } + let open_ns_name = format!("{}::{}", sym.as_str(), ident.name); let ns_ident = IdentKey::with_root_ctxt(Symbol::intern(&open_ns_name)); match self.extern_prelude_get_flag(ns_ident, ident.span, finalize.is_some()) { diff --git a/tests/ui/resolve/auxiliary/namespaced_crate_utils.rs b/tests/ui/resolve/auxiliary/namespaced_crate_utils.rs new file mode 100644 index 0000000000000..cdc6c27d800bd --- /dev/null +++ b/tests/ui/resolve/auxiliary/namespaced_crate_utils.rs @@ -0,0 +1 @@ +pub fn f() {} diff --git a/tests/ui/resolve/namespaced-crate-self-import.rs b/tests/ui/resolve/namespaced-crate-self-import.rs new file mode 100644 index 0000000000000..96cc85f980c0d --- /dev/null +++ b/tests/ui/resolve/namespaced-crate-self-import.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Znamespaced-crates +//@ edition: 2024 +//@ check-pass +//@ aux-crate:my_api::utils=namespaced_crate_utils.rs + +use alias::utils; +use my_api as alias; + +fn main() {} From 25a888f7ae6853cd895e8881829d4eaba0764751 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Sat, 5 Sep 2026 14:51:06 +0530 Subject: [PATCH 03/13] fix: fix test to actually have a trailing self --- tests/ui/resolve/namespaced-crate-self-import.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/resolve/namespaced-crate-self-import.rs b/tests/ui/resolve/namespaced-crate-self-import.rs index 96cc85f980c0d..23fac433c4578 100644 --- a/tests/ui/resolve/namespaced-crate-self-import.rs +++ b/tests/ui/resolve/namespaced-crate-self-import.rs @@ -4,6 +4,6 @@ //@ aux-crate:my_api::utils=namespaced_crate_utils.rs use alias::utils; -use my_api as alias; +use my_api::{self as alias, utils as direct_utils}; fn main() {} From 2f5678e30b580781cac35046c347776b0208aed5 Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Mon, 7 Sep 2026 03:12:15 -0500 Subject: [PATCH 04/13] fix 0-length array formatting --- src/etc/lldb_providers.py | 3 +++ tests/debuginfo/vec-slices.rs | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index c6ee751b6bd0d..2791dae3600b0 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -545,6 +545,9 @@ def f16SummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: def sequence_formatter(output: str, valobj: SBValue, _dict: LLDBOpaque): length: int = valobj.GetNumChildren() + if length == 0: + return output + long: bool = False for i in range(0, length): if len(output) > 32: diff --git a/tests/debuginfo/vec-slices.rs b/tests/debuginfo/vec-slices.rs index 1657e55c1cfdc..26606a0ce7ece 100644 --- a/tests/debuginfo/vec-slices.rs +++ b/tests/debuginfo/vec-slices.rs @@ -1,3 +1,7 @@ +//@ revisions: msvc non-msvc + +//@ [msvc] only-msvc +//@ [non-msvc] ignore-msvc //@ ignore-gdb-version: 15.0 - 99.0 // ^ test temporarily disabled as it fails under gdb 15 @@ -55,22 +59,29 @@ //@ lldb-command:run //@ lldb-command:v empty -//@ lldb-check:[...] size=0 +//@ [non-msvc] lldb-check:[...] size=0 +//@ [msvc] lldb-check: [] //@ lldb-command:v singleton -//@ lldb-check:[...] size=1 { [0] = 1 } +//@ [non-msvc] lldb-check:[...] size=1 { [0] = 1 } +//@ [msvc] lldb-check:[...] [1] { [0] = 1 } //@ lldb-command:v multiple -//@ lldb-check:[...] size=4 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 } +//@ [non-msvc] lldb-check:[...] size=4 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 } +//@ [msvc] lldb-check:[...] [2, 3, 4, 5] { [0] = 2 [1] = 3 [2] = 4 [3] = 5 } //@ lldb-command:v slice_of_slice -//@ lldb-check:[...] size=2 { [0] = 3 [1] = 4 } +//@ [non-msvc] lldb-check:[...] size=2 { [0] = 3 [1] = 4 } +//@ [msvc] lldb-check:[...] [3, 4] { [0] = 3 [1] = 4 } //@ lldb-command:v padded_tuple -//@ lldb-check:[...] size=2 { [0] = (6, 7) [1] = (8, 9) } +//@ [non-msvc] lldb-check:[...] size=2 { [0] = (6, 7) [1] = (8, 9) } +//@ [msvc] lldb-check:[...] [(6, 7), (8, 9)] { [0] = (6, 7) [1] = (8, 9) } //@ lldb-command:v padded_struct -//@ lldb-check:[...] size=2 { [0] = {x:10, y:11, z:12} [1] = {x:13, y:14, z:15} } +//@ [non-msvc] lldb-check:[...] size=2 { [0] = {x:10, y:11, z:12} [1] = {x:13, y:14, z:15} } +// ignore-tidy-linelength +//@ [msvc] lldb-check:[...] [{x:10, y:11, z:12}, {x:13, y:14, z:15}] { [0] = {x:10, y:11, z:12} [1] = {x:13, y:14, z:15} } #![allow(dead_code, unused_variables)] From ca69880cd9548cd9fc7b82908a745ae17d6890af Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Mon, 7 Sep 2026 04:07:53 -0500 Subject: [PATCH 05/13] Add msvc revisions to some debuginfo tests --- tests/debuginfo/basic-types-globals.rs | 62 ++++++++++----------- tests/debuginfo/borrowed-unique-basic.rs | 1 + tests/debuginfo/captured-fields-1.rs | 12 ++-- tests/debuginfo/generic-struct.rs | 18 ++++-- tests/debuginfo/method-on-generic-struct.rs | 19 +++++-- tests/debuginfo/no_mangle-info.rs | 20 +++++-- tests/debuginfo/pretty-slices.rs | 10 +++- tests/debuginfo/strings-and-strs.rs | 6 +- tests/debuginfo/thread-names.rs | 13 +++-- 9 files changed, 99 insertions(+), 62 deletions(-) diff --git a/tests/debuginfo/basic-types-globals.rs b/tests/debuginfo/basic-types-globals.rs index 819a016401a98..c8694bfcc7505 100644 --- a/tests/debuginfo/basic-types-globals.rs +++ b/tests/debuginfo/basic-types-globals.rs @@ -1,6 +1,6 @@ //@ revisions: lto no-lto -//@ compile-flags:-g +//@ compile-flags:-g --crate-name=basic_types_globals //@ disable-gdb-pretty-printers //@ [lto] compile-flags:-C lto @@ -8,36 +8,36 @@ //@ ignore-backends: gcc //@ lldb-command:run -//@ lldb-command:v B -//@ lldb-check: ::B = false -//@ lldb-command:v I -//@ lldb-check: ::I = -1 -//@ lldb-command:v --format=d C -//@ lldb-check: ::C = 97 U+0x00000061 U'a' -//@ lldb-command:v --format=d I8 -//@ lldb-check: ::I8 = 68 -//@ lldb-command:v I16 -//@ lldb-check: ::I16 = -16 -//@ lldb-command:v I32 -//@ lldb-check: ::I32 = -32 -//@ lldb-command:v I64 -//@ lldb-check: ::I64 = -64 -//@ lldb-command:v U -//@ lldb-check: ::U = 1 -//@ lldb-command:v --format=d U8 -//@ lldb-check: ::U8 = 100 -//@ lldb-command:v U16 -//@ lldb-check: ::U16 = 16 -//@ lldb-command:v U32 -//@ lldb-check: ::U32 = 32 -//@ lldb-command:v U64 -//@ lldb-check: ::U64 = 64 -//@ lldb-command:v F16 -//@ lldb-check: ::F16 = 1.5 -//@ lldb-command:v F32 -//@ lldb-check: ::F32 = 2.5 -//@ lldb-command:v F64 -//@ lldb-check: ::F64 = 3.5 +//@ lldb-command:v basic_types_globals::B +//@ lldb-check:[...]basic_types_globals::B = false +//@ lldb-command:v basic_types_globals::I +//@ lldb-check:[...]basic_types_globals::I = -1 +//@ lldb-command:v basic_types_globals::C +//@ lldb-check:[...]basic_types_globals::C = U+0x00000061 U'a' +//@ lldb-command:v basic_types_globals::I8 +//@ lldb-check:[...]basic_types_globals::I8 = 68 +//@ lldb-command:v basic_types_globals::I16 +//@ lldb-check:[...]basic_types_globals::I16 = -16 +//@ lldb-command:v basic_types_globals::I32 +//@ lldb-check:[...]basic_types_globals::I32 = -32 +//@ lldb-command:v basic_types_globals::I64 +//@ lldb-check:[...]basic_types_globals::I64 = -64 +//@ lldb-command:v basic_types_globals::U +//@ lldb-check:[...]basic_types_globals::U = 1 +//@ lldb-command:v basic_types_globals::U8 +//@ lldb-check:[...]basic_types_globals::U8 = 100 +//@ lldb-command:v basic_types_globals::U16 +//@ lldb-check:[...]basic_types_globals::U16 = 16 +//@ lldb-command:v basic_types_globals::U32 +//@ lldb-check:[...]basic_types_globals::U32 = 32 +//@ lldb-command:v basic_types_globals::U64 +//@ lldb-check:[...]basic_types_globals::U64 = 64 +//@ lldb-command:v basic_types_globals::F16 +//@ lldb-check:[...]basic_types_globals::F16 = 1.5 +//@ lldb-command:v basic_types_globals::F32 +//@ lldb-check:[...]basic_types_globals::F32 = 2.5 +//@ lldb-command:v basic_types_globals::F64 +//@ lldb-check:[...]basic_types_globals::F64 = 3.5 //@ gdb-command:run //@ gdb-command:print B diff --git a/tests/debuginfo/borrowed-unique-basic.rs b/tests/debuginfo/borrowed-unique-basic.rs index b1c555569cce2..17939239c0dea 100644 --- a/tests/debuginfo/borrowed-unique-basic.rs +++ b/tests/debuginfo/borrowed-unique-basic.rs @@ -55,6 +55,7 @@ // === LLDB TESTS ================================================================================== //@ lldb-command:type format add -f decimal char +//@ lldb-command:type format add -f decimal 'signed char' //@ lldb-command:type format add -f decimal 'unsigned char' //@ lldb-command:run diff --git a/tests/debuginfo/captured-fields-1.rs b/tests/debuginfo/captured-fields-1.rs index ddce4a3da1144..e0c1450a9f1e5 100644 --- a/tests/debuginfo/captured-fields-1.rs +++ b/tests/debuginfo/captured-fields-1.rs @@ -30,22 +30,22 @@ //@ lldb-command:run //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#0}) test = {_ref__my_ref__my_field1:0x[...]} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]0[...]) test = {_ref__my_ref__my_field1:0x[...]} //@ lldb-command:continue //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#1}) test = {_ref__my_ref__my_field2:0x[...]} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]1[...]) test = {_ref__my_ref__my_field2:0x[...]} //@ lldb-command:continue //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#2}) test = {_ref__my_ref:0x[...]} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]2[...]) test = {_ref__my_ref:0x[...]} //@ lldb-command:continue //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#3}) test = {my_ref:{my_field1:11, my_field2:22}} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]3[...]) test = {my_ref:{my_field1:11, my_field2:22}} //@ lldb-command:continue //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#4}) test = {my_var__my_field2:22} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]4[...]) test = {my_var__my_field2:22} //@ lldb-command:continue //@ lldb-command:v test -//@ lldb-check:(captured_fields_1::main::{closure_env#5}) test = {my_var:{my_field1:11, my_field2:22}} +//@ lldb-check:(captured_fields_1::main::[...]closure_env[...]5[...]) test = {my_var:{my_field1:11, my_field2:22}} //@ lldb-command:continue #![allow(unused)] diff --git a/tests/debuginfo/generic-struct.rs b/tests/debuginfo/generic-struct.rs index 945a0cdc2da38..c3529397a7c7d 100644 --- a/tests/debuginfo/generic-struct.rs +++ b/tests/debuginfo/generic-struct.rs @@ -1,3 +1,7 @@ +//@ revisions: msvc non-msvc + +//@ [msvc] only-msvc +//@ [non-msvc] ignore-msvc //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc @@ -20,14 +24,20 @@ //@ lldb-command:run //@ lldb-command:v int_int -//@ lldb-check:[...]AGenericStruct) int_int = {key:0, value:1} +//@ [non-msvc] lldb-check:[...]AGenericStruct) int_int = {key:0, value:1} +//@ [msvc] lldb-check:[...]AGenericStruct) int_int = {key:0, value:1} //@ lldb-command:v int_float -//@ lldb-check:[...]AGenericStruct) int_float = {key:2, value:3.5} +//@ [non-msvc] lldb-check:[...]AGenericStruct) int_float = {key:2, value:3.5} +//@ [msvc] lldb-check:[...]AGenericStruct) int_float = {value:3.5, key:2} //@ lldb-command:v float_int -//@ lldb-check:[...]AGenericStruct) float_int = {key:4.5, value:5} +//@ [non-msvc] lldb-check:[...]AGenericStruct) float_int = {key:4.5, value:5} +//@ [msvc] lldb-check:[...]AGenericStruct) float_int = {key:4.5, value:5} //@ lldb-command:v float_int_float -//@ lldb-check:[...]AGenericStruct >) float_int_float = {key:6.5, value:{key:7, value:8.5}} +// ignore-tidy-linelength +//@ [non-msvc]lldb-check:[...]AGenericStruct >) float_int_float = {key:6.5, value:{key:7, value:8.5}} +// ignore-tidy-linelength +//@ [msvc] lldb-check:[...]AGenericStruct >) float_int_float = {value:{value:8.5, key:7}, key:6.5} // === CDB TESTS =================================================================================== diff --git a/tests/debuginfo/method-on-generic-struct.rs b/tests/debuginfo/method-on-generic-struct.rs index f154e46b2d578..cebec85bfaccd 100644 --- a/tests/debuginfo/method-on-generic-struct.rs +++ b/tests/debuginfo/method-on-generic-struct.rs @@ -1,3 +1,7 @@ +//@ revisions: msvc non-msvc + +//@ [msvc] only-msvc +//@ [non-msvc] ignore-msvc //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc @@ -58,7 +62,8 @@ // STACK BY REF //@ lldb-command:v *self -//@ lldb-check:[...]Struct<(u32, i32)>) *self = {x:(8888, -8888)} +//@ [non-msvc] lldb-check:[...]Struct<(u32, i32)>) *self = {x:(8888, -8888)} +//@ [msvc] lldb-check:[...]Struct >) *self = {x:(8888, -8888)} //@ lldb-command:v arg1 //@ lldb-check:[...] -1 //@ lldb-command:v arg2 @@ -67,7 +72,8 @@ // STACK BY VAL //@ lldb-command:v self -//@ lldb-check:[...]Struct<(u32, i32)>) self = {x:(8888, -8888)} +//@ [non-msvc] lldb-check:[...]Struct<(u32, i32)>) self = {x:(8888, -8888)} +//@ [msvc] lldb-check:[...]Struct >) self = {x:(8888, -8888)} //@ lldb-command:v arg1 //@ lldb-check:[...] -3 //@ lldb-command:v arg2 @@ -76,7 +82,8 @@ // OWNED BY REF //@ lldb-command:v *self -//@ lldb-check:[...]Struct) *self = {x:1234.5} +//@ [non-msvc] lldb-check:[...]Struct) *self = {x:1234.5} +//@ [msvc] lldb-check:[...]Struct) *self = {x:1234.5} //@ lldb-command:v arg1 //@ lldb-check:[...] -5 //@ lldb-command:v arg2 @@ -85,7 +92,8 @@ // OWNED BY VAL //@ lldb-command:v self -//@ lldb-check:[...]Struct) self = {x:1234.5} +//@ [non-msvc] lldb-check:[...]Struct) self = {x:1234.5} +//@ [msvc] lldb-check:[...]Struct) self = {x:1234.5} //@ lldb-command:v arg1 //@ lldb-check:[...] -7 //@ lldb-command:v arg2 @@ -94,7 +102,8 @@ // OWNED MOVED //@ lldb-command:v *self -//@ lldb-check:[...]Struct) *self = {x:1234.5} +//@ [non-msvc] lldb-check:[...]Struct) *self = {x:1234.5} +//@ [msvc] lldb-check:[...]Struct) *self = {x:1234.5} //@ lldb-command:v arg1 //@ lldb-check:[...] -9 //@ lldb-command:v arg2 diff --git a/tests/debuginfo/no_mangle-info.rs b/tests/debuginfo/no_mangle-info.rs index 262644ee2b6e8..572c89eb90abd 100644 --- a/tests/debuginfo/no_mangle-info.rs +++ b/tests/debuginfo/no_mangle-info.rs @@ -1,4 +1,9 @@ -//@ compile-flags:-g +//@ revisions: msvc non-msvc + +//@ [msvc] only-msvc +//@ [non-msvc] ignore-msvc + +//@ compile-flags:-g --crate-name=no_mangle_info //@ min-gdb-version: 10.1 //@ ignore-backends: gcc @@ -11,10 +16,13 @@ // === LLDB TESTS ================================================================================== //@ lldb-command:run -//@ lldb-command:v TEST -//@ lldb-check:(unsigned long) TEST = 3735928559 -//@ lldb-command:v OTHER_TEST -//@ lldb-check:(unsigned long) no_mangle_info::namespace::OTHER_TEST = 42 +//@ [msvc] lldb-command:v no_mangle_info::TEST +//@ [msvc] lldb-check:[...]no_mangle_info::TEST = 3735928559 + +//@ [non-msvc] lldb-command:v TEST +//@ [non-msvc] lldb-check:[...]TEST = 3735928559 +//@ lldb-command:v no_mangle_info::namespace::OTHER_TEST +//@ lldb-check:[...]no_mangle_info::namespace::OTHER_TEST = 42 // === CDB TESTS ================================================================================== //@ cdb-command: g @@ -36,6 +44,6 @@ pub mod namespace { } pub fn main() { - println!("TEST: {}", TEST); + println!("TEST: {}", unsafe { TEST} ); println!("OTHER TEST: {}", namespace::OTHER_TEST); // #break } diff --git a/tests/debuginfo/pretty-slices.rs b/tests/debuginfo/pretty-slices.rs index e8813e00ae637..39acd1da1f4b3 100644 --- a/tests/debuginfo/pretty-slices.rs +++ b/tests/debuginfo/pretty-slices.rs @@ -1,3 +1,7 @@ +//@ revisions: msvc non-msvc + +//@ [msvc] only-msvc +//@ [non-msvc] ignore-msvc //@ ignore-android: FIXME(#10381) //@ ignore-windows-gnu: #128981 //@ compile-flags:-g @@ -20,10 +24,12 @@ //@ lldb-command:run //@ lldb-command:v slice -//@ lldb-check:(&[i32]) slice = size=3 { [0] = 0 [1] = 1 [2] = 2 } +//@ [non-msvc] lldb-check:(&[i32]) slice = size=3 { [0] = 0 [1] = 1 [2] = 2 } +//@ [msvc] lldb-check:(&[i32]) slice = [0, 1, 2] { [0] = 0 [1] = 1 [2] = 2 } //@ lldb-command:v mut_slice -//@ lldb-check:(&mut [i32]) mut_slice = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 } +//@ [non-msvc] lldb-check:(&mut [i32]) mut_slice = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 } +//@ [msvc] lldb-check:(&mut [i32]) mut_slice = [2, 3, 5, 7] { [0] = 2 [1] = 3 [2] = 5 [3] = 7 } //@ lldb-command:v str_slice //@ lldb-check:(&str) str_slice = "string slice" { [0] = 's' [1] = 't' [2] = 'r' [3] = 'i' [4] = 'n' [5] = 'g' [6] = ' ' [7] = 's' [8] = 'l' [9] = 'i' [10] = 'c' [11] = 'e' } diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs index 0a7f4b13c4e56..692c75bbfbc9d 100644 --- a/tests/debuginfo/strings-and-strs.rs +++ b/tests/debuginfo/strings-and-strs.rs @@ -40,13 +40,13 @@ //@ lldb-check:(strings_and_strs::Foo) str_in_struct = {inner:"Hello"} //@ lldb-command:v str_in_tuple -//@ lldb-check:((&str, &str)) str_in_tuple = ("Hello", "World") +//@ lldb-check:[...] str_in_tuple = ("Hello", "World") //@ lldb-command:v str_in_rc -//@ lldb-check:(alloc::rc::Rc<&str, alloc::alloc::Global>) str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } +//@ lldb-check:[...] str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } //@ lldb-command:v box_str -//@ lldb-check:(alloc::boxed::Box) box_str = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } +//@ lldb-check:[...] box_str = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } // Disabled temporarily since it only "works" by accident // `value` is a wide pointer, whose `data_ptr` type, according to LLDB, is `unsigned char[]`. LLDB diff --git a/tests/debuginfo/thread-names.rs b/tests/debuginfo/thread-names.rs index 19d27f55f80de..32cdef929cf11 100644 --- a/tests/debuginfo/thread-names.rs +++ b/tests/debuginfo/thread-names.rs @@ -17,11 +17,14 @@ // === LLDB TESTS ================================================================================= // //@ lldb-command:run -// -//@ lldb-command:thread info 1 -//@ lldb-check:thread #1:[...]name = 'main'[...] -//@ lldb-command:thread info 2 -//@ lldb-check:thread #2:[...]name = 'my new thread'[...] + +// We list all threads and check the full results because we're not guaranteed to have only 2 +// threads, nor are we guaranteed to have `my new thread` be thread 2. +// We use the python API to do this because `thread list` refuses to print anything inside the test +// harness for some reason. +//@ lldb-command:script print(lldb.debugger.GetTargetAtIndex(0).GetProcess().threads) +//@ lldb-check:[...]name = 'main'[...] +//@ lldb-check:[...]name = 'my new thread'[...] // === CDB TESTS ================================================================================== // From 0e8a7c92f8f8928abb7151554e09b61a687ec59b Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Tue, 8 Sep 2026 22:25:26 +0530 Subject: [PATCH 06/13] fix: add tests for super and crate --- .../auxiliary/trailing_super_crate_import_utils.rs | 1 + tests/ui/resolve/trailing-crate-import.rs | 8 ++++++++ tests/ui/resolve/trailing-crate-import.stderr | 8 ++++++++ tests/ui/resolve/trailing-super-import.rs | 9 +++++++++ tests/ui/resolve/trailing-super-import.stderr | 8 ++++++++ 5 files changed, 34 insertions(+) create mode 100644 tests/ui/resolve/auxiliary/trailing_super_crate_import_utils.rs create mode 100644 tests/ui/resolve/trailing-crate-import.rs create mode 100644 tests/ui/resolve/trailing-crate-import.stderr create mode 100644 tests/ui/resolve/trailing-super-import.rs create mode 100644 tests/ui/resolve/trailing-super-import.stderr diff --git a/tests/ui/resolve/auxiliary/trailing_super_crate_import_utils.rs b/tests/ui/resolve/auxiliary/trailing_super_crate_import_utils.rs new file mode 100644 index 0000000000000..cdc6c27d800bd --- /dev/null +++ b/tests/ui/resolve/auxiliary/trailing_super_crate_import_utils.rs @@ -0,0 +1 @@ +pub fn f() {} diff --git a/tests/ui/resolve/trailing-crate-import.rs b/tests/ui/resolve/trailing-crate-import.rs new file mode 100644 index 0000000000000..32a1c96c45485 --- /dev/null +++ b/tests/ui/resolve/trailing-crate-import.rs @@ -0,0 +1,8 @@ +//@ compile-flags: -Znamespaced-crates +//@ edition: 2024 +//@ aux-crate:my_api::utils=trailing_super_crate_import_utils.rs + +use my_api::crate as crate_alias; +//~^ ERROR: `crate` in paths can only be used in start position + +fn main() {} diff --git a/tests/ui/resolve/trailing-crate-import.stderr b/tests/ui/resolve/trailing-crate-import.stderr new file mode 100644 index 0000000000000..fd9f9a8ef10ae --- /dev/null +++ b/tests/ui/resolve/trailing-crate-import.stderr @@ -0,0 +1,8 @@ +error: `crate` in paths can only be used in start position + --> $DIR/trailing-crate-import.rs:5:13 + | +LL | use my_api::crate as crate_alias; + | ^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/resolve/trailing-super-import.rs b/tests/ui/resolve/trailing-super-import.rs new file mode 100644 index 0000000000000..4c5c6e44f3022 --- /dev/null +++ b/tests/ui/resolve/trailing-super-import.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Znamespaced-crates +//@ edition: 2024 +//@ check-fail +//@ aux-crate:my_api::utils=trailing_super_crate_import_utils.rs + +use my_api::super as super_alias; +//~^ ERROR: `super` in paths can only be used in start position, after `self`, or after another `super` + +fn main() {} diff --git a/tests/ui/resolve/trailing-super-import.stderr b/tests/ui/resolve/trailing-super-import.stderr new file mode 100644 index 0000000000000..26a6f5c8ab54f --- /dev/null +++ b/tests/ui/resolve/trailing-super-import.stderr @@ -0,0 +1,8 @@ +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/trailing-super-import.rs:6:13 + | +LL | use my_api::super as super_alias; + | ^^^^^ + +error: aborting due to 1 previous error + From 2738c80ba22d23c08241ea90ab7f36cfdb29fb3b Mon Sep 17 00:00:00 2001 From: Yukang Date: Wed, 9 Sep 2026 08:48:23 +0800 Subject: [PATCH 07/13] Add regression test for missing Fn-family generic arguments --- ...-args-issue-136407.feature_disabled.stderr | 151 ++++++++++++++++++ ...t-args-issue-136407.feature_enabled.stderr | 80 ++++++++++ .../missing-fn-trait-args-issue-136407.rs | 37 +++++ 3 files changed, 268 insertions(+) create mode 100644 tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr create mode 100644 tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_enabled.stderr create mode 100644 tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr new file mode 100644 index 0000000000000..8eca499d8f274 --- /dev/null +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr @@ -0,0 +1,151 @@ +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:9:18 + | +LL | pub fn shared() {} + | ^^ help: use parenthetical notation instead: `Fn() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `Fn` + --> $DIR/missing-fn-trait-args-issue-136407.rs:9:18 + | +LL | pub fn shared() {} + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn shared>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:13:19 + | +LL | pub fn mutable() {} + | ^^^^^ help: use parenthetical notation instead: `FnMut() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `FnMut` + --> $DIR/missing-fn-trait-args-issue-136407.rs:13:19 + | +LL | pub fn mutable() {} + | ^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn mutable>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:17:16 + | +LL | pub fn once() {} + | ^^^^^^ help: use parenthetical notation instead: `FnOnce() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `FnOnce` + --> $DIR/missing-fn-trait-args-issue-136407.rs:17:16 + | +LL | pub fn once() {} + | ^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn once>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:21:24 + | +LL | pub fn async_shared() {} + | ^^^^^^^ help: use parenthetical notation instead: `AsyncFn() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `AsyncFn` + --> $DIR/missing-fn-trait-args-issue-136407.rs:21:24 + | +LL | pub fn async_shared() {} + | ^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_shared>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:25:25 + | +LL | pub fn async_mutable() {} + | ^^^^^^^^^^ help: use parenthetical notation instead: `AsyncFnMut() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `AsyncFnMut` + --> $DIR/missing-fn-trait-args-issue-136407.rs:25:25 + | +LL | pub fn async_mutable() {} + | ^^^^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_mutable>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:29:22 + | +LL | pub fn async_once() {} + | ^^^^^^^^^^^ help: use parenthetical notation instead: `AsyncFnOnce() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: missing generics for trait `AsyncFnOnce` + --> $DIR/missing-fn-trait-args-issue-136407.rs:29:22 + | +LL | pub fn async_once() {} + | ^^^^^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_once>() {} + | ++++++ + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/missing-fn-trait-args-issue-136407.rs:33:23 + | +LL | pub fn with_output>() {} + | ^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn() -> ()` + | + = note: see issue #29625 for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied + --> $DIR/missing-fn-trait-args-issue-136407.rs:33:23 + | +LL | pub fn with_output>() {} + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn with_output>() {} + | +++++ + +error: aborting due to 14 previous errors + +Some errors have detailed explanations: E0107, E0658. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_enabled.stderr b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_enabled.stderr new file mode 100644 index 0000000000000..13a39f94892fc --- /dev/null +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_enabled.stderr @@ -0,0 +1,80 @@ +error[E0107]: missing generics for trait `Fn` + --> $DIR/missing-fn-trait-args-issue-136407.rs:9:18 + | +LL | pub fn shared() {} + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn shared>() {} + | ++++++ + +error[E0107]: missing generics for trait `FnMut` + --> $DIR/missing-fn-trait-args-issue-136407.rs:13:19 + | +LL | pub fn mutable() {} + | ^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn mutable>() {} + | ++++++ + +error[E0107]: missing generics for trait `FnOnce` + --> $DIR/missing-fn-trait-args-issue-136407.rs:17:16 + | +LL | pub fn once() {} + | ^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn once>() {} + | ++++++ + +error[E0107]: missing generics for trait `AsyncFn` + --> $DIR/missing-fn-trait-args-issue-136407.rs:21:24 + | +LL | pub fn async_shared() {} + | ^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_shared>() {} + | ++++++ + +error[E0107]: missing generics for trait `AsyncFnMut` + --> $DIR/missing-fn-trait-args-issue-136407.rs:25:25 + | +LL | pub fn async_mutable() {} + | ^^^^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_mutable>() {} + | ++++++ + +error[E0107]: missing generics for trait `AsyncFnOnce` + --> $DIR/missing-fn-trait-args-issue-136407.rs:29:22 + | +LL | pub fn async_once() {} + | ^^^^^^^^^^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn async_once>() {} + | ++++++ + +error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied + --> $DIR/missing-fn-trait-args-issue-136407.rs:33:23 + | +LL | pub fn with_output>() {} + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | pub fn with_output>() {} + | +++++ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs new file mode 100644 index 0000000000000..d672c14a992f3 --- /dev/null +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs @@ -0,0 +1,37 @@ +//! Regression test for . +// Missing arguments must not suggest gated Fn-family syntax without its feature. + +//@ revisions: feature_disabled feature_enabled +//@ edition: 2024 + +#![cfg_attr(feature_enabled, feature(unboxed_closures))] + +pub fn shared() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn mutable() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn once() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_shared() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_mutable() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_once() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn with_output>() {} +//~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +fn main() {} From 4cca91ca2697868cb73610842cd8b7f35430f3c6 Mon Sep 17 00:00:00 2001 From: Yukang Date: Wed, 9 Sep 2026 08:56:07 +0800 Subject: [PATCH 08/13] Avoid suggesting gated generic arguments for Fn-family traits --- .../wrong_number_of_generic_args.rs | 8 ++++ ...dyn-any-to-fn-with-missing-generics.stderr | 5 --- ...t-args-issue-136407.feature_disabled.fixed | 37 +++++++++++++++++++ ...-args-issue-136407.feature_disabled.stderr | 35 ------------------ .../missing-fn-trait-args-issue-136407.rs | 2 +- 5 files changed, 46 insertions(+), 41 deletions(-) create mode 100644 tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.fixed diff --git a/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs index 5cf13b51a7a8c..8a38207884184 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs @@ -628,6 +628,14 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { return; } + // Do not suggest angle-bracketed arguments that require the unstable feature. + if !self.tcx.features().unboxed_closures() + && self.tcx.is_trait(self.def_id) + && self.tcx.trait_def(self.def_id).paren_sugar + { + return; + } + match self.gen_args_info { MissingLifetimes { .. } => { self.suggest_adding_lifetime_args(err); diff --git a/tests/ui/cast/dyn-any-to-fn-with-missing-generics.stderr b/tests/ui/cast/dyn-any-to-fn-with-missing-generics.stderr index 53aa609321431..c9b49e9ed2b25 100644 --- a/tests/ui/cast/dyn-any-to-fn-with-missing-generics.stderr +++ b/tests/ui/cast/dyn-any-to-fn-with-missing-generics.stderr @@ -13,11 +13,6 @@ error[E0107]: missing generics for trait `Fn` | LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); | ^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); - | ++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.fixed b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.fixed new file mode 100644 index 0000000000000..8ddd1289b51ef --- /dev/null +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.fixed @@ -0,0 +1,37 @@ +//! Regression test for . +// Missing arguments must not suggest gated Fn-family syntax without its feature. + +//@ revisions: feature_disabled feature_enabled +//@ edition: 2024 +//@[feature_disabled] run-rustfix +#![cfg_attr(feature_enabled, feature(unboxed_closures))] + +pub fn shared ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn mutable ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn once ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_shared ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_mutable ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn async_once ()>() {} +//~^ ERROR missing generics +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +pub fn with_output ()>() {} +//~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied +//[feature_disabled]~| ERROR the precise format of `Fn`-family traits' type parameters + +fn main() {} diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr index 8eca499d8f274..2a62cdfec2566 100644 --- a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.feature_disabled.stderr @@ -13,11 +13,6 @@ error[E0107]: missing generics for trait `Fn` | LL | pub fn shared() {} | ^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn shared>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:13:19 @@ -34,11 +29,6 @@ error[E0107]: missing generics for trait `FnMut` | LL | pub fn mutable() {} | ^^^^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn mutable>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:17:16 @@ -55,11 +45,6 @@ error[E0107]: missing generics for trait `FnOnce` | LL | pub fn once() {} | ^^^^^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn once>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:21:24 @@ -76,11 +61,6 @@ error[E0107]: missing generics for trait `AsyncFn` | LL | pub fn async_shared() {} | ^^^^^^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn async_shared>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:25:25 @@ -97,11 +77,6 @@ error[E0107]: missing generics for trait `AsyncFnMut` | LL | pub fn async_mutable() {} | ^^^^^^^^^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn async_mutable>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:29:22 @@ -118,11 +93,6 @@ error[E0107]: missing generics for trait `AsyncFnOnce` | LL | pub fn async_once() {} | ^^^^^^^^^^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn async_once>() {} - | ++++++ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/missing-fn-trait-args-issue-136407.rs:33:23 @@ -139,11 +109,6 @@ error[E0107]: trait takes 1 generic argument but 0 generic arguments were suppli | LL | pub fn with_output>() {} | ^^ expected 1 generic argument - | -help: add missing generic argument - | -LL | pub fn with_output>() {} - | +++++ error: aborting due to 14 previous errors diff --git a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs index d672c14a992f3..30df5efcbf5ff 100644 --- a/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs +++ b/tests/ui/unboxed-closures/missing-fn-trait-args-issue-136407.rs @@ -3,7 +3,7 @@ //@ revisions: feature_disabled feature_enabled //@ edition: 2024 - +//@[feature_disabled] run-rustfix #![cfg_attr(feature_enabled, feature(unboxed_closures))] pub fn shared() {} From e7f01f6d3f044c496529e5a2287250888cc682d1 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Wed, 9 Sep 2026 13:29:10 +0530 Subject: [PATCH 09/13] fix: make OpenModule branch match ExternPrelude --- compiler/rustc_resolve/src/ident.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 243fcc8f9c0ab..e71f56b130a8b 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1030,16 +1030,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) } ModuleOrUniformRoot::OpenModule(sym) => { - if ident.name == kw::SelfLower && ns == TypeNS { - let res = Res::OpenMod(sym); - return Ok(self.arenas.new_pub_def_decl(res, ident.span, LocalExpnId::ROOT)); - } + if ns != TypeNS { + Err(Determined) + } else { + if ident.name == kw::SelfLower { + let res = Res::OpenMod(sym); + return Ok(self.arenas.new_pub_def_decl( + res, + ident.span, + LocalExpnId::ROOT, + )); + } - let open_ns_name = format!("{}::{}", sym.as_str(), ident.name); - let ns_ident = IdentKey::with_root_ctxt(Symbol::intern(&open_ns_name)); - match self.extern_prelude_get_flag(ns_ident, ident.span, finalize.is_some()) { - Some(decl) => Ok(decl), - None => Err(Determinacy::Determined), + let open_ns_name = format!("{}::{}", sym.as_str(), ident.name); + let ns_ident = IdentKey::with_root_ctxt(Symbol::intern(&open_ns_name)); + match self.extern_prelude_get_flag(ns_ident, ident.span, finalize.is_some()) { + Some(decl) => Ok(decl), + None => Err(Determined), + } } } ModuleOrUniformRoot::ModuleAndExternPrelude(module) => self.resolve_ident_in_scope_set( From 4669d7b07149c449ce12045d11ce819ba2ee8d45 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 9 Sep 2026 12:15:43 +0200 Subject: [PATCH 10/13] Don't explicitly specify `OnDuplicate::Error` as it is the default --- compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs | 1 - compiler/rustc_attr_parsing/src/attributes/semantics.rs | 1 - compiler/rustc_attr_parsing/src/attributes/transparency.rs | 1 - 3 files changed, 3 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 0df3d9a626bee..bd892064fc12c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -425,7 +425,6 @@ pub(crate) struct RustcNoWritableParser; impl NoArgsAttributeParser for RustcNoWritableParser { const PATH: &[Symbol] = &[sym::rustc_no_writable]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ Allow(Target::Fn), Allow(Target::Closure), diff --git a/compiler/rustc_attr_parsing/src/attributes/semantics.rs b/compiler/rustc_attr_parsing/src/attributes/semantics.rs index 7a8475c12eada..72b08a865a418 100644 --- a/compiler/rustc_attr_parsing/src/attributes/semantics.rs +++ b/compiler/rustc_attr_parsing/src/attributes/semantics.rs @@ -19,7 +19,6 @@ impl NoArgsAttributeParser for MayDangleParser { pub(crate) struct ComptimeParser; impl NoArgsAttributeParser for ComptimeParser { const PATH: &[Symbol] = &[sym::rustc_comptime]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ Allow(Target::Method(MethodKind::Inherent)), Allow(Target::Fn), diff --git a/compiler/rustc_attr_parsing/src/attributes/transparency.rs b/compiler/rustc_attr_parsing/src/attributes/transparency.rs index 9060637e53953..69c59b709d845 100644 --- a/compiler/rustc_attr_parsing/src/attributes/transparency.rs +++ b/compiler/rustc_attr_parsing/src/attributes/transparency.rs @@ -7,7 +7,6 @@ pub(crate) struct RustcMacroTransparencyParser; impl SingleAttributeParser for RustcMacroTransparencyParser { const PATH: &[Symbol] = &[sym::rustc_macro_transparency]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const STABILITY: AttributeStability = unstable!(rustc_attrs); const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::MacroDef)]); From b2416a5d34c06f9913fca34b3efc40e671fb7409 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Wed, 9 Sep 2026 14:18:27 +0200 Subject: [PATCH 11/13] yeet VisitorExt --- .../src/diagnostics/region_errors.rs | 2 +- compiler/rustc_hir/src/hir.rs | 2 +- compiler/rustc_hir/src/intravisit.rs | 18 +++++++----------- compiler/rustc_hir/src/lib.rs | 1 + .../src/check/compare_impl_item.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 2 +- .../src/collect/generics_of.rs | 2 +- .../src/collect/resolve_bound_vars.rs | 2 +- .../rustc_hir_analysis/src/collect/type_of.rs | 2 +- .../rustc_hir_analysis/src/hir_wf_check.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- compiler/rustc_lint/src/diagnostics.rs | 2 +- compiler/rustc_lint/src/non_local_def.rs | 2 +- .../rustc_lint/src/types/improper_ctypes.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_passes/src/stability.rs | 2 +- .../rustc_trait_selection/src/diagnostics.rs | 2 +- .../infer/nice_region_error/find_anon_type.rs | 2 +- .../mismatched_static_lifetime.rs | 2 +- .../nice_region_error/static_impl_trait.rs | 2 +- .../src/error_reporting/traits/suggestions.rs | 2 +- src/librustdoc/html/span_map.rs | 2 +- .../clippy/clippy_lints/src/box_default.rs | 2 +- .../clippy/clippy_lints/src/dereference.rs | 2 +- .../clippy/clippy_lints/src/implicit_hasher.rs | 2 +- src/tools/clippy/clippy_lints/src/lifetimes.rs | 2 +- .../clippy_lints/src/ptr/mut_from_ref.rs | 2 -- .../clippy_lints/src/types/type_complexity.rs | 2 +- src/tools/clippy/clippy_lints/src/use_self.rs | 2 +- .../clippy_utils/src/ty/type_certainty/mod.rs | 2 +- 30 files changed, 35 insertions(+), 40 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index a972b37cd42d2..8f9e57877ca8c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -8,7 +8,7 @@ use rustc_hir::QPath::Resolved; use rustc_hir::WherePredicateKind::BoundPredicate; use rustc_hir::def::Res::Def; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate}; use rustc_infer::infer::{NllRegionVariableOrigin, SubregionOrigin}; use rustc_middle::bug; diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 3d27276093aa5..ee79680d7d1e9 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -35,7 +35,7 @@ use tracing::debug; use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res}; use crate::def_id::{DefId, LocalDefIdMap}; -use crate::intravisit::{FnKind, VisitorExt}; +use crate::intravisit::FnKind; use crate::lints::DelayedLints; #[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index ee7b7f3efdf83..9cd4b5d7d001f 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -518,27 +518,23 @@ pub trait Visitor<'v>: Sized { ) -> Self::Result { walk_test_binder_bound_type_constraint(self, bound_type) } -} -pub trait VisitorExt<'v>: Visitor<'v> { - /// Extension trait method to visit types in unambiguous positions, this is not - /// directly on the [`Visitor`] trait as this method should never be overridden. - /// /// Named `visit_ty_unambig` instead of `visit_unambig_ty` to aid in discovery /// by IDes when `v.visit_ty` is written. - fn visit_ty_unambig(&mut self, t: &'v Ty<'v>) -> Self::Result { + /// + /// This method cannot be overridden. + final fn visit_ty_unambig(&mut self, t: &'v Ty<'v>) -> Self::Result { walk_unambig_ty(self, t) } - /// Extension trait method to visit consts in unambiguous positions, this is not - /// directly on the [`Visitor`] trait as this method should never be overridden. - /// + /// Named `visit_const_arg_unambig` instead of `visit_unambig_const_arg` to aid in /// discovery by IDes when `v.visit_const_arg` is written. - fn visit_const_arg_unambig(&mut self, c: &'v ConstArg<'v>) -> Self::Result { + /// + /// This method cannot be overridden. + final fn visit_const_arg_unambig(&mut self, c: &'v ConstArg<'v>) -> Self::Result { walk_unambig_const_arg(self, c) } } -impl<'v, V: Visitor<'v>> VisitorExt<'v> for V {} pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) -> V::Result { let Param { hir_id, pat, ty_span: _, span: _ } = param; diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 55ef1c9fb3ef9..0f31ed196c3df 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -11,6 +11,7 @@ #![feature(default_field_values)] #![feature(derive_const)] #![feature(exhaustive_patterns)] +#![feature(final_associated_functions)] #![recursion_limit = "256"] // tidy-alphabetical-end diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index d49c3b2869bd3..73013587b27df 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_errors::codes::*; use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, pluralize, struct_span_code_err}; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, intravisit}; use rustc_infer::infer::{self, BoundRegionConversionTime, InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::{TraitErrors, util}; diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 2e4da8d948f07..46663f115a97e 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -26,7 +26,7 @@ use rustc_errors::{ }; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt}; +use rustc_hir::intravisit::{InferKind, Visitor}; use rustc_hir::{self as hir, GenericParamKind, HirId, Node, PreciseCapturingArgKind, find_attr}; use rustc_infer::infer::{InferCtxt, SolverRegionConstraint, TyCtxtInferExt}; use rustc_infer::traits::{DynCompatibilityViolation, ObligationCause}; diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 13128a7fe9135..1c52d5f5fa954 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -4,7 +4,7 @@ use std::ops::ControlFlow; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{self as hir, AmbigArg, GenericParamKind, HirId, Node}; use rustc_lint_defs::builtin::INVALID_TYPE_PARAM_DEFAULT; use rustc_middle::span_bug; diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 042b931750b71..ad7cb30097a6a 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -16,7 +16,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LocalDefIdMap; use rustc_hir::definitions::{DefPathData, PerParentDisambiguatorsMap}; -use rustc_hir::intravisit::{self, InferKind, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, InferKind, Visitor}; use rustc_hir::{ self as hir, AmbigArg, GenericArg, GenericParam, GenericParamKind, HirId, LifetimeKind, Node, }; diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 6ebd38195ffbe..9ad26f7975858 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -2,7 +2,7 @@ use core::ops::ControlFlow; use rustc_errors::{Applicability, StashKey, Suggestions}; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, AmbigArg, HirId}; use rustc_middle::ty::print::{with_forced_trimmed_paths, with_types_for_suggestion}; use rustc_middle::ty::util::IntTypeExt; diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index f2c25c8716783..fb6bd751c7f1f 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -1,5 +1,5 @@ use rustc_hir::def::DefKind; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{self as hir, AmbigArg, ForeignItem, ForeignItemKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{ObligationCause, ObligationCauseCode, WellFormedLoc}; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index b59dc21981ce6..b7906de6dac0c 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -10,7 +10,7 @@ use rustc_errors::{ use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, AmbigArg, ExprKind, GenericArg, HirId, Node, QPath, intravisit}; use rustc_hir_analysis::hir_ty_lowering::errors::GenericsArgsErrExtend; use rustc_hir_analysis::hir_ty_lowering::generics::{ diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index a15eb4c569d03..cfae7afd8f4f3 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -10,7 +10,7 @@ use rustc_errors::{ }; use rustc_hir as hir; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::inhabitedness::InhabitedPredicate; use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt}; diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 4fb30651829fd..9d6999080ca04 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -1,6 +1,6 @@ use rustc_errors::{MultiSpan, msg}; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{Body, HirId, Item, ItemKind, Node, Path, TyKind, find_attr}; use rustc_lint_defs::{declare_lint, impl_lint_pass}; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_lint/src/types/improper_ctypes.rs b/compiler/rustc_lint/src/types/improper_ctypes.rs index b37d90e7bdc7f..cfd5032b7b245 100644 --- a/compiler/rustc_lint/src/types/improper_ctypes.rs +++ b/compiler/rustc_lint/src/types/improper_ctypes.rs @@ -6,7 +6,7 @@ use rustc_abi::VariantIdx; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{DiagMessage, msg}; use rustc_hir::def::CtorKind; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, AmbigArg}; use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_middle::bug; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 5ff5c05de734a..61cf9e5b0693a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -33,7 +33,7 @@ use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::definitions::{DefPathData, Definitions, PerParentDisambiguatorState}; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate, find_attr}; use rustc_index::IndexVec; use rustc_lint_defs::Lint; diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 23cc86ae6ae61..64d969d808fef 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -10,7 +10,7 @@ use rustc_feature::{EnabledLangFeature, EnabledLibFeature, UNSTABLE_LANG_FEATURE use rustc_hir::attrs::{AttributeKind, DeprecatedSince}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalModId}; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{ self as hir, AmbigArg, ConstStability, Constness, DefaultBodyStability, FieldDef, HirId, Item, ItemKind, Path, Stability, StabilityLevel, StableSince, TraitRef, Ty, TyKind, UnstableReason, diff --git a/compiler/rustc_trait_selection/src/diagnostics.rs b/compiler/rustc_trait_selection/src/diagnostics.rs index 5588cf9054cf4..6e2a4f10fb458 100644 --- a/compiler/rustc_trait_selection/src/diagnostics.rs +++ b/compiler/rustc_trait_selection/src/diagnostics.rs @@ -7,7 +7,7 @@ use rustc_errors::{ }; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty}; +use rustc_hir::intravisit::{Visitor, walk_ty}; use rustc_hir::{self as hir, AmbigArg, FnRetTy, GenericParamKind, Node}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::print::{PrintTraitRefExt as _, TraitRefPrintOnlyTraitPath}; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs index 739628f820653..e88038528189e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs @@ -1,7 +1,7 @@ use core::ops::ControlFlow; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{self as hir, AmbigArg}; use rustc_middle::hir::nested_filter; use rustc_middle::middle::resolve_bound_vars as rbv; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs index e8a9e929d6a5d..521910163ad5d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs @@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; -use rustc_hir::intravisit::VisitorExt; +use rustc_hir::intravisit::Visitor; use rustc_middle::bug; use rustc_middle::ty::TypeVisitor; use tracing::debug; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index 2d48b41bcb361..6c6d68e63ed63 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -3,7 +3,7 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{Applicability, Diag, ErrorGuaranteed}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty}; +use rustc_hir::intravisit::{Visitor, walk_ty}; use rustc_hir::{ self as hir, AmbigArg, GenericBound, GenericParam, GenericParamKind, Item, ItemKind, Lifetime, LifetimeKind, LifetimeParamKind, MissingLifetimeKind, Node, TyKind, diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 65e589d336500..3e81412ed474f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -15,7 +15,7 @@ use rustc_errors::{ use rustc_hir::attrs::lang_items::{self, LangItem}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{Visitor, VisitorExt}; +use rustc_hir::intravisit::Visitor; use rustc_hir::{ self as hir, AmbigArg, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node, expr_needs_parens, diff --git a/src/librustdoc/html/span_map.rs b/src/librustdoc/html/span_map.rs index c18975b6a3c4e..424b3c94fcbb1 100644 --- a/src/librustdoc/html/span_map.rs +++ b/src/librustdoc/html/span_map.rs @@ -4,7 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_hir::intravisit::{self, Visitor, VisitorExt}; +use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{ExprKind, HirId, Item, ItemKind, Mod, Node, QPath}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, TyCtxt}; diff --git a/src/tools/clippy/clippy_lints/src/box_default.rs b/src/tools/clippy/clippy_lints/src/box_default.rs index 5c0635d94e023..5b32b3860ea19 100644 --- a/src/tools/clippy/clippy_lints/src/box_default.rs +++ b/src/tools/clippy/clippy_lints/src/box_default.rs @@ -6,7 +6,7 @@ use clippy_utils::{is_default_equivalent, sym}; use rustc_errors::Applicability; use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::Res; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_ty}; +use rustc_hir::intravisit::{InferKind, Visitor, walk_ty}; use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, LetStmt, Node, QPath, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext as _, declare_lint_pass}; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 31c35b59073c6..3e2227329e5eb 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -12,7 +12,7 @@ use rustc_ast::util::parser::ExprPrecedence; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_ty}; +use rustc_hir::intravisit::{InferKind, Visitor, walk_ty}; use rustc_hir::{ self as hir, AmbigArg, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, Item, MatchSource, Mutability, Node, OwnerId, Pat, PatKind, Path, QPath, TyKind, UnOp, diff --git a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs index d6f49828d5932..e39ff754a5b3b 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use clippy_utils::res::MaybeDef as _; use rustc_errors::{Applicability, Diag}; -use rustc_hir::intravisit::{Visitor, VisitorExt as _, walk_body, walk_expr, walk_ty}; +use rustc_hir::intravisit::{Visitor, walk_body, walk_expr, walk_ty}; use rustc_hir::{self as hir, AmbigArg, Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind}; use rustc_hir_analysis::lower_ty; use rustc_lint::{LateContext, LateLintPass, declare_lint_pass}; diff --git a/src/tools/clippy/clippy_lints/src/lifetimes.rs b/src/tools/clippy/clippy_lints/src/lifetimes.rs index ba3d8417bf97d..bd5c380f7bc23 100644 --- a/src/tools/clippy/clippy_lints/src/lifetimes.rs +++ b/src/tools/clippy/clippy_lints/src/lifetimes.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::FnRetTy::Return; use rustc_hir::attrs::lang_items; use rustc_hir::intravisit::{ - IgnoreNested, NestedFilter, Visitor, VisitorExt as _, walk_fn_decl, walk_generic_args, walk_generic_param, + IgnoreNested, NestedFilter, Visitor, walk_fn_decl, walk_generic_args, walk_generic_param, walk_generics, walk_impl_item_ref, walk_param_bound, walk_poly_trait_ref, walk_trait_ref, walk_ty, walk_unambig_ty, walk_where_predicate, }; diff --git a/src/tools/clippy/clippy_lints/src/ptr/mut_from_ref.rs b/src/tools/clippy/clippy_lints/src/ptr/mut_from_ref.rs index 30d708f436b40..6cf4c8586f340 100644 --- a/src/tools/clippy/clippy_lints/src/ptr/mut_from_ref.rs +++ b/src/tools/clippy/clippy_lints/src/ptr/mut_from_ref.rs @@ -67,8 +67,6 @@ impl<'tcx> Visitor<'tcx> for LifetimeVisitor<'tcx> { /// The second field of the vector's elements indicate if the lifetime is attached to a /// shared reference, a mutable reference, or neither. fn get_lifetimes<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Vec<(&'tcx Lifetime, Option, Span)> { - use hir::intravisit::VisitorExt as _; - let mut visitor = LifetimeVisitor { result: Vec::new() }; visitor.visit_ty_unambig(ty); visitor.result diff --git a/src/tools/clippy/clippy_lints/src/types/type_complexity.rs b/src/tools/clippy/clippy_lints/src/types/type_complexity.rs index ca2977736e4c4..6ade8059f2033 100644 --- a/src/tools/clippy/clippy_lints/src/types/type_complexity.rs +++ b/src/tools/clippy/clippy_lints/src/types/type_complexity.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use rustc_abi::ExternAbi; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_ty}; +use rustc_hir::intravisit::{InferKind, Visitor, walk_ty}; use rustc_hir::{self as hir, AmbigArg, GenericParamKind, TyKind}; use rustc_lint::LateContext; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/use_self.rs b/src/tools/clippy/clippy_lints/src/use_self.rs index 82f30d48d97d3..7b4250c6078f2 100644 --- a/src/tools/clippy/clippy_lints/src/use_self.rs +++ b/src/tools/clippy/clippy_lints/src/use_self.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_ty}; +use rustc_hir::intravisit::{InferKind, Visitor, walk_ty}; use rustc_hir::{ self as hir, AmbigArg, Expr, ExprKind, FnRetTy, FnSig, GenericArgsParentheses, GenericParamKind, HirId, Impl, ImplItemImplKind, ImplItemKind, Item, ItemKind, Node, Pat, PatExpr, PatExprKind, PatKind, Path, QPath, Ty, TyKind, diff --git a/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs index 07ea49f3bb7a9..e7b259bb93c0e 100644 --- a/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs @@ -15,7 +15,7 @@ use crate::paths::{PathNS, lookup_path}; use rustc_ast::{LitFloatType, LitIntType, LitKind}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_qpath, walk_ty}; +use rustc_hir::intravisit::{InferKind, Visitor, walk_qpath, walk_ty}; use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, GenericArgs, HirId, Node, Param, PathSegment, QPath, TyKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, AdtDef, GenericArgKind, Ty}; From 1a533b6b78af89a80abe6979dc4b1fbd6fd1f9e1 Mon Sep 17 00:00:00 2001 From: rabindra789 Date: Thu, 6 Aug 2026 21:09:28 +0530 Subject: [PATCH 12/13] mir: validate Move call arguments are locals or box derefs --- compiler/rustc_mir_transform/src/validate.rs | 20 ++++++++++++++ tests/ui/mir/validate/call-move-arg.rs | 28 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/ui/mir/validate/call-move-arg.rs diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 4bb497097c1de..5efec6bcf770f 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -430,6 +430,26 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { ), ); } + + // Call arguments are moved by reference, so they must be plain locals + // or the contents of a box; other moved places violate MIR invariants. + if self.tcx.sess.opts.unstable_opts.validate_mir + && self.body.phase < MirPhase::Runtime(RuntimePhase::Initial) + { + let is_plain_local = place.projection.is_empty(); + let is_box_deref = + matches!(place.projection.as_ref(), [ProjectionElem::Deref]) + && self.body.local_decls[place.local].ty.is_box(); + if !is_plain_local && !is_box_deref { + self.fail( + location, + format!( + "encountered `Move` of a non-local, non-box place in `Call` terminator: {:?}", + terminator.kind, + ), + ); + } + } } } diff --git a/tests/ui/mir/validate/call-move-arg.rs b/tests/ui/mir/validate/call-move-arg.rs new file mode 100644 index 0000000000000..a6e01f264a986 --- /dev/null +++ b/tests/ui/mir/validate/call-move-arg.rs @@ -0,0 +1,28 @@ +// Check that validation rejects moving a non-local, non-box place as a +// `Call` argument. +// +//@ failure-status: 101 +//@ dont-check-compiler-stderr +//@ compile-flags: -Zvalidate-mir + +#![feature(custom_mir, core_intrinsics)] +extern crate core; +use core::intrinsics::mir::*; + +fn bar(_x: i32) {} + +#[custom_mir(dialect = "built")] +pub fn main() { + mir! { + let a: (i32, i32); + { + a = (1, 2); + Call(RET = bar(Move(a.0)), ReturnTo(retblock), UnwindContinue()) + //~^ ERROR broken MIR in + //~| ERROR encountered `Move` of a non-local, non-box place in `Call` terminator + } + retblock = { + Return() + } + } +} From d4811d0e03de24318b8ffc228183bac0d7926ec8 Mon Sep 17 00:00:00 2001 From: Amirhossein Akhlaghpour Date: Wed, 9 Sep 2026 15:35:02 +0000 Subject: [PATCH 13/13] normalize CoerceShared field types before relating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amirhossein Akhlaghpoor Co-authored-by: León Orell Valerian Liehr --- compiler/rustc_borrowck/src/type_check/mod.rs | 7 +++-- ...hared-normalizes-field-tys-issue-162144.rs | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/ui/reborrow/coerce-shared-normalizes-field-tys-issue-162144.rs diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 9f23a0d5ab631..354db9026ffb2 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2597,8 +2597,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let Some(src_field) = src_fields.iter().find(|f| f.name == dst_field.name) else { continue; }; - let dst_ty = dst_field.ty(tcx, dst_args).skip_norm_wip(); - let src_ty = src_field.ty(tcx, src_args).skip_norm_wip(); + // These field types can still contain projections from the source or target type + // and normalize them before handing them to `NllTypeRelating` + let dst_ty = self.normalize(dst_field.ty(tcx, dst_args), location.to_locations()); + let src_ty = self.normalize(src_field.ty(tcx, src_args), location.to_locations()); + if let ( ty::Ref(src_region, _, Mutability::Mut), ty::Ref(dst_region, _, Mutability::Not), diff --git a/tests/ui/reborrow/coerce-shared-normalizes-field-tys-issue-162144.rs b/tests/ui/reborrow/coerce-shared-normalizes-field-tys-issue-162144.rs new file mode 100644 index 0000000000000..4a183d008c2b9 --- /dev/null +++ b/tests/ui/reborrow/coerce-shared-normalizes-field-tys-issue-162144.rs @@ -0,0 +1,29 @@ +//@ check-pass + +#![feature(reborrow)] + +use std::marker::{CoerceShared, PhantomData, Reborrow}; + +#[derive(Reborrow, CoerceShared)] +#[coerce_shared(CustomMarkerRef<'a>)] +struct CustomMarker<'a>(PhantomData<&'a ()>); + +#[derive(Clone, Copy)] +struct CustomMarkerRef<'a>(PhantomData<&'a ::Item>); + +impl<'a> Iterator for CustomMarkerRef<'a> { + type Item = (); + + fn next(&mut self) -> Option { + None + } +} + +fn method<'a>(_a: CustomMarkerRef<'a>) -> &'a () { + &() +} + +fn main() { + let a = CustomMarker(PhantomData); + let _b = method(a); +}