Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit da8597f

Browse files
committedMar 29, 2024
1 parent e473247 commit da8597f

31 files changed

+664
-1
lines changed
 

‎tests/crashes/100041.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: #100041
2+
3+
pub trait WellUnformed {
4+
type RequestNormalize;
5+
}
6+
7+
impl<T: ?Sized> WellUnformed for T {
8+
type RequestNormalize = ();
9+
}
10+
11+
pub fn latent(_: &[<[[()]] as WellUnformed>::RequestNormalize; 0]) {}
12+
13+
pub fn bang() {
14+
latent(&[]);
15+
}
16+
17+
fn main() {}

‎tests/crashes/101962.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #101962
2+
3+
#![feature(core_intrinsics)]
4+
5+
pub fn wrapping<T: Copy>(a: T, b: T) {
6+
let _z = core::intrinsics::wrapping_mul(a, b);
7+
}
8+
9+
fn main() {
10+
wrapping(1,2);
11+
}

‎tests/crashes/102047.rs‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//@ known-bug: #102047
2+
3+
struct Ty1;
4+
struct Ty2;
5+
6+
pub trait Trait<T> {}
7+
8+
pub trait WithAssoc1<'a> {
9+
type Assoc;
10+
}
11+
pub trait WithAssoc2<'a> {
12+
type Assoc;
13+
}
14+
15+
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
16+
where
17+
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
18+
U: for<'a> WithAssoc2<'a>,
19+
{
20+
}
21+
22+
impl WithAssoc1<'_> for Ty1 {
23+
type Assoc = ();
24+
}
25+
impl WithAssoc2<'_> for Ty1 {
26+
type Assoc = i32;
27+
}
28+
impl WithAssoc1<'_> for Ty2 {
29+
type Assoc = ();
30+
}
31+
impl WithAssoc2<'_> for Ty2 {
32+
type Assoc = u32;
33+
}
34+
35+
fn foo<T, U, V>()
36+
where
37+
T: for<'a> WithAssoc1<'a>,
38+
U: for<'a> WithAssoc2<'a>,
39+
(T, U): Trait<V>,
40+
{
41+
}
42+
43+
fn main() {
44+
foo::<Ty1, Ty2, _>();
45+
}

‎tests/crashes/102252.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #102252
2+
3+
#![feature(min_specialization, rustc_attrs)]
4+
5+
#[rustc_specialization_trait]
6+
pub trait Trait {}
7+
8+
struct Struct
9+
where
10+
Self: Iterator<Item = <Self as Iterator>::Item>, {}
11+
12+
impl Trait for Struct {}
13+
14+
fn main() {}

‎tests/crashes/103899.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #103899
2+
3+
trait BaseWithAssoc {
4+
type Assoc;
5+
}
6+
7+
trait WrapperWithAssoc {
8+
type BaseAssoc: BaseWithAssoc;
9+
}
10+
11+
struct Wrapper<B> {
12+
inner: B,
13+
}
14+
15+
struct ProjectToBase<T: BaseWithAssoc> {
16+
data_type_h: T::Assoc,
17+
}
18+
19+
struct DoubleProject<L: WrapperWithAssoc> {
20+
buffer: Wrapper<ProjectToBase<L::BaseAssoc>>,
21+
}
22+
23+
fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
24+
loop {}
25+
}
26+
27+
fn main() {}

‎tests/crashes/105238-1.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ known-bug: #105238
2+
3+
#![allow(incomplete_features)]
4+
#![feature(generic_const_exprs)]
5+
6+
trait Ret {
7+
type R;
8+
}
9+
10+
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
11+
12+
impl<U, V> Ret for Cond<true, U, V> {
13+
type R = U;
14+
}
15+
16+
impl<U, V> Ret for Cond<false, U, V> {
17+
type R = V;
18+
}
19+
20+
struct RobinHashTable<const MAX_LENGTH: usize, CellIdx = Cond<{ MAX_LENGTH < 65535 }, u16, u32>>
21+
where
22+
CellIdx: Ret,
23+
{
24+
_idx: CellIdx::R,
25+
}
26+
27+
fn main() {
28+
use std::mem::size_of;
29+
println!("{}", size_of::<RobinHashTable<1024>>());
30+
println!("{}", size_of::<RobinHashTable<65536>>());
31+
}

