From fb52da38088ccc885aaedc02b227dc5ffca15f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 25 Jan 2025 22:30:38 +0100 Subject: [PATCH] crashes: more tests --- tests/crashes/135470.rs | 40 +++++++++++++++++++++++++++++++++ tests/crashes/135528.rs | 18 +++++++++++++++ tests/crashes/135570.rs | 12 ++++++++++ tests/crashes/135617.rs | 13 +++++++++++ tests/crashes/135646.rs | 5 +++++ tests/crashes/135668.rs | 38 +++++++++++++++++++++++++++++++ tests/crashes/135718.rs | 50 +++++++++++++++++++++++++++++++++++++++++ tests/crashes/135720.rs | 4 ++++ tests/crashes/135845.rs | 6 +++++ tests/crashes/135863.rs | 10 +++++++++ tests/crashes/136063.rs | 6 +++++ 11 files changed, 202 insertions(+) create mode 100644 tests/crashes/135470.rs create mode 100644 tests/crashes/135528.rs create mode 100644 tests/crashes/135570.rs create mode 100644 tests/crashes/135617.rs create mode 100644 tests/crashes/135646.rs create mode 100644 tests/crashes/135668.rs create mode 100644 tests/crashes/135718.rs create mode 100644 tests/crashes/135720.rs create mode 100644 tests/crashes/135845.rs create mode 100644 tests/crashes/135863.rs create mode 100644 tests/crashes/136063.rs diff --git a/tests/crashes/135470.rs b/tests/crashes/135470.rs new file mode 100644 index 0000000000000..7d357a9317f34 --- /dev/null +++ b/tests/crashes/135470.rs @@ -0,0 +1,40 @@ +//@ known-bug: #135470 +//@ compile-flags: --edition=2021 -Copt-level=0 + +use std::future::Future; +trait Access { + type Lister; + + fn list() -> impl Future { + async { todo!() } + } +} + +trait Foo {} +impl Access for dyn Foo { + type Lister = (); +} + +fn main() { + let svc = async { + async { ::list() }.await; + }; + &svc as &dyn Service; +} + +trait UnaryService { + fn call2() {} +} +trait Unimplemented {} +impl UnaryService for T {} +struct Wrap(T); +impl UnaryService for Wrap {} + +trait Service { + fn call(&self); +} +impl Service for T { + fn call(&self) { + Wrap::::call2(); + } +} diff --git a/tests/crashes/135528.rs b/tests/crashes/135528.rs new file mode 100644 index 0000000000000..a1418f40be6a6 --- /dev/null +++ b/tests/crashes/135528.rs @@ -0,0 +1,18 @@ +//@ known-bug: #135528 +//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes +#![feature(type_alias_impl_trait)] +type Tait = impl Copy; + +fn set(x: &isize) -> isize { + *x +} + +fn d(x: Tait) { + set(x); +} + +fn other_define() -> Tait { + () +} + +fn main() {} diff --git a/tests/crashes/135570.rs b/tests/crashes/135570.rs new file mode 100644 index 0000000000000..a9eda97ef9de7 --- /dev/null +++ b/tests/crashes/135570.rs @@ -0,0 +1,12 @@ +//@ known-bug: #135570 +//@compile-flags: -Zvalidate-mir -Zmir-enable-passes=+Inline -Copt-level=0 -Zmir-enable-passes=+GVN +//@ only-x86_64 + +fn function_with_bytes( +) -> &'static [u8] { + BYTES +} + +fn main() { + function_with_bytes::() == &[]; +} diff --git a/tests/crashes/135617.rs b/tests/crashes/135617.rs new file mode 100644 index 0000000000000..ac524b823a089 --- /dev/null +++ b/tests/crashes/135617.rs @@ -0,0 +1,13 @@ +//@ known-bug: #135617 +trait Project { + const ASSOC: usize; +} + +fn foo() +where + for<'a> (): Project, +{ + [(); <() as Project>::ASSOC]; +} + +pub fn main() {} diff --git a/tests/crashes/135646.rs b/tests/crashes/135646.rs new file mode 100644 index 0000000000000..67b0ad93db4c0 --- /dev/null +++ b/tests/crashes/135646.rs @@ -0,0 +1,5 @@ +//@ known-bug: #135646 +//@ compile-flags: --edition=2024 -Zpolonius=next +fn main() { + &{ [1, 2, 3][4] }; +} diff --git a/tests/crashes/135668.rs b/tests/crashes/135668.rs new file mode 100644 index 0000000000000..8126a65606b27 --- /dev/null +++ b/tests/crashes/135668.rs @@ -0,0 +1,38 @@ +//@ known-bug: #135668 +//@ compile-flags: --edition=2021 +use std::future::Future; + +pub async fn foo() { + let _ = create_task().await; +} + +async fn create_task() -> impl Sized { + bind(documentation) +} + +async fn documentation() { + include_str!("nonexistent"); +} + +fn bind(_filter: F) -> impl Sized +where + F: FilterBase, +{ + || -> ::Assoc { panic!() } +} + +trait FilterBase { + type Assoc; +} + +impl FilterBase for F +where + F: Fn() -> R, + // Removing the below line makes it correctly error on both stable and beta + R: Future, + // Removing the below line makes it ICE on both stable and beta + R: Send, + // Removing the above two bounds makes it ICE on stable but correctly error on beta +{ + type Assoc = F; +} diff --git a/tests/crashes/135718.rs b/tests/crashes/135718.rs new file mode 100644 index 0000000000000..c0e628f4c46c3 --- /dev/null +++ b/tests/crashes/135718.rs @@ -0,0 +1,50 @@ +//@ known-bug: #135718 + +struct Equal; + +struct Bar; + +trait TwiceNested {} +impl TwiceNested for Bar where Bar: NestMakeEqual {} + +struct Sum; + +trait Not { + fn not(); +} + +impl

