diff options
Diffstat (limited to 'tests')
23 files changed, 337 insertions, 53 deletions
diff --git a/tests/crashes/124436.rs b/tests/crashes/124436.rs new file mode 100644 index 00000000000..aed830e8f0e --- /dev/null +++ b/tests/crashes/124436.rs @@ -0,0 +1,7 @@ +//@ known-bug: rust-lang/rust#124436 +//@ compile-flags: -Zdump-mir=all -Zpolymorphize=on + +pub trait TraitCat {} +pub trait TraitDog {} + +pub fn gamma<T: TraitCat + TraitDog>(t: [TraitDog; 32]) {} diff --git a/tests/crashes/124440.rs b/tests/crashes/124440.rs new file mode 100644 index 00000000000..431c4e444f1 --- /dev/null +++ b/tests/crashes/124440.rs @@ -0,0 +1,23 @@ +//@ known-bug: rust-lang/rust#124440 + +#![allow(warnings)] + +trait Foo {} + +impl<F> Foo for F where F: FnMut(&()) {} + +struct Bar<F> { + f: F, +} + +impl<F> Foo for Bar<F> where F: Foo {} + +fn assert_foo<F>(_: F) +where + Bar<F>: Foo, +{ +} + +fn main() { + assert_foo(|_| ()); +} diff --git a/tests/crashes/124464.rs b/tests/crashes/124464.rs new file mode 100644 index 00000000000..471479f5cf1 --- /dev/null +++ b/tests/crashes/124464.rs @@ -0,0 +1,17 @@ +//@ known-bug: rust-lang/rust #124464 +enum TestOption<T> { + TestSome(T), + TestSome(T), +} + +pub struct Request { + bar: TestOption<u64>, + bar: u8, +} + +fn default_instance() -> &'static Request { + static instance: Request = Request { bar: 17 }; + &instance +} + +pub fn main() {} diff --git a/tests/crashes/124490.rs b/tests/crashes/124490.rs new file mode 100644 index 00000000000..9f605c32cf2 --- /dev/null +++ b/tests/crashes/124490.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#124490 +use io::{self as std}; +use std::collections::{self as io}; + +mod a { + pub mod b { + pub mod c {} + } +} + +use a::*; + +use b::c; +use c as b; + +fn main() {} diff --git a/tests/crashes/124552.rs b/tests/crashes/124552.rs new file mode 100644 index 00000000000..5320ce27843 --- /dev/null +++ b/tests/crashes/124552.rs @@ -0,0 +1,12 @@ +//@ known-bug: rust-lang/rust#124552 + +struct B; + +struct Foo { + b: u32, + b: B, +} + +static BAR: Foo = Foo { b: B }; + +fn main() {} diff --git a/tests/crashes/124563.rs b/tests/crashes/124563.rs new file mode 100644 index 00000000000..b082739af53 --- /dev/null +++ b/tests/crashes/124563.rs @@ -0,0 +1,46 @@ +//@ known-bug: rust-lang/rust#124563 + +use std::marker::PhantomData; + +pub trait Trait {} + +pub trait Foo { + type Trait: Trait; + type Bar: Bar; + fn foo(&mut self); +} + +pub struct FooImpl<'a, 'b, A: Trait>(PhantomData<&'a &'b A>); + +impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> +where + T: Trait, +{ + type Trait = T; + type Bar = BarImpl<'a, 'b, T>; + + fn foo(&mut self) { + self.enter_scope(|ctx| { + BarImpl(ctx); + }); + } +} + +impl<'a, 'b, T> FooImpl<'a, 'b, T> +where + T: Trait, +{ + fn enter_scope(&mut self, _scope: impl FnOnce(&mut Self)) {} +} +pub trait Bar { + type Foo: Foo; +} + +pub struct BarImpl<'a, 'b, T: Trait>(&'b mut FooImpl<'a, 'b, T>); + +impl<'a, 'b, T> Bar for BarImpl<'a, 'b, T> +where + T: Trait, +{ + type Foo = FooImpl<'a, 'b, T>; +} diff --git a/tests/crashes/124583.rs b/tests/crashes/124583.rs new file mode 100644 index 00000000000..ffd9d7521ad --- /dev/null +++ b/tests/crashes/124583.rs @@ -0,0 +1,5 @@ +//@ known-bug: rust-lang/rust#124583 + +fn main() { + let _ = -(-0.0f16); +} diff --git a/tests/crashes/124702.rs b/tests/crashes/124702.rs new file mode 100644 index 00000000000..e3767dec403 --- /dev/null +++ b/tests/crashes/124702.rs @@ -0,0 +1,14 @@ +//@ known-bug: rust-lang/rust#124702 +//@ compile-flags: -Znext-solver=coherence +trait X {} + +trait Z { + type Assoc: Y; +} +struct A<T>(T); + +impl<T: X> Z for A<T> { + type Assoc = T; +} + +impl<T> From<<A<A<T>> as Z>::Assoc> for T {} diff --git a/tests/crashes/124751.rs b/tests/crashes/124751.rs new file mode 100644 index 00000000000..f15e39965d3 --- /dev/null +++ b/tests/crashes/124751.rs @@ -0,0 +1,8 @@ +//@ known-bug: rust-lang/rust#124751 +//@ compile-flags: -Zunstable-options --edition=2024 + +#![feature(gen_blocks)] + +fn main() { + let _ = async gen || {}; +} diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs index 74801e007c4..359dd4146ba 100644 --- a/tests/ui-fulldeps/stable-mir/check_abi.rs +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -99,7 +99,7 @@ fn check_result(abi: &ArgAbi) { assert_matches!(layout.variants, VariantsShape::Multiple { .. }) } -/// Check the niche information about: `NonZeroU8` +/// Checks the niche information about `NonZero<u8>`. fn check_niche(abi: &ArgAbi) { assert!(abi.ty.kind().is_struct()); assert_matches!(abi.mode, PassMode::Direct { .. }); @@ -150,12 +150,12 @@ fn generate_input(path: &str) -> std::io::Result<()> { #![feature(c_variadic)] #![allow(unused_variables)] - use std::num::NonZeroU8; + use std::num::NonZero; pub fn fn_abi( ignore: [u8; 0], primitive: char, - niche: NonZeroU8, + niche: NonZero<u8>, ) -> Result<usize, &'static str> {{ // We only care about the signature. todo!() diff --git a/tests/ui/mismatched_types/non_zero_assigned_something.rs b/tests/ui/mismatched_types/non_zero_assigned_something.rs index d2adbe01c18..e94d5249d6a 100644 --- a/tests/ui/mismatched_types/non_zero_assigned_something.rs +++ b/tests/ui/mismatched_types/non_zero_assigned_something.rs @@ -1,9 +1,9 @@ fn main() { - let _: std::num::NonZeroU64 = 1; + let _: std::num::NonZero<u64> = 1; //~^ ERROR mismatched types - //~| HELP consider calling `NonZeroU64::new` + //~| HELP consider calling `NonZero::new` - let _: Option<std::num::NonZeroU64> = 1; + let _: Option<std::num::NonZero<u64>> = 1; //~^ ERROR mismatched types - //~| HELP consider calling `NonZeroU64::new` + //~| HELP consider calling `NonZero::new` } diff --git a/tests/ui/mismatched_types/non_zero_assigned_something.stderr b/tests/ui/mismatched_types/non_zero_assigned_something.stderr index f8e86905ab9..aa015bd2efc 100644 --- a/tests/ui/mismatched_types/non_zero_assigned_something.stderr +++ b/tests/ui/mismatched_types/non_zero_assigned_something.stderr @@ -1,32 +1,32 @@ error[E0308]: mismatched types - --> $DIR/non_zero_assigned_something.rs:2:35 + --> $DIR/non_zero_assigned_something.rs:2:37 | -LL | let _: std::num::NonZeroU64 = 1; - | -------------------- ^ expected `NonZero<u64>`, found integer +LL | let _: std::num::NonZero<u64> = 1; + | ---------------------- ^ expected `NonZero<u64>`, found integer | | | expected due to this | = note: expected struct `NonZero<u64>` found type `{integer}` -help: consider calling `NonZeroU64::new` +help: consider calling `NonZero::new` | -LL | let _: std::num::NonZeroU64 = NonZeroU64::new(1).unwrap(); - | ++++++++++++++++ ++++++++++ +LL | let _: std::num::NonZero<u64> = NonZero::new(1).unwrap(); + | +++++++++++++ ++++++++++ error[E0308]: mismatched types - --> $DIR/non_zero_assigned_something.rs:6:43 + --> $DIR/non_zero_assigned_something.rs:6:45 | -LL | let _: Option<std::num::NonZeroU64> = 1; - | ---------------------------- ^ expected `Option<NonZero<u64>>`, found integer +LL | let _: Option<std::num::NonZero<u64>> = 1; + | ------------------------------ ^ expected `Option<NonZero<u64>>`, found integer | | | expected due to this | = note: expected enum `Option<NonZero<u64>>` found type `{integer}` -help: consider calling `NonZeroU64::new` +help: consider calling `NonZero::new` | -LL | let _: Option<std::num::NonZeroU64> = NonZeroU64::new(1); - | ++++++++++++++++ + +LL | let _: Option<std::num::NonZero<u64>> = NonZero::new(1); + | +++++++++++++ + error: aborting due to 2 previous errors diff --git a/tests/ui/rust-2018/async-ident.fixed b/tests/ui/rust-2018/async-ident.fixed index 4e31f674435..639a8a245fb 100644 --- a/tests/ui/rust-2018/async-ident.fixed +++ b/tests/ui/rust-2018/async-ident.fixed @@ -9,16 +9,14 @@ fn r#async() {} //~ ERROR async macro_rules! foo { ($foo:ident) => {}; - ($r#async:expr, r#async) => {}; + ($async:expr, r#async) => {}; //~^ ERROR async - //~| ERROR async - //~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition } foo!(r#async); - //~^ ERROR async - //~| WARN this is accepted in the current edition +//~^ ERROR async +//~| WARN this is accepted in the current edition mod dont_lint_raw { fn r#async() {} diff --git a/tests/ui/rust-2018/async-ident.rs b/tests/ui/rust-2018/async-ident.rs index 4c5134a2923..7921f05f481 100644 --- a/tests/ui/rust-2018/async-ident.rs +++ b/tests/ui/rust-2018/async-ident.rs @@ -11,14 +11,12 @@ macro_rules! foo { ($foo:ident) => {}; ($async:expr, async) => {}; //~^ ERROR async - //~| ERROR async - //~| WARN this is accepted in the current edition //~| WARN this is accepted in the current edition } foo!(async); - //~^ ERROR async - //~| WARN this is accepted in the current edition +//~^ ERROR async +//~| WARN this is accepted in the current edition mod dont_lint_raw { fn r#async() {} diff --git a/tests/ui/rust-2018/async-ident.stderr b/tests/ui/rust-2018/async-ident.stderr index 5b8d8184f4f..4ab061dd6f5 100644 --- a/tests/ui/rust-2018/async-ident.stderr +++ b/tests/ui/rust-2018/async-ident.stderr @@ -14,15 +14,6 @@ LL | #![deny(keyword_idents)] = note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]` error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:12:7 - | -LL | ($async:expr, async) => {}; - | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! - = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> - -error: `async` is a keyword in the 2018 edition --> $DIR/async-ident.rs:12:19 | LL | ($async:expr, async) => {}; @@ -32,7 +23,7 @@ LL | ($async:expr, async) => {}; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:19:6 + --> $DIR/async-ident.rs:17:6 | LL | foo!(async); | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -41,7 +32,7 @@ LL | foo!(async); = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:28:11 + --> $DIR/async-ident.rs:26:11 | LL | trait async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -50,7 +41,7 @@ LL | trait async {} = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:32:10 + --> $DIR/async-ident.rs:30:10 | LL | impl async for MyStruct {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -59,7 +50,7 @@ LL | impl async for MyStruct {} = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:38:12 + --> $DIR/async-ident.rs:36:12 | LL | static async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -68,7 +59,7 @@ LL | static async: u32 = 0; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:44:11 + --> $DIR/async-ident.rs:42:11 | LL | const async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -77,7 +68,7 @@ LL | const async: u32 = 0; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:50:15 + --> $DIR/async-ident.rs:48:15 | LL | impl Foo { fn async() {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -86,7 +77,7 @@ LL | impl Foo { fn async() {} } = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:55:12 + --> $DIR/async-ident.rs:53:12 | LL | struct async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -95,7 +86,7 @@ LL | struct async {} = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:58:9 + --> $DIR/async-ident.rs:56:9 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -104,7 +95,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:58:16 + --> $DIR/async-ident.rs:56:16 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -113,7 +104,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:58:24 + --> $DIR/async-ident.rs:56:24 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -122,7 +113,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:69:19 + --> $DIR/async-ident.rs:67:19 | LL | () => (pub fn async() {}) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -131,7 +122,7 @@ LL | () => (pub fn async() {}) = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:76:6 + --> $DIR/async-ident.rs:74:6 | LL | (async) => (1) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -139,5 +130,5 @@ LL | (async) => (1) = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> -error: aborting due to 15 previous errors +error: aborting due to 14 previous errors diff --git a/tests/ui/rust-2024/gen-kw-in-macro.rs b/tests/ui/rust-2024/gen-kw-in-macro.rs new file mode 100644 index 00000000000..3ccbe05b226 --- /dev/null +++ b/tests/ui/rust-2024/gen-kw-in-macro.rs @@ -0,0 +1,13 @@ +//@ check-pass + +#![deny(keyword_idents_2024)] + +macro_rules! foo { + ($gen:expr) => { + $gen + }; +} + +fn main() { + foo!(println!("hello, world")); +} diff --git a/tests/ui/rust-2024/gen-kw.e2015.stderr b/tests/ui/rust-2024/gen-kw.e2015.stderr index b12363184b7..b1074f77e00 100644 --- a/tests/ui/rust-2024/gen-kw.e2015.stderr +++ b/tests/ui/rust-2024/gen-kw.e2015.stderr @@ -22,5 +22,14 @@ LL | let gen = r#gen; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> -error: aborting due to 2 previous errors +error: `gen` is a keyword in the 2024 edition + --> $DIR/gen-kw.rs:19:27 + | +LL | () => { mod test { fn gen() {} } } + | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> + +error: aborting due to 3 previous errors diff --git a/tests/ui/rust-2024/gen-kw.e2018.stderr b/tests/ui/rust-2024/gen-kw.e2018.stderr index e10fc4c4512..b902cff7fdb 100644 --- a/tests/ui/rust-2024/gen-kw.e2018.stderr +++ b/tests/ui/rust-2024/gen-kw.e2018.stderr @@ -22,5 +22,14 @@ LL | let gen = r#gen; = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> -error: aborting due to 2 previous errors +error: `gen` is a keyword in the 2024 edition + --> $DIR/gen-kw.rs:19:27 + | +LL | () => { mod test { fn gen() {} } } + | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` + | + = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> + +error: aborting due to 3 previous errors diff --git a/tests/ui/rust-2024/gen-kw.rs b/tests/ui/rust-2024/gen-kw.rs index 3d2a3f95165..04251cbcac4 100644 --- a/tests/ui/rust-2024/gen-kw.rs +++ b/tests/ui/rust-2024/gen-kw.rs @@ -14,3 +14,12 @@ fn main() { //[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! //[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! } + +macro_rules! t { + () => { mod test { fn gen() {} } } + //~^ ERROR `gen` is a keyword in the 2024 edition + //[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! + //[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! +} + +t!(); diff --git a/tests/ui/suggestions/unused-imports.fixed b/tests/ui/suggestions/unused-imports.fixed new file mode 100644 index 00000000000..57dd091c043 --- /dev/null +++ b/tests/ui/suggestions/unused-imports.fixed @@ -0,0 +1,35 @@ +//@ run-rustfix +//@ check-pass + +#![warn(unused_imports)] + +pub mod nested { + pub struct A; + pub struct B; + pub struct C; + pub struct D; + pub mod even_more { + pub struct E; + pub struct F; + pub struct G; + } + pub mod another { + pub struct H; + pub struct I; + } +} + +use nested::B; +//~^ WARN unused import + +use nested::even_more::F; +//~^^^^^^^ WARN unused import + +// Note that the following fix should result in `::{self}`, not `::self`. The latter is invalid +// Rust syntax, so the braces should not be removed. +use nested::another::{self}; +//~^ WARN unused import + +fn main() { + let _ = (B, F, another::I); +} diff --git a/tests/ui/suggestions/unused-imports.rs b/tests/ui/suggestions/unused-imports.rs new file mode 100644 index 00000000000..5f9dd243bdd --- /dev/null +++ b/tests/ui/suggestions/unused-imports.rs @@ -0,0 +1,42 @@ +//@ run-rustfix +//@ check-pass + +#![warn(unused_imports)] + +pub mod nested { + pub struct A; + pub struct B; + pub struct C; + pub struct D; + pub mod even_more { + pub struct E; + pub struct F; + pub struct G; + } + pub mod another { + pub struct H; + pub struct I; + } +} + +use nested::{A, B, C}; +//~^ WARN unused import + +use nested::{ + D, + even_more::{ + E, + F, + G, + }, + }; +//~^^^^^^^ WARN unused import + +// Note that the following fix should result in `::{self}`, not `::self`. The latter is invalid +// Rust syntax, so the braces should not be removed. +use nested::another::{self, I}; +//~^ WARN unused import + +fn main() { + let _ = (B, F, another::I); +} diff --git a/tests/ui/suggestions/unused-imports.stderr b/tests/ui/suggestions/unused-imports.stderr new file mode 100644 index 00000000000..bf112608da7 --- /dev/null +++ b/tests/ui/suggestions/unused-imports.stderr @@ -0,0 +1,32 @@ +warning: unused imports: `A`, `C` + --> $DIR/unused-imports.rs:22:14 + | +LL | use nested::{A, B, C}; + | ^ ^ + | +note: the lint level is defined here + --> $DIR/unused-imports.rs:4:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: unused imports: `D`, `E`, `G` + --> $DIR/unused-imports.rs:26:5 + | +LL | D, + | ^ +LL | even_more::{ +LL | E, + | ^ +LL | F, +LL | G, + | ^ + +warning: unused import: `I` + --> $DIR/unused-imports.rs:37:29 + | +LL | use nested::another::{self, I}; + | ^ + +warning: 3 warnings emitted + diff --git a/tests/ui/type/pattern_types/range_patterns_usage.rs b/tests/ui/type/pattern_types/range_patterns_usage.rs index 7fe50423c51..2a9f736ae61 100644 --- a/tests/ui/type/pattern_types/range_patterns_usage.rs +++ b/tests/ui/type/pattern_types/range_patterns_usage.rs @@ -8,7 +8,7 @@ use std::pat::pattern_type; -type X = std::num::NonZeroU32; +type X = std::num::NonZero<u32>; type Y = pattern_type!(u32 is 1..); type Z = Option<pattern_type!(u32 is 1..)>; struct NonZeroU32New(pattern_type!(u32 is 1..)); |