‎tests/crashes/105238-2.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ known-bug: #105238
2+
3+
#![allow(incomplete_features)]
4+
#![feature(generic_const_exprs)]
5+
6+
trait Ret {
7+
type R;
8+
}
9+
10+
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
11+
12+
impl<U, V> Ret for Cond<true, U, V> {
13+
type R = U;
14+
}
15+
16+
impl<U, V> Ret for Cond<false, U, V> {
17+
type R = V;
18+
}
19+
20+
struct RobinHashTable<
21+
const MAX_LENGTH: usize,
22+
CellIdx = <Cond<{ MAX_LENGTH < 65535 }, u16, u32> as Ret>::R,
23+
> {
24+
_idx: CellIdx,
25+
}
26+
27+
fn main() {
28+
use std::mem::size_of;
29+
println!("{}", size_of::<RobinHashTable<1024>>());
30+
println!("{}", size_of::<RobinHashTable<65536>>());
31+
}

‎tests/crashes/105488.rs‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ known-bug: #105488
2+
3+
pub trait MyFnOnce {
4+
type Output;
5+
6+
fn call_my_fn_once(self) -> Self::Output;
7+
}
8+
9+
pub struct WrapFnOnce<F>(F);
10+
11+
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
12+
type Output = D::Output;
13+
14+
fn call_my_fn_once(self) -> Self::Output {
15+
D::call_my_fn_once(self.0())
16+
}
17+
}
18+
19+
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
20+
type Output = D::Output;
21+
22+
fn call_my_fn_once(self) -> Self::Output {
23+
D::call_my_fn_once(self())
24+
}
25+
}
26+
27+
pub fn my_fn_1() -> impl MyFnOnce {
28+
my_fn_2
29+
}
30+
31+
pub fn my_fn_2() -> impl MyFnOnce {
32+
WrapFnOnce(my_fn_1)
33+
}
34+
35+
fn main() {
36+
let v = my_fn_1();
37+
38+
let _ = v.call_my_fn_once();
39+
}

‎tests/crashes/108814.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #108814
2+
3+
#![feature(non_lifetime_binders)]
4+
5+
fn take(_: impl for<T> FnOnce(T) -> T) {}
6+
7+
fn main() {
8+
take(|x| x)
9+
}

‎tests/crashes/109681.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #109681
2+
3+
#![crate_type="lib"]
4+
#![feature(linkage)]
5+
6+
#[linkage = "common"]
7+
pub static TEST3: bool = true;
8+
9+
fn main() {}

‎tests/crashes/110378.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #110378
2+
// ignore-tidy-linelength
3+
4+
#![feature(generic_const_exprs)]
5+
6+
fn foo<const L: usize>(_a: [u8; L], _b: [u8; L]) -> [u8; L + 1] {
7+
[0_u8; L + 1]
8+
}
9+
10+
fn main() {
11+
let baz = [[0_u8; 1]; 8];
12+
13+
let _: [u8; 4] = foo(foo(foo(baz[0], baz[1]), foo(baz[2], baz[3])), foo(foo(baz[4], baz[5]), foo(baz[6], baz[7])));
14+
//let _: [u8; 3] = foo(foo(baz[0], baz[1]), foo(baz[2], baz[3]));
15+
}

‎tests/crashes/110630.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ known-bug: #110630
2+
3+
#![feature(generic_const_exprs)]
4+
5+
use std::ops::Mul;
6+
7+
pub trait Indices<const N: usize> {
8+
const NUM_ELEMS: usize = I::NUM_ELEMS * N;
9+
}
10+
11+
pub trait Concat<J> {
12+
type Output;
13+
}
14+
15+
pub struct Tensor<I: Indices<N>, const N: usize>
16+
where
17+
[u8; I::NUM_ELEMS]: Sized, {}
18+
19+
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
20+
where
21+
I: Concat<T>,
22+
<I as Concat<J>>::Output: Indices<N>,
23+
[u8; I::NUM_ELEMS]: Sized,
24+
[u8; J::NUM_ELEMS]: Sized,
25+
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
26+
{
27+
type Output = Tensor<<I as Concat<J>>::Output, N>;
28+
}