Not for Sum +where + Bar: NestMakeEqual, + Self: Problem

, +{ + fn not() {} +} + +trait NestMakeEqual { + type NestEq; +} + +trait MakeEqual { + type Eq; +} + +struct Foo; +impl MakeEqual for Foo { + type Eq = Equal; +} + +impl NestMakeEqual for Bar +where + Foo: MakeEqual, +{ + type NestEq = O; +} + +trait Problem {} +impl Problem<()> for Sum where Bar: TwiceNested {} +impl Problem for Sum where Bar: TwiceNested {} + +fn main() { + Sum::not(); +} diff --git a/tests/crashes/135720.rs b/tests/crashes/135720.rs new file mode 100644 index 0000000000000..ee85bc4b66a1a --- /dev/null +++ b/tests/crashes/135720.rs @@ -0,0 +1,4 @@ +//@ known-bug: #135720 +#![feature(generic_const_exprs)] +type S<'l> = [i32; A]; +fn lint_me(x: S<()>) {} diff --git a/tests/crashes/135845.rs b/tests/crashes/135845.rs new file mode 100644 index 0000000000000..ed038d8a1f187 --- /dev/null +++ b/tests/crashes/135845.rs @@ -0,0 +1,6 @@ +//@ known-bug: #135845 +struct S<'a, T: ?Sized>(&'a T); + +fn b<'a>() -> S<'static, _> { + S::<'a>(&0) +} diff --git a/tests/crashes/135863.rs b/tests/crashes/135863.rs new file mode 100644 index 0000000000000..a0ff5988a0db2 --- /dev/null +++ b/tests/crashes/135863.rs @@ -0,0 +1,10 @@ +//@ known-bug: #135863 +struct A; + +impl A { + fn len(self: &&B) {} +} + +fn main() { + A.len() +} diff --git a/tests/crashes/136063.rs b/tests/crashes/136063.rs new file mode 100644 index 0000000000000..078cc59dfa28a --- /dev/null +++ b/tests/crashes/136063.rs @@ -0,0 +1,6 @@ +//@ known-bug: #136063 +#![feature(generic_const_exprs)] +trait A {} +impl A<1> for bool {} +fn bar(arg : &dyn A) { bar(true) } +pub fn main() {}