Skip to content

Commit 57ff589

Browse files
committed
Add broken MIR regression tests
1 parent 193b748 commit 57ff589

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
pub trait Foo {
7+
fn foo(&self);
8+
}
9+
10+
11+
impl<T, const N: usize> Foo for [T; N] {
12+
fn foo(&self) {
13+
let _ = &self;
14+
}
15+
}
16+
17+
fn main() {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/broken-mir-1.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
use std::fmt::Debug;
5+
6+
#[derive(Debug)]
7+
struct S<T: Debug, const N: usize>([T; N]); //~ ERROR `[T; N]` doesn't implement `std::fmt::Debug`
8+
9+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/broken-mir-2.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0277]: `[T; N]` doesn't implement `std::fmt::Debug`
8+
--> $DIR/broken-mir-2.rs:7:36
9+
|
10+
LL | struct S<T: Debug, const N: usize>([T; N]);
11+
| ^^^^^^ `[T; N]` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
12+
|
13+
= help: the trait `std::fmt::Debug` is not implemented for `[T; N]`
14+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; N]`
15+
= note: required for the cast to the object type `dyn std::fmt::Debug`
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)