‎tests/crashes/111742.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #111742
2+
// ignore-tidy-linelength
3+
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs)]
6+
7+
const CONST: u32 = 0;
8+
struct Test<const N: u32, const M: u32 = { CONST/* Must be a const and not a Literal */ }> where [(); N as usize]: , ([u32; N as usize]);
9+
10+
fn main() {
11+
let _: Test<1>;
12+
}

‎tests/crashes/112201.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ known-bug: #112201
2+
3+
pub fn compose(
4+
f1: impl FnOnce(f64) -> f64 + Clone,
5+
f2: impl FnOnce(f64) -> f64 + Clone,
6+
) -> impl FnOnce(f64) -> f64 + Clone {
7+
move |x| f1(f2(x))
8+
}
9+
10+
fn repeat_helper(
11+
f: impl FnOnce(f64) -> f64 + Clone,
12+
res: impl FnOnce(f64) -> f64 + Clone,
13+
times: usize,
14+
) -> impl FnOnce(f64) -> f64 + Clone {
15+
return res;
16+
repeat_helper(f.clone(), compose(f, res), times - 1)
17+
}
18+
19+
fn main() {}

‎tests/crashes/113280.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #113280
2+
3+
#![feature(dyn_star, pointer_like_trait)]
4+
#![allow(incomplete_features)]
5+
6+
use std::fmt::Debug;
7+
use std::marker::PointerLike;
8+
9+
fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a {
10+
f32::from_bits(0x1) as f64
11+
}
12+
13+
fn main() {
14+
println!("{:?}", make_dyn_star(Box::new(1i32)));
15+
}

‎tests/crashes/113379.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #113379
2+
3+
async fn f999() -> Vec<usize> {
4+
'b: {
5+
continue 'b;
6+
}
7+
}

‎tests/crashes/122909.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
2-
//@ known-bug: #12345
2+
//@ known-bug: #122909
33

44

55
use std::sync::{Arc, Context, Weak};

‎tests/crashes/34127.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ compile-flags: -g -Copt-level=0
2+
//@ known-bug: #34127
3+
4+
pub fn main() {
5+
let _a = [(); 1 << 63];
6+
}

‎tests/crashes/54888.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ known-bug: #54888
2+
3+
#![feature(unsize, coerce_unsized)]
4+
5+
use std::{
6+
ops::CoerceUnsized,
7+
marker::Unsize,
8+
};
9+
10+
#[repr(C)]
11+
struct Ptr<T: ?Sized>(Box<T>);
12+
13+
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
14+
where
15+
T: Unsize<U>,
16+
{}
17+
18+
19+
fn main() {
20+
let foo = Ptr(Box::new(5)) as Ptr<dyn std::any::Any>;
21+
}

‎tests/crashes/57276.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #57276
2+
3+
#![feature(arbitrary_self_types, dispatch_from_dyn)]
4+
5+
use std::ops::{Deref, DispatchFromDyn};
6+
7+
trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
8+
fn foo(self: T) -> dyn Trait<T>;
9+
}
10+
11+
fn main() {}

‎tests/crashes/74299.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ known-bug: #74299
2+
#![feature(specialization)]
3+
4+
trait X {
5+
type U;
6+
fn f(&self) -> Self::U {
7+
loop {}
8+
}
9+
}
10+
11+
impl<T> X for T {
12+
default type U = ();
13+
}
14+
15+
trait Y {
16+
fn g(&self) {}
17+
}
18+
19+
impl Y for <() as X>::U {}
20+
impl Y for <i32 as X>::U {}
21+
22+
fn main() {
23+
().f().g();
24+
}

