crashes: more tests

This commit is contained in:
Matthias Krüger 2025-01-25 22:30:38 +01:00
parent 43ca9d18e3
commit fb52da3808
11 changed files with 202 additions and 0 deletions

40
tests/crashes/135470.rs Normal file
View file

@ -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<Output = Self::Lister> {
async { todo!() }
}
}
trait Foo {}
impl Access for dyn Foo {
type Lister = ();
}
fn main() {
let svc = async {
async { <dyn Foo>::list() }.await;
};
&svc as &dyn Service;
}
trait UnaryService {
fn call2() {}
}
trait Unimplemented {}
impl<T: Unimplemented> UnaryService for T {}
struct Wrap<T>(T);
impl<T: Send> UnaryService for Wrap<T> {}
trait Service {
fn call(&self);
}
impl<T: Send> Service for T {
fn call(&self) {
Wrap::<T>::call2();
}
}

18
tests/crashes/135528.rs Normal file
View file

@ -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() {}

12
tests/crashes/135570.rs Normal file
View file

@ -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<const BYTES: &'static [u8; 0xc7b889180b67b07d_bc1a3c88783d35b5_u128]>(
) -> &'static [u8] {
BYTES
}
fn main() {
function_with_bytes::<b"aa">() == &[];
}

13
tests/crashes/135617.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #135617
trait Project {
const ASSOC: usize;
}
fn foo()
where
for<'a> (): Project,
{
[(); <() as Project>::ASSOC];
}
pub fn main() {}

5
tests/crashes/135646.rs Normal file
View file

@ -0,0 +1,5 @@
//@ known-bug: #135646
//@ compile-flags: --edition=2024 -Zpolonius=next
fn main() {
&{ [1, 2, 3][4] };
}

38
tests/crashes/135668.rs Normal file
View file

@ -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<F>(_filter: F) -> impl Sized
where
F: FilterBase,
{
|| -> <F as FilterBase>::Assoc { panic!() }
}
trait FilterBase {
type Assoc;
}
impl<F, R> 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;
}

50
tests/crashes/135718.rs Normal file
View file

@ -0,0 +1,50 @@
//@ known-bug: #135718
struct Equal;
struct Bar;
trait TwiceNested {}
impl<M> TwiceNested for Bar where Bar: NestMakeEqual<NestEq = M> {}
struct Sum;
trait Not {
fn not();
}
impl<P> Not for Sum
where
Bar: NestMakeEqual<NestEq = P>,
Self: Problem<P>,
{
fn not() {}
}
trait NestMakeEqual {
type NestEq;
}
trait MakeEqual {
type Eq;
}
struct Foo;
impl MakeEqual for Foo {
type Eq = Equal;
}
impl<O> NestMakeEqual for Bar
where
Foo: MakeEqual<Eq = O>,
{
type NestEq = O;
}
trait Problem<M> {}
impl Problem<()> for Sum where Bar: TwiceNested {}
impl Problem<Equal> for Sum where Bar: TwiceNested {}
fn main() {
Sum::not();
}

4
tests/crashes/135720.rs Normal file
View file

@ -0,0 +1,4 @@
//@ known-bug: #135720
#![feature(generic_const_exprs)]
type S<'l> = [i32; A];
fn lint_me(x: S<()>) {}

6
tests/crashes/135845.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #135845
struct S<'a, T: ?Sized>(&'a T);
fn b<'a>() -> S<'static, _> {
S::<'a>(&0)
}

10
tests/crashes/135863.rs Normal file
View file

@ -0,0 +1,10 @@
//@ known-bug: #135863
struct A;
impl A {
fn len(self: &&B) {}
}
fn main() {
A.len()
}

6
tests/crashes/136063.rs Normal file
View file

@ -0,0 +1,6 @@
//@ known-bug: #136063
#![feature(generic_const_exprs)]
trait A<const B: u8 = X> {}
impl A<1> for bool {}
fn bar(arg : &dyn A<x>) { bar(true) }
pub fn main() {}