diff --git a/tests/crashes/130956.rs b/tests/crashes/130956.rs new file mode 100644 index 0000000000000..ebb986d123f91 --- /dev/null +++ b/tests/crashes/130956.rs @@ -0,0 +1,37 @@ +//@ known-bug: #130956 + +mod impl_trait_mod { + use super::*; + pub type OpaqueBlock = impl Trait; + pub type OpaqueIf = impl Trait; + + pub struct BlockWrapper(OpaqueBlock); + pub struct IfWrapper(pub OpaqueIf); + + pub fn if_impl() -> Parser { + bind(option(block()), |_| block()) + } +} +use impl_trait_mod::*; + +pub trait Trait { + type Assoc; +} +pub struct Parser

(P); +pub struct Bind(P, F); +impl Trait for Bind { type Assoc = (); } +impl Trait for BlockWrapper { type Assoc = (); } +impl Trait for IfWrapper { type Assoc = (); } + +pub fn block() -> Parser { + loop {} +} +pub fn option(arg: Parser

) -> Parser { + bind(arg, |_| block()) +} +fn bind Parser>(_: Parser

, _: F) -> Parser> + { loop {} } + +fn main() { + if_impl().0; +} diff --git a/tests/crashes/130967.rs b/tests/crashes/130967.rs new file mode 100644 index 0000000000000..8a3aae72c20c5 --- /dev/null +++ b/tests/crashes/130967.rs @@ -0,0 +1,13 @@ +//@ known-bug: #130967 + +trait Producer { + type Produced; + fn make_one() -> Self::Produced; +} + +impl Producer for () { + type Produced = Option; + fn make_one() -> Self::Produced { + loop {} + } +} diff --git a/tests/crashes/131046.rs b/tests/crashes/131046.rs new file mode 100644 index 0000000000000..2638705ae18b2 --- /dev/null +++ b/tests/crashes/131046.rs @@ -0,0 +1,15 @@ +//@ known-bug: #131046 + +trait Owner { + const C: u32; +} + +impl Owner for () { + const C: u32 = N; +} + +fn take0(_: impl Owner = { N }>) {} + +fn main() { + take0::<128>(()); +} diff --git a/tests/crashes/131048.rs b/tests/crashes/131048.rs new file mode 100644 index 0000000000000..d57e9921a8ab5 --- /dev/null +++ b/tests/crashes/131048.rs @@ -0,0 +1,7 @@ +//@ known-bug: #131048 + +impl std::ops::CoerceUnsized for A {} + +fn main() { + format_args!("Hello, world!"); +} diff --git a/tests/crashes/131050.rs b/tests/crashes/131050.rs new file mode 100644 index 0000000000000..07f8662d016f7 --- /dev/null +++ b/tests/crashes/131050.rs @@ -0,0 +1,27 @@ +//@ known-bug: #131050 +//@ compile-flags: --edition=2021 + +fn query_as() {} + +async fn create_user() { + query_as(); +} + +async fn post_user_filter() -> impl Filter { + AndThen(&(), || async { create_user().await }) +} + +async fn get_app() -> impl Send { + post_user_filter().await +} + +trait Filter {} + +struct AndThen(T, F); + +impl Filter for AndThen +where + F: Fn() -> R, + R: Send, +{ +} diff --git a/tests/crashes/131052.rs b/tests/crashes/131052.rs new file mode 100644 index 0000000000000..7ae3ec08f3ed7 --- /dev/null +++ b/tests/crashes/131052.rs @@ -0,0 +1,8 @@ +//@ known-bug: #131052 +#![feature(adt_const_params)] + +struct ConstBytes; + +pub fn main() { + let _: ConstBytes = ConstBytes::; +} diff --git a/tests/crashes/131101.rs b/tests/crashes/131101.rs new file mode 100644 index 0000000000000..3ec441101b7d9 --- /dev/null +++ b/tests/crashes/131101.rs @@ -0,0 +1,12 @@ +//@ known-bug: #131101 +trait Foo { + fn do_x(&self) -> [u8; N]; +} + +struct Bar; + +impl Foo for Bar { + fn do_x(&self) -> [u8; 3] { + [0u8; 3] + } +} diff --git a/tests/crashes/131102.rs b/tests/crashes/131102.rs new file mode 100644 index 0000000000000..12b35f8d1b2ac --- /dev/null +++ b/tests/crashes/131102.rs @@ -0,0 +1,4 @@ +//@ known-bug: #131102 +pub struct Blorb([String; N]); +pub struct Wrap(Blorb<0>); +pub const fn i(_: Wrap) {} diff --git a/tests/crashes/131103.rs b/tests/crashes/131103.rs new file mode 100644 index 0000000000000..70193e8b3bd38 --- /dev/null +++ b/tests/crashes/131103.rs @@ -0,0 +1,6 @@ +//@ known-bug: #131103 +struct Struct(pub [u8; N]); + +pub fn function(value: Struct<3>) -> u8 { + value.0[0] +} diff --git a/tests/crashes/131190.rs b/tests/crashes/131190.rs new file mode 100644 index 0000000000000..3a0e64c69d5b5 --- /dev/null +++ b/tests/crashes/131190.rs @@ -0,0 +1,19 @@ +//@ known-bug: #131190 +//@ compile-flags: -Cinstrument-coverage --edition=2018 + +use std::future::Future; + +pub fn block_on(fut: impl Future) -> T {} + +async fn call_once(f: impl async FnOnce(DropMe)) { + f(DropMe("world")).await; +} + +struct DropMe(&'static str); + +pub fn main() { + block_on(async { + let async_closure = async move |a: DropMe| {}; + call_once(async_closure).await; + }); +} diff --git a/tests/crashes/131227.rs b/tests/crashes/131227.rs new file mode 100644 index 0000000000000..f46185b5b4a66 --- /dev/null +++ b/tests/crashes/131227.rs @@ -0,0 +1,16 @@ +//@ known-bug: #131227 +//@ compile-flags: -Zmir-opt-level=3 + +static mut G: () = (); + +fn myfunc() -> i32 { + let var = &raw mut G; + if var.is_null() { + return 0; + } + 0 +} + +fn main() { + myfunc(); +} diff --git a/tests/crashes/131292.rs b/tests/crashes/131292.rs new file mode 100644 index 0000000000000..01e0eca0bd6d6 --- /dev/null +++ b/tests/crashes/131292.rs @@ -0,0 +1,7 @@ +//@ known-bug: #131292 +//@ only-x86_64 +use std::arch::asm; + +unsafe fn f6() { + asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt")); +} diff --git a/tests/crashes/131294-2.rs b/tests/crashes/131294-2.rs new file mode 100644 index 0000000000000..130a8b10fb78e --- /dev/null +++ b/tests/crashes/131294-2.rs @@ -0,0 +1,25 @@ +//@ known-bug: #131294 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always + +// https://github.com/rust-lang/rust/issues/131294#issuecomment-2395088049 second comment +struct Rows; + +impl Iterator for Rows { + type Item = String; + + fn next() -> Option { + let args = format_args!("Hello world"); + + { + match args.as_str() { + Some(t) => t.to_owned(), + None => String::new(), + } + } + .into() + } +} + +fn main() { + Rows.next(); +} diff --git a/tests/crashes/131294.rs b/tests/crashes/131294.rs new file mode 100644 index 0000000000000..ec6c95674677e --- /dev/null +++ b/tests/crashes/131294.rs @@ -0,0 +1,16 @@ +//@ known-bug: #131294 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always + +struct Rows; + +impl Iterator for Rows { + type Item = String; + + fn next() -> Option { + std::fmt::format(format_args!("Hello world")).into() + } +} + +fn main() { + Rows.next(); +} diff --git a/tests/crashes/131295.rs b/tests/crashes/131295.rs new file mode 100644 index 0000000000000..f31d6bc324a26 --- /dev/null +++ b/tests/crashes/131295.rs @@ -0,0 +1,9 @@ +//@ known-bug: #131295 + +#![feature(generic_const_exprs)] + +async fn foo<'a>() -> [(); { + let _y: &'a (); + 4 + }] { +} diff --git a/tests/crashes/131298.rs b/tests/crashes/131298.rs new file mode 100644 index 0000000000000..833f1b04ffab9 --- /dev/null +++ b/tests/crashes/131298.rs @@ -0,0 +1,12 @@ +//@ known-bug: #131298 + +fn dyn_hoops() -> *const dyn Iterator { + loop {} +} + +mod typeck { + type Opaque = impl Sized; + fn define() -> Opaque { + let _: Opaque = super::dyn_hoops::(); + } +} diff --git a/tests/crashes/131342-2.rs b/tests/crashes/131342-2.rs new file mode 100644 index 0000000000000..79b6a837a49fb --- /dev/null +++ b/tests/crashes/131342-2.rs @@ -0,0 +1,40 @@ +//@ known-bug: #131342 +// see also: 131342.rs + +fn main() { + problem_thingy(Once); +} + +struct Once; + +impl Iterator for Once { + type Item = (); +} + +fn problem_thingy(items: impl Iterator) { + let peeker = items.peekable(); + problem_thingy(&peeker); +} + +trait Iterator { + type Item; + + fn peekable(self) -> Peekable + where + Self: Sized, + { + loop {} + } +} + +struct Peekable { + _peeked: I::Item, +} + +impl Iterator for Peekable { + type Item = I::Item; +} + +impl Iterator for &I { + type Item = I::Item; +} diff --git a/tests/crashes/131342.rs b/tests/crashes/131342.rs new file mode 100644 index 0000000000000..7f7ee9c9ac110 --- /dev/null +++ b/tests/crashes/131342.rs @@ -0,0 +1,16 @@ +//@ known-bug: #131342 +// see also: 131342-2.rs + +fn main() { + let mut items = vec![1, 2, 3, 4, 5].into_iter(); + problem_thingy(&mut items); +} + +fn problem_thingy(items: &mut impl Iterator) { + let mut peeker = items.peekable(); + match peeker.peek() { + Some(_) => (), + None => return (), + } + problem_thingy(&mut peeker); +} diff --git a/tests/crashes/131347.rs b/tests/crashes/131347.rs new file mode 100644 index 0000000000000..15f367d79e208 --- /dev/null +++ b/tests/crashes/131347.rs @@ -0,0 +1,9 @@ +//@ known-bug: #131347 +//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir + +struct S; +static STUFF: [i8] = [0; S::N]; + +fn main() { + assert_eq!(STUFF, [0; 63]); +} diff --git a/tests/crashes/131373.rs b/tests/crashes/131373.rs new file mode 100644 index 0000000000000..661fecd7620b8 --- /dev/null +++ b/tests/crashes/131373.rs @@ -0,0 +1,33 @@ +//@ known-bug: #131373 + +trait LockReference: 'static { + type Ref<'a>; +} + +struct SliceRef<'a, T: ?Sized> { + _x: &'a T, +} + +impl<'a, T: ?Sized, SR: LockReference> IntoIterator for SliceRef<'a, T> +where + &'a T: IntoIterator, +{ + type Item = SR::Ref<'a>; + type IntoIter = std::iter::Map<<&'a T as IntoIterator>::IntoIter, + for<'c> fn(&'c SR) -> SR::Ref<'c>>; + fn into_iter(self) -> Self::IntoIter { + loop {} + } +} + +impl LockReference for () { + type Ref<'a> = (); +} + +fn locked() -> SliceRef<'static, [()]> { + loop {} +} + +fn main() { + let _ = locked().into_iter(); +} diff --git a/tests/crashes/131406.rs b/tests/crashes/131406.rs new file mode 100644 index 0000000000000..ea642f949280d --- /dev/null +++ b/tests/crashes/131406.rs @@ -0,0 +1,12 @@ +//@ known-bug: #131406 + +trait Owner { + const C: u32 = N; +} + +impl Owner for () {} +fn take0(_: impl Owner = { N }>) {} + +fn main() { + take0::<128>(()); +}