From ee5f63f88885ce7b585c1d016a81f0e78d57646b Mon Sep 17 00:00:00 2001 From: lokirithm Date: Wed, 13 May 2026 01:15:59 +0530 Subject: [PATCH 1/4] Move test files from issues/ to appropriate subdirectories --- .../sized-recursive-type-via-associated-type.rs} | 0 .../correctly-monomorphize-generic-drop-impl.rs} | 0 .../dont-roundup-dst-prefix-size-to-alignment.rs} | 0 .../size_of-requires-type-annotation-in-const.rs} | 0 .../size_of-requires-type-annotation-in-const.stderr} | 0 .../issue-46855.rs => mir/dont-use-operand-as-place-for-zst.rs} | 0 .../validate-various-comparison-behavior.rs} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-31299.rs => associated-types/sized-recursive-type-via-associated-type.rs} (100%) rename tests/ui/{issues/issue-27997.rs => codegen/correctly-monomorphize-generic-drop-impl.rs} (100%) rename tests/ui/{issues/issue-35815.rs => codegen/dont-roundup-dst-prefix-size-to-alignment.rs} (100%) rename tests/ui/{issues/issue-47486.rs => consts/size_of-requires-type-annotation-in-const.rs} (100%) rename tests/ui/{issues/issue-47486.stderr => consts/size_of-requires-type-annotation-in-const.stderr} (100%) rename tests/ui/{issues/issue-46855.rs => mir/dont-use-operand-as-place-for-zst.rs} (100%) rename tests/ui/{issues/issue-50811.rs => mir/validate-various-comparison-behavior.rs} (100%) diff --git a/tests/ui/issues/issue-31299.rs b/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs similarity index 100% rename from tests/ui/issues/issue-31299.rs rename to tests/ui/associated-types/sized-recursive-type-via-associated-type.rs diff --git a/tests/ui/issues/issue-27997.rs b/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs similarity index 100% rename from tests/ui/issues/issue-27997.rs rename to tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs diff --git a/tests/ui/issues/issue-35815.rs b/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs similarity index 100% rename from tests/ui/issues/issue-35815.rs rename to tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs diff --git a/tests/ui/issues/issue-47486.rs b/tests/ui/consts/size_of-requires-type-annotation-in-const.rs similarity index 100% rename from tests/ui/issues/issue-47486.rs rename to tests/ui/consts/size_of-requires-type-annotation-in-const.rs diff --git a/tests/ui/issues/issue-47486.stderr b/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr similarity index 100% rename from tests/ui/issues/issue-47486.stderr rename to tests/ui/consts/size_of-requires-type-annotation-in-const.stderr diff --git a/tests/ui/issues/issue-46855.rs b/tests/ui/mir/dont-use-operand-as-place-for-zst.rs similarity index 100% rename from tests/ui/issues/issue-46855.rs rename to tests/ui/mir/dont-use-operand-as-place-for-zst.rs diff --git a/tests/ui/issues/issue-50811.rs b/tests/ui/mir/validate-various-comparison-behavior.rs similarity index 100% rename from tests/ui/issues/issue-50811.rs rename to tests/ui/mir/validate-various-comparison-behavior.rs From 664af6990b226f1193e9b7d207baa721042d451c Mon Sep 17 00:00:00 2001 From: lokirithm Date: Wed, 13 May 2026 01:26:32 +0530 Subject: [PATCH 2/4] Update files --- .../sized-recursive-type-via-associated-type.rs | 4 ++-- tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs | 1 + tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs | 1 + tests/ui/consts/size_of-requires-type-annotation-in-const.rs | 1 + .../consts/size_of-requires-type-annotation-in-const.stderr | 4 ++-- tests/ui/mir/dont-use-operand-as-place-for-zst.rs | 1 + tests/ui/mir/validate-various-comparison-behavior.rs | 1 + 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs b/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs index b01b73bf373e8..2c2a3820d42d0 100644 --- a/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs +++ b/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs @@ -1,6 +1,6 @@ +//! Regression test for //@ run-pass -// Regression test for #31299. This was generating an overflow error -// because of eager normalization: +// This was generating an overflow error because of eager normalization: // // proving `M: Sized` requires // - proving `PtrBack>: Sized` requires diff --git a/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs b/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs index 85317cec061ad..1a81632970c97 100644 --- a/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs +++ b/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass use std::sync::atomic::{Ordering, AtomicUsize}; diff --git a/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs b/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs index 1a09d8041e459..19bf627e6ddf2 100644 --- a/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs +++ b/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] use std::mem; diff --git a/tests/ui/consts/size_of-requires-type-annotation-in-const.rs b/tests/ui/consts/size_of-requires-type-annotation-in-const.rs index d686f02a9fe39..3e4a9fd076b47 100644 --- a/tests/ui/consts/size_of-requires-type-annotation-in-const.rs +++ b/tests/ui/consts/size_of-requires-type-annotation-in-const.rs @@ -1,3 +1,4 @@ +//! Regression test for fn main() { () < std::mem::size_of::<_>(); //~ ERROR: mismatched types [0u8; std::mem::size_of::<_>()]; //~ ERROR: type annotations needed diff --git a/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr b/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr index c7e9af70e64a7..3ca15af5e1782 100644 --- a/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr +++ b/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-47486.rs:2:10 + --> $DIR/size_of-requires-type-annotation-in-const.rs:3:10 | LL | () < std::mem::size_of::<_>(); | -- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `usize` @@ -7,7 +7,7 @@ LL | () < std::mem::size_of::<_>(); | expected because this is `()` error[E0282]: type annotations needed - --> $DIR/issue-47486.rs:3:11 + --> $DIR/size_of-requires-type-annotation-in-const.rs:4:11 | LL | [0u8; std::mem::size_of::<_>()]; | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `size_of` diff --git a/tests/ui/mir/dont-use-operand-as-place-for-zst.rs b/tests/ui/mir/dont-use-operand-as-place-for-zst.rs index acea242046fde..0d1d12d5b404c 100644 --- a/tests/ui/mir/dont-use-operand-as-place-for-zst.rs +++ b/tests/ui/mir/dont-use-operand-as-place-for-zst.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] //@ compile-flags: -Zmir-opt-level=1 diff --git a/tests/ui/mir/validate-various-comparison-behavior.rs b/tests/ui/mir/validate-various-comparison-behavior.rs index aaf1c17f59b5f..c1aaa4c35ae15 100644 --- a/tests/ui/mir/validate-various-comparison-behavior.rs +++ b/tests/ui/mir/validate-various-comparison-behavior.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![feature(test)] #![allow(invalid_nan_comparisons)] From de28a95577ab43e7635ca1b9edc40ccdb9fa46c7 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 19 May 2026 07:15:07 -0400 Subject: [PATCH 3/4] Add an example to the `NumBuffer` documentations We specifically call out that the sign is written for negative integers. This would also ideally be called out in `::format_into`, but the macro infrastructure for the implementation unfortunately doesn't really make this easy as far as I can tell. --- library/core/src/fmt/num_buffer.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/core/src/fmt/num_buffer.rs b/library/core/src/fmt/num_buffer.rs index 055c50833d94d..cc3680b8a42be 100644 --- a/library/core/src/fmt/num_buffer.rs +++ b/library/core/src/fmt/num_buffer.rs @@ -34,6 +34,22 @@ impl_NumBufferTrait! { /// A buffer wrapper of which the internal size is based on the maximum /// number of digits the associated integer can have. +/// +/// # Examples +/// +/// ``` +/// #![feature(int_format_into)] +/// use core::fmt::NumBuffer; +/// +/// let mut buf = NumBuffer::new(); +/// let n1 = 1972u32; +/// assert_eq!(n1.format_into(&mut buf), "1972"); +/// +/// // Formatting a negative integer includes the sign. +/// let mut buf = NumBuffer::new(); +/// let n2 = -1972i32; +/// assert_eq!(n2.format_into(&mut buf), "-1972"); +/// ``` #[unstable(feature = "int_format_into", issue = "138215")] pub struct NumBuffer { // FIXME: Once const generics feature is working, use `T::BUF_SIZE` instead of 40. From b75c53288e7784abdada2705c272f297e850cbd1 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Wed, 20 May 2026 08:35:27 +0300 Subject: [PATCH 4/4] Visit delegation's qself under elided-infer lifetime rib too --- compiler/rustc_resolve/src/late.rs | 10 ++-- .../wrong-lifetime-rib-ice-156342.rs | 17 ------- .../wrong-lifetime-rib-ice-156342.stderr | 19 -------- tests/ui/delegation/wrong-lifetime-rib.rs | 32 +++++++++++++ tests/ui/delegation/wrong-lifetime-rib.stderr | 46 +++++++++++++++++++ 5 files changed, 83 insertions(+), 41 deletions(-) delete mode 100644 tests/ui/delegation/wrong-lifetime-rib-ice-156342.rs delete mode 100644 tests/ui/delegation/wrong-lifetime-rib-ice-156342.stderr create mode 100644 tests/ui/delegation/wrong-lifetime-rib.rs create mode 100644 tests/ui/delegation/wrong-lifetime-rib.stderr diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 21936a0111c62..21b36f1934c3a 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3912,13 +3912,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { PathSource::Delegation, ); - if let Some(qself) = &delegation.qself { - self.visit_ty(&qself.ty); - } - // Create lifetimes not with `LifetimeRibKind::Generics` but with `LifetimeRibKind::Elided`, - // as we are not processing generic params but generic args in a future function call (#156342). + // as we are not processing generic params but generic args in a future call (#156342, #156758). self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { + if let Some(qself) = &delegation.qself { + this.visit_ty(&qself.ty); + } + this.visit_path(&delegation.path); }); diff --git a/tests/ui/delegation/wrong-lifetime-rib-ice-156342.rs b/tests/ui/delegation/wrong-lifetime-rib-ice-156342.rs deleted file mode 100644 index aad697c8c229e..0000000000000 --- a/tests/ui/delegation/wrong-lifetime-rib-ice-156342.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(fn_delegation)] -#![feature(type_info)] - -use std::mem::type_info::Trait; - -impl Trait { -//~^ ERROR: cannot define inherent `impl` for a type outside of the crate where the type is defined - reuse None::<&()>; - //~^ ERROR: expected function, found unit variant `None` -} - -fn foo() {} - -reuse foo::<&&&&&&&&&&()> as foo1; -reuse foo::<&std::borrow::Cow<'_, &()>> as foo2; - -fn main() {} diff --git a/tests/ui/delegation/wrong-lifetime-rib-ice-156342.stderr b/tests/ui/delegation/wrong-lifetime-rib-ice-156342.stderr deleted file mode 100644 index dbe4823ae0c97..0000000000000 --- a/tests/ui/delegation/wrong-lifetime-rib-ice-156342.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0423]: expected function, found unit variant `None` - --> $DIR/wrong-lifetime-rib-ice-156342.rs:8:11 - | -LL | reuse None::<&()>; - | ^^^^^^^^^^^ not a function - -error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined - --> $DIR/wrong-lifetime-rib-ice-156342.rs:6:1 - | -LL | impl Trait { - | ^^^^^^^^^^ impl for type defined outside of crate - | - = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it - = note: for more details about the orphan rules, see - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0116, E0423. -For more information about an error, try `rustc --explain E0116`. diff --git a/tests/ui/delegation/wrong-lifetime-rib.rs b/tests/ui/delegation/wrong-lifetime-rib.rs new file mode 100644 index 0000000000000..14d62cbaa41fa --- /dev/null +++ b/tests/ui/delegation/wrong-lifetime-rib.rs @@ -0,0 +1,32 @@ +//@ edition:2024 + +#![feature(fn_delegation)] +#![feature(type_info)] + +mod ice_156342 { + use std::mem::type_info::Trait; + + impl Trait { + //~^ ERROR: cannot define inherent `impl` for a type outside of the crate where the type is defined + reuse None::<&()>; + //~^ ERROR: expected function, found unit variant `None` + } + + fn foo() {} + + reuse foo::<&&&&&&&&&&()> as foo1; + reuse foo::<&std::borrow::Cow<'_, &()>> as foo2; +} + +mod ice_156758 { + trait X {} + type Project = (); + type Ty = (); + + impl X { //~ ERROR: expected a type, found a trait + reuse<<<&Project> :: Ty> :: Ty as Iterator>::next; + //~^ ERROR: ambiguous associated type + } +} + +fn main() {} diff --git a/tests/ui/delegation/wrong-lifetime-rib.stderr b/tests/ui/delegation/wrong-lifetime-rib.stderr new file mode 100644 index 0000000000000..2c9594af581ce --- /dev/null +++ b/tests/ui/delegation/wrong-lifetime-rib.stderr @@ -0,0 +1,46 @@ +error[E0423]: expected function, found unit variant `None` + --> $DIR/wrong-lifetime-rib.rs:11:15 + | +LL | reuse None::<&()>; + | ^^^^^^^^^^^ not a function + +error[E0782]: expected a type, found a trait + --> $DIR/wrong-lifetime-rib.rs:26:10 + | +LL | impl X { + | ^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | impl dyn X { + | +++ +help: you might have intended to implement this trait for a given type + | +LL | impl X for /* Type */ { + | ++++++++++++++ + +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/wrong-lifetime-rib.rs:9:5 + | +LL | impl Trait { + | ^^^^^^^^^^ impl for type defined outside of crate + | + = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it + = note: for more details about the orphan rules, see + +error[E0223]: ambiguous associated type + --> $DIR/wrong-lifetime-rib.rs:27:16 + | +LL | reuse<<<&Project> :: Ty> :: Ty as Iterator>::next; + | ^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `Ty` implemented for `&()`, you could use the fully-qualified path + | +LL - reuse<<<&Project> :: Ty> :: Ty as Iterator>::next; +LL + reuse<<<&() as Example>::Ty> :: Ty as Iterator>::next; + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0116, E0223, E0423, E0782. +For more information about an error, try `rustc --explain E0116`.