Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashes: more tests #133294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/crashes/132765.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #132765

trait LendingIterator {
type Item<'q>;
fn for_each(&self, _f: Box<fn(Self::Item<'_>)>) {}
}

fn f(_: ()) {}

fn main() {
LendingIterator::for_each(&(), f);
}
9 changes: 9 additions & 0 deletions tests/crashes/132766.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #132766
jieyouxu marked this conversation as resolved.
Show resolved Hide resolved

trait Trait {}
impl<'a> Trait for () {
fn pass2<'a>() -> impl Trait2 {}
}

trait Trait2 {}
impl Trait2 for () {}
24 changes: 24 additions & 0 deletions tests/crashes/132767.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ known-bug: #132767

trait Func {
type Ret;
}
impl<F: FnOnce() -> R, R> Func for F {
type Ret = R;
}

trait Id {}
fn invalid_impl_trait() -> impl Id {}

struct Foo<T: Func> {
_func: T,
value: Option<<T as Func>::Ret>,
}

fn main() {
let foo = Foo {
_func: invalid_impl_trait,
value: None,
};
drop(foo.value);
}
13 changes: 13 additions & 0 deletions tests/crashes/132882.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #132882

use std::ops::Add;

pub trait Numoid
where
for<N: Numoid> &'a Self: Add<Self>,
{
}

pub fn compute<N: Numoid>(a: N) -> N {
&a + a
}
5 changes: 5 additions & 0 deletions tests/crashes/132981.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//@ known-bug: #132981
//@compile-flags: -Clink-dead-code=true --crate-type lib

#![feature(rust_cold_cc)]
pub extern "rust-cold" fn foo(_: [usize; 3]) {}
26 changes: 26 additions & 0 deletions tests/crashes/133056.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ known-bug: #133056

pub enum ApiError {}
pub struct TokioError {
source: ApiError,
}
pub enum Error {
Api { b: bool },
Ethereum,
Tokio { source: TokioError },
}

mod assert {
use std::mem::TransmuteFrom;

pub fn is_transmutable<Src, Dst>()
where
Dst: TransmuteFrom<Src>,
{
}
}

fn test() {
type Dst = Error;
assert::is_transmutable::<Src, Dst>();
}
8 changes: 8 additions & 0 deletions tests/crashes/133063.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #133063

fn foo(x: !) {
match x {
(! | !) if false => {}
_ => {}
}
}
15 changes: 15 additions & 0 deletions tests/crashes/133065.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ known-bug: #133065
//@compile-flags: -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: hmm, this is also one of those cases where it's better to identify which mir opts are involved, like #133104. Probably split this off into another PR.

Copy link
Member Author

@matthiaskrgr matthiaskrgr Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I understand this only enables mir inlining.
does Zinline-mir also enable other opts than mir inlining?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @saethlin do you know? I'm not super familiar with the MIR-specific ones.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too convinced that this is too useful in general.
If we for example have a broken mir opt in the pipeline, and the mir opt gets banished to -Zunsave-mir-opts, this still fixes the bug from a user perspective as the mir opt is no longer run by default.

Also some mir opts rely on each other which is why I don't fuzz single mir opts, as there are probably bunch of cases where "one opt will break if that other opt is not run before it."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a crashes test we can also remove it easily if it becomes a problem, so yeah it's a whatever.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does Zinline-mir also enable other opts than mir inlining?

-Zinline-mir is the same as -Zmir-enable-passes=+Inline, and it takes work to make sure those flags don't diverge in behavior.

there are probably bunch of cases where "one opt will break if that other opt is not run before it."

There aren't supposed to be any such cases.

If we for example have a broken mir opt in the pipeline, and the mir opt gets banished to -Zunsave-mir-opts, this still fixes the bug from a user perspective as the mir opt is no longer run by default.

The crashes tests aren't about tracking the quality of the user experience, they are about tracking the state of open issues. If an ICEing MIR opt is put behind a flag, the bug is still in the code.

trait Bar: Sized {
fn bar(self) {}
}

impl<T> Bar for T {
fn bar() {
let _ = "Hello".bytes().nth(3);
}
}

fn main() {
().bar();
}
12 changes: 12 additions & 0 deletions tests/crashes/133066.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #133066
jieyouxu marked this conversation as resolved.
Show resolved Hide resolved
trait Owner {
const C<const N: u32>: u32;
}

impl Owner for () {;}

fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}

fn main() {
take0::<f32, >(());
}
11 changes: 11 additions & 0 deletions tests/crashes/133199.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: #133199
//@ aux-build: aux133199.rs
jieyouxu marked this conversation as resolved.
Show resolved Hide resolved

extern crate aux133199;

use aux133199::FixedBitSet;

fn main() {
FixedBitSet::<7>::new();
//~^ ERROR
}
13 changes: 13 additions & 0 deletions tests/crashes/133275-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #133275
#![feature(const_trait_impl)]
#![feature(associated_type_defaults)]

#[const_trait]
trait Foo3<T>
where
Self::Baz: Clone,
{
type Baz = T;
}

pub fn main() {}
15 changes: 15 additions & 0 deletions tests/crashes/133275-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ known-bug: #133275
#![feature(const_trait_impl)]
#[const_trait]
pub trait Owo<X = <IntEnum as Uwu>::T> {}

#[const_trait]
trait Foo3<T>
where
Self::Bar: Clone,
Self::Baz: Clone,
{
type Bar = Vec<Self::Baz>;
type Baz = T;
//~^ ERROR the trait bound `T: Clone` is not satisfied
}
13 changes: 13 additions & 0 deletions tests/crashes/auxiliary/aux133199.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

pub struct FixedBitSet<const N: usize>;

impl<const N: usize> FixedBitSet<N>
where
[u8; N.div_ceil(8)]: Sized,
{
pub fn new() -> Self {
todo!()
}
}
Loading