From 1d45b7adafe9e011993a1a319e9312366ede2221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 15 Apr 2024 23:01:02 +0200 Subject: [PATCH] crashes: add a couple more tests --- tests/crashes/100618.rs | 12 +++++++++++ tests/crashes/105299.rs | 19 +++++++++++++++++ tests/crashes/107362.rs | 43 ++++++++++++++++++++++++++++++++++++++ tests/crashes/108499.rs | 44 +++++++++++++++++++++++++++++++++++++++ tests/crashes/114920.rs | 2 ++ tests/crashes/118185-2.rs | 26 +++++++++++++++++++++++ tests/crashes/118545.rs | 8 +++++++ tests/crashes/118590.rs | 11 ++++++++++ tests/crashes/119381.rs | 6 ++++++ tests/crashes/120033.rs | 14 +++++++++++++ tests/crashes/120254.rs | 24 +++++++++++++++++++++ tests/crashes/121363.rs | 9 ++++++++ tests/crashes/121538.rs | 30 ++++++++++++++++++++++++++ tests/crashes/122259.rs | 12 +++++++++++ tests/crashes/122630.rs | 22 ++++++++++++++++++++ tests/crashes/97006.rs | 15 +++++++++++++ 16 files changed, 297 insertions(+) create mode 100644 tests/crashes/100618.rs create mode 100644 tests/crashes/105299.rs create mode 100644 tests/crashes/107362.rs create mode 100644 tests/crashes/108499.rs create mode 100644 tests/crashes/114920.rs create mode 100644 tests/crashes/118185-2.rs create mode 100644 tests/crashes/118545.rs create mode 100644 tests/crashes/118590.rs create mode 100644 tests/crashes/119381.rs create mode 100644 tests/crashes/120033.rs create mode 100644 tests/crashes/120254.rs create mode 100644 tests/crashes/121363.rs create mode 100644 tests/crashes/121538.rs create mode 100644 tests/crashes/122259.rs create mode 100644 tests/crashes/122630.rs create mode 100644 tests/crashes/97006.rs diff --git a/tests/crashes/100618.rs b/tests/crashes/100618.rs new file mode 100644 index 0000000000000..911c4098badc0 --- /dev/null +++ b/tests/crashes/100618.rs @@ -0,0 +1,12 @@ +//@ known-bug: #100618 +//@ compile-flags: -Cdebuginfo=2 + +//@ only-x86_64 +enum Foo { + Value(T), + Recursive(&'static Foo>), +} + +fn main() { + let _x = Foo::Value(()); +} diff --git a/tests/crashes/105299.rs b/tests/crashes/105299.rs new file mode 100644 index 0000000000000..8e3aafa47bc9f --- /dev/null +++ b/tests/crashes/105299.rs @@ -0,0 +1,19 @@ +//@ known-bug: #105299 + +pub trait Foo: Clone {} + +pub struct Bar<'a, T: Clone> { + pub cow: std::borrow::Cow<'a, [T]>, + + pub THIS_CAUSES_ICE: (), // #1 +} + +impl Bar<'_, T> +where + T: Clone, + [T]: Foo, +{ + pub fn MOVES_SELF(self) {} // #2 +} + +pub fn main() {} diff --git a/tests/crashes/107362.rs b/tests/crashes/107362.rs new file mode 100644 index 0000000000000..8d55d611eb133 --- /dev/null +++ b/tests/crashes/107362.rs @@ -0,0 +1,43 @@ +//@ known-bug: #107362 +//@ compile-flags: -Cdebuginfo=2 + +pub trait Functor +{ + type With: Functor; +} + +pub struct IdFunctor(T); +impl Functor for IdFunctor { + type With = IdFunctor; +} + +impl Functor for Vec { + type With = Vec ; +} + + +pub struct Compose(F1::With>) +where + F1: Functor + ?Sized, + F2: Functor + ?Sized; + +impl Functor for Compose +where + F1: Functor + ?Sized, + F2: Functor + ?Sized +{ + type With = F1::With> ; +} + +pub enum Value +where + F: Functor + ?Sized, +{ + SignedInt(*mut F::With), + Array(*mut Value, ()>>), + +} + +fn main() { + let x: Value> = Value::SignedInt(&mut IdFunctor(1)); +} diff --git a/tests/crashes/108499.rs b/tests/crashes/108499.rs new file mode 100644 index 0000000000000..4a0638cd59ae4 --- /dev/null +++ b/tests/crashes/108499.rs @@ -0,0 +1,44 @@ +//@ known-bug: #108499 + +// at lower recursion limits the recursion limit is reached before the bug happens +#![recursion_limit = "2000"] + +// this will try to calculate 3↑↑3=3^(3^3) +type Test = <() as Op<((), ()), [[[(); 0]; 0]; 0], [[[(); 0]; 0]; 0], + [[[[(); 0]; 0]; 0]; 0]>>::Result; + +use std::default::Default; + +fn main() { + // force the compiler to actually evaluate `Test` + println!("{}", Test::default()); +} + +trait Op { + type Result; +} + +// this recursive function defines the hyperoperation sequence, +// a canonical example of the type of recursion which produces the issue +// the problem seems to be caused by having two recursive calls, the second +// of which depending on the first +impl< + X: Op<(X, Y), A, [B; 0], [C; 0]>, + Y: Op<(X, Y), A, X::Result, C>, + A, B, C, +> Op<(X, Y), A, [[B; 0]; 0], [C; 0]> for () { + type Result = Y::Result; +} + +// base cases +impl Op for () { + type Result = [B; 0]; +} + +impl Op for () { + type Result = [A; 0]; +} + +impl Op for () { + type Result = A; +} diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs new file mode 100644 index 0000000000000..9aa7598e10fc3 --- /dev/null +++ b/tests/crashes/114920.rs @@ -0,0 +1,2 @@ +//@ known-bug: #114920 +#![core::prelude::v1::test] diff --git a/tests/crashes/118185-2.rs b/tests/crashes/118185-2.rs new file mode 100644 index 0000000000000..c3a29c3a3f54a --- /dev/null +++ b/tests/crashes/118185-2.rs @@ -0,0 +1,26 @@ +//@ known-bug: #118185 + +fn main() { + let target: Target = create_target(); + target.get(0); // correct arguments work + target.get(10.0); // CRASH HERE +} + +// must be generic +fn create_target() -> T { + unimplemented!() +} + +// unimplemented trait, but contains function with the same name +pub trait RandomTrait { + fn get(&mut self); // but less arguments +} + +struct Target; + +impl Target { + // correct function with arguments + pub fn get(&self, data: i32) { + unimplemented!() + } +} diff --git a/tests/crashes/118545.rs b/tests/crashes/118545.rs new file mode 100644 index 0000000000000..1d4bb848bf04e --- /dev/null +++ b/tests/crashes/118545.rs @@ -0,0 +1,8 @@ +//@ known-bug: #118545 +#![feature(generic_const_exprs)] + +struct Checked; + +fn foo() {} +const _: Checked = Checked::; +pub fn main() {} diff --git a/tests/crashes/118590.rs b/tests/crashes/118590.rs new file mode 100644 index 0000000000000..829c16582dc92 --- /dev/null +++ b/tests/crashes/118590.rs @@ -0,0 +1,11 @@ +//@ known-bug: #118590 + +fn main() { + recurse(std::iter::empty::<()>()) +} + +fn recurse(nums: impl Iterator) { + if true { return } + + recurse(nums.skip(42).peekable()) +} diff --git a/tests/crashes/119381.rs b/tests/crashes/119381.rs new file mode 100644 index 0000000000000..51d1d084ba2bc --- /dev/null +++ b/tests/crashes/119381.rs @@ -0,0 +1,6 @@ +//@ known-bug: #119381 + +#![feature(with_negative_coherence)] +trait Trait {} +impl Trait for [(); N] {} +impl Trait for [(); N] {} diff --git a/tests/crashes/120033.rs b/tests/crashes/120033.rs new file mode 100644 index 0000000000000..f1502978dc511 --- /dev/null +++ b/tests/crashes/120033.rs @@ -0,0 +1,14 @@ +//@ known-bug: #120033 +#![feature(non_lifetime_binders)] + +pub trait Foo { + type Bar; +} + +pub struct Bar {} + +pub fn f() +where + T1: for Foo>, + T2: for Foo = T1::Bar>, +{} diff --git a/tests/crashes/120254.rs b/tests/crashes/120254.rs new file mode 100644 index 0000000000000..ea68523820ec0 --- /dev/null +++ b/tests/crashes/120254.rs @@ -0,0 +1,24 @@ +//@ known-bug: #120254 + +trait Dbg {} + +struct Foo { + input: I, + errors: E, +} + +trait Bar: Offset<::Checkpoint> { + type Checkpoint; +} + +impl Bar for Foo { + type Checkpoint = I::Checkpoint; +} + +trait Offset {} + +impl Offset< as Bar>::Checkpoint> for Foo {} + +impl Foo { + fn record_err(self, _: ::Checkpoint) -> () {} +} diff --git a/tests/crashes/121363.rs b/tests/crashes/121363.rs new file mode 100644 index 0000000000000..2a5b6274496fb --- /dev/null +++ b/tests/crashes/121363.rs @@ -0,0 +1,9 @@ +//@ known-bug: #121363 +//@ compile-flags: -Zmir-opt-level=5 --crate-type lib + +#![feature(trivial_bounds)] + +#[derive(Debug)] +struct TwoStrs(str, str) +where + str: Sized; diff --git a/tests/crashes/121538.rs b/tests/crashes/121538.rs new file mode 100644 index 0000000000000..f18bad84b5724 --- /dev/null +++ b/tests/crashes/121538.rs @@ -0,0 +1,30 @@ +//@ known-bug: #121538 +//@ compile-flags: -Cdebuginfo=2 + +use std::marker::PhantomData; + +struct Digit { + elem: T +} + +struct Node { m: PhantomData<&'static T> } + +enum FingerTree { + Single(T), + + Deep( + Digit, + Node>>, + ) +} + +enum Wrapper { + Simple, + Other(FingerTree), +} + +fn main() { + let w = + Some(Wrapper::Simple::); + +} diff --git a/tests/crashes/122259.rs b/tests/crashes/122259.rs new file mode 100644 index 0000000000000..5ac8063f0f382 --- /dev/null +++ b/tests/crashes/122259.rs @@ -0,0 +1,12 @@ +//@ known-bug: #122259 + +#![feature(unsized_fn_params)] + +#[derive(Copy, Clone)] +struct Target(str); + +fn w(t: &Target) { + x(*t); +} + +fn x(t: Target) {} diff --git a/tests/crashes/122630.rs b/tests/crashes/122630.rs new file mode 100644 index 0000000000000..e66624431c510 --- /dev/null +++ b/tests/crashes/122630.rs @@ -0,0 +1,22 @@ +//@ known-bug: #122630 +//@ compile-flags: -Zvalidate-mir + +use std::ops::Coroutine; + +const FOO_SIZE: usize = 1024; +struct Foo([u8; FOO_SIZE]); + +impl Drop for Foo { + fn move_before_yield_with_noop() -> impl Coroutine {} +} + +fn overlap_move_points() -> impl Coroutine { + static || { + let first = Foo([0; FOO_SIZE]); + yield; + let second = first; + yield; + let second = first; + yield; + } +} diff --git a/tests/crashes/97006.rs b/tests/crashes/97006.rs new file mode 100644 index 0000000000000..c8dfa52ebee07 --- /dev/null +++ b/tests/crashes/97006.rs @@ -0,0 +1,15 @@ +//@ known-bug: #97006 +//@ compile-flags: -Zunpretty=hir + +#![allow(unused)] + +macro_rules! m { + ($attr_path: path) => { + #[$attr_path] + fn f() {} + } +} + +m!(inline); //~ ERROR: unexpected generic arguments in path + +fn main() {}