‎tests/crashes/74451.rs‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//@ known-bug: #74451
2+
//@ compile-flags: -Copt-level=0
3+
4+
#![feature(specialization)]
5+
#![feature(unsize, coerce_unsized)]
6+
#![allow(incomplete_features)]
7+
#![crate_type = "lib"]
8+
9+
use std::ops::CoerceUnsized;
10+
11+
pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
12+
13+
pub trait Smartass {
14+
type Data;
15+
type Data2: CoerceUnsized<*const [u8]>;
16+
}
17+
18+
pub trait MaybeObjectSafe {}
19+
20+
impl MaybeObjectSafe for () {}
21+
22+
impl<T> Smartass for T {
23+
type Data = <Self as Smartass>::Data2;
24+
default type Data2 = *const [u8; 0];
25+
}
26+
27+
impl Smartass for () {
28+
type Data2 = *const [u8; 1];
29+
}
30+
31+
impl Smartass for dyn MaybeObjectSafe {
32+
type Data = *const [u8];
33+
type Data2 = *const [u8; 0];
34+
}
35+
36+
impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
37+
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
38+
{}
39+
40+
pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> {
41+
s // This shouldn't coerce
42+
}

‎tests/crashes/79409.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #79409
2+
3+
#![feature(extern_types)]
4+
#![feature(unsized_locals)]
5+
6+
extern {
7+
type Device;
8+
}
9+
10+
unsafe fn make_device() -> Box<Device> {
11+
Box::from_raw(0 as *mut _)
12+
}
13+
14+
fn main() {
15+
let d: Device = unsafe { *make_device() };
16+
}

‎tests/crashes/79590.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ known-bug: #79590
2+
3+
trait Database: Restriction<Inner = u32> {}
4+
5+
trait Restriction {
6+
type Inner;
7+
}
8+
9+
struct Test {}
10+
11+
impl Database for Test {}
12+
impl Restriction for Test {
13+
type Inner = u32;
14+
}
15+
16+
fn main() {
17+
let t = Test {};
18+
let x: &dyn Database<Inner = _> = &t;
19+
}

‎tests/crashes/87577.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ known-bug: #877577
2+
3+
#[derive(Debug)]
4+
struct S<#[cfg(feature = "alloc")] N: A<T>> {}

‎tests/crashes/88296.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #88296
2+
3+
#![feature(specialization)]
4+
5+
trait Foo {
6+
type Bar;
7+
}
8+
9+
impl<T> Foo for T {
10+
default type Bar = u32;
11+
}
12+
13+
impl Foo for i32 {
14+
type Bar = i32;
15+
}
16+
17+
extern "C" {
18+
#[allow(unused)]
19+
// OK as Foo::Bar is explicitly defined for i32
20+
static OK: <i32 as Foo>::Bar;
21+
22+
#[allow(unused)]
23+
// ICE in the improper_ctypes lint
24+
// as Foo::Bar is only default implemented for ()
25+
static ICE: <() as Foo>::Bar;
26+
}
27+
pub fn main() {}

‎tests/crashes/90110.rs‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//@ known-bug: #90110
2+
3+
use std::fs::File;
4+
use std::io::{BufReader, BufRead};
5+
use std::str::Split;
6+
use std::path::Path;
7+
8+
pub trait Parser<D>
9+
where dyn Parser<D>: Sized
10+
{
11+
fn new(split_header: Split<&str>) -> Self where Self: Sized;
12+
fn parse_line(&self, split_line: &Split<&str>) -> D;
13+
}
14+
15+
16+
pub struct CsvReader<D> {
17+
parser: Box<dyn Parser<D>>,
18+
19+
reader: BufReader<File>,
20+
buf: String, // Buffer we will read into. Avoids re-allocation on each line.
21+
path: String, // Record this so we can return more informative error messages.
22+
line: usize, // Same motivation for this.
23+
}
24+
25+
impl<D> CsvReader<D>
26+
where dyn Parser<D>: Sized
27+
{
28+
fn new<F>(path: &str, make_parser: F) -> CsvReader<D>
29+
where F: Fn(Split<char>) -> dyn Parser<D> {
30+
let file = match File::open(Path::new(path)) {
31+
Err(err) => panic!("Couldn't read {}: {}", path, err),
32+
Ok(file) => file,
33+
};
34+
35+
let mut reader = BufReader::new(file);
36+
37+
let mut buf = String::new();
38+
39+
let parser = Box::new(match reader.read_line(&mut buf) {
40+
Err(err) => panic!("Failed to read the header line from {}: {}", path, err),
41+
Ok(_) => {
42+
let split_header = buf.split(',');
43+
make_parser(split_header)
44+
},
45+
});
46+
47+
CsvReader {
48+
parser: parser,
49+
reader,
50+
buf,
51+
path: path.to_string(),
52+
line: 2,
53+
}
54+
}
55+
}
56+
57+
pub fn main() {}

