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/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. diff --git a/tests/ui/issues/issue-31299.rs b/tests/ui/associated-types/sized-recursive-type-via-associated-type.rs similarity index 85% rename from tests/ui/issues/issue-31299.rs rename to tests/ui/associated-types/sized-recursive-type-via-associated-type.rs index b01b73bf373e8..2c2a3820d42d0 100644 --- a/tests/ui/issues/issue-31299.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/issues/issue-27997.rs b/tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs similarity index 91% rename from tests/ui/issues/issue-27997.rs rename to tests/ui/codegen/correctly-monomorphize-generic-drop-impl.rs index 85317cec061ad..1a81632970c97 100644 --- a/tests/ui/issues/issue-27997.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/issues/issue-35815.rs b/tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs similarity index 80% rename from tests/ui/issues/issue-35815.rs rename to tests/ui/codegen/dont-roundup-dst-prefix-size-to-alignment.rs index 1a09d8041e459..19bf627e6ddf2 100644 --- a/tests/ui/issues/issue-35815.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/issues/issue-47486.rs b/tests/ui/consts/size_of-requires-type-annotation-in-const.rs similarity index 67% rename from tests/ui/issues/issue-47486.rs rename to tests/ui/consts/size_of-requires-type-annotation-in-const.rs index d686f02a9fe39..3e4a9fd076b47 100644 --- a/tests/ui/issues/issue-47486.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/issues/issue-47486.stderr b/tests/ui/consts/size_of-requires-type-annotation-in-const.stderr similarity index 82% rename from tests/ui/issues/issue-47486.stderr rename to tests/ui/consts/size_of-requires-type-annotation-in-const.stderr index c7e9af70e64a7..3ca15af5e1782 100644 --- a/tests/ui/issues/issue-47486.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/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`. diff --git a/tests/ui/issues/issue-46855.rs b/tests/ui/mir/dont-use-operand-as-place-for-zst.rs similarity index 84% rename from tests/ui/issues/issue-46855.rs rename to tests/ui/mir/dont-use-operand-as-place-for-zst.rs index acea242046fde..0d1d12d5b404c 100644 --- a/tests/ui/issues/issue-46855.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/issues/issue-50811.rs b/tests/ui/mir/validate-various-comparison-behavior.rs similarity index 95% rename from tests/ui/issues/issue-50811.rs rename to tests/ui/mir/validate-various-comparison-behavior.rs index aaf1c17f59b5f..c1aaa4c35ae15 100644 --- a/tests/ui/issues/issue-50811.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)]