‎tests/crashes/91985.rs‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//@ known-bug: #91985
2+
3+
#![feature(generic_associated_types)]
4+
5+
pub trait Trait1 {
6+
type Associated: Ord;
7+
}
8+
9+
pub trait Trait2 {
10+
type Associated: Clone;
11+
}
12+
13+
pub trait GatTrait {
14+
type Gat<T: Clone>;
15+
}
16+
17+
pub struct GatStruct;
18+
19+
impl GatTrait for GatStruct {
20+
type Gat<T: Clone> = Box<T>;
21+
}
22+
23+
pub struct OuterStruct<T1: Trait1, T2: Trait2> {
24+
inner: InnerStruct<T2, GatStruct>,
25+
t1: T1,
26+
}
27+
28+
pub struct InnerStruct<T: Trait2, G: GatTrait> {
29+
pub gat: G::Gat<T::Associated>,
30+
}
31+
32+
impl<T1, T2> OuterStruct<T1, T2>
33+
where
34+
T1: Trait1,
35+
T2: Trait2<Associated = T1::Associated>,
36+
{
37+
pub fn new() -> Self {
38+
todo!()
39+
}
40+
}
41+
42+
pub fn main() {}

‎tests/crashes/96304.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #96304
2+
3+
#![feature(asm_sym)]
4+
core::arch::global_asm!("/* {} */", sym<&'static ()>::clone);
5+
6+
pub fn main() {}

‎tests/crashes/97501.rs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: #97501
2+
3+
#![feature(core_intrinsics)]
4+
use std::intrinsics::wrapping_add;
5+
6+
#[derive(Clone, Copy)]
7+
struct WrapInt8 {
8+
value: u8
9+
}
10+
11+
impl std::ops::Add for WrapInt8 {
12+
type Output = WrapInt8;
13+
fn add(self, other: WrapInt8) -> WrapInt8 {
14+
wrapping_add(self, other)
15+
}
16+
}
17+
18+
fn main() {
19+
let p = WrapInt8 { value: 123 };
20+
let q = WrapInt8 { value: 234 };
21+
println!("{}", (p + q).value);
22+
}

‎tests/crashes/98322.rs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ known-bug: #98322
2+
3+
#![feature(generic_const_exprs)]
4+
5+
// Main function seems irrelevant
6+
fn main() {}
7+
8+
// Constant must be provided via an associated constant in a trait
9+
pub trait ConstTrait {
10+
const ASSOC_CONST: usize;
11+
}
12+
13+
// For some reason I find it's necessary to have an implementation of this trait that recurses
14+
pub trait OtherTrait
15+
{
16+
fn comm(self);
17+
}
18+
19+
// There must be a blanket impl here
20+
impl<T> OtherTrait for T where
21+
T: ConstTrait,
22+
[();T::ASSOC_CONST]: Sized,
23+
{
24+
fn comm(self) {
25+
todo!()
26+
}
27+
}
28+
29+
// The struct must be recursive
30+
pub struct RecursiveStruct(Box<RecursiveStruct>);
31+
32+
// This implementation must exist, and it must recurse into its child
33+
impl OtherTrait for RecursiveStruct {
34+
fn comm(self) {
35+
(self.0).comm();
36+
}
37+
}

0 commit comments

Comments
 (0)
Please sign in to comment.