Skip to content

Commit 2c49d0a

Browse files
authored
Rollup merge of rust-lang#71952 - JohnTitor:add-tests, r=Dylan-DPC
Add some regression tests Closes rust-lang#29988 Closes rust-lang#34979 Pick up two snippets that have been fixed from rust-lang#67945 (shouldn't be closed yet!)
2 parents 180c4fd + f22bc7b commit 2c49d0a

7 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: -C no-prepopulate-passes
2+
// Regression test for #29988
3+
4+
#[repr(C)]
5+
struct S {
6+
f1: i32,
7+
f2: i32,
8+
f3: i32,
9+
}
10+
11+
extern {
12+
fn foo(s: S);
13+
}
14+
15+
fn main() {
16+
let s = S { f1: 1, f2: 2, f3: 3 };
17+
unsafe {
18+
// CHECK: load { i64, i32 }, { i64, i32 }* {{.*}}, align 4
19+
// CHECK: call void @foo({ i64, i32 } {{.*}})
20+
foo(s);
21+
}
22+
}

src/test/ui/enum/issue-67945-1.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enum Bug<S> {
2+
Var = {
3+
let x: S = 0; //~ ERROR: mismatched types
4+
0
5+
},
6+
}
7+
8+
fn main() {}

src/test/ui/enum/issue-67945-1.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-67945-1.rs:3:20
3+
|
4+
LL | enum Bug<S> {
5+
| - this type parameter
6+
LL | Var = {
7+
LL | let x: S = 0;
8+
| - ^ expected type parameter `S`, found integer
9+
| |
10+
| expected due to this
11+
|
12+
= note: expected type parameter `S`
13+
found type `{integer}`
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/enum/issue-67945-2.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(type_ascription)]
2+
3+
enum Bug<S> {
4+
Var = 0: S,
5+
//~^ ERROR: mismatched types
6+
//~| ERROR: mismatched types
7+
}
8+
9+
fn main() {}

src/test/ui/enum/issue-67945-2.stderr

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-67945-2.rs:4:11
3+
|
4+
LL | enum Bug<S> {
5+
| - this type parameter
6+
LL | Var = 0: S,
7+
| ^ expected type parameter `S`, found integer
8+
|
9+
= note: expected type parameter `S`
10+
found type `{integer}`
11+
12+
error[E0308]: mismatched types
13+
--> $DIR/issue-67945-2.rs:4:11
14+
|
15+
LL | enum Bug<S> {
16+
| - this type parameter
17+
LL | Var = 0: S,
18+
| ^^^^ expected `isize`, found type parameter `S`
19+
|
20+
= note: expected type `isize`
21+
found type parameter `S`
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/lifetimes/issue-34979.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo {}
2+
impl<'a, T> Foo for &'a T {}
3+
4+
struct Ctx<'a>(&'a ())
5+
where
6+
&'a (): Foo, //~ ERROR: type annotations needed
7+
&'static (): Foo;
8+
9+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/issue-34979.rs:6:13
3+
|
4+
LL | trait Foo {}
5+
| --------- required by this bound in `Foo`
6+
...
7+
LL | &'a (): Foo,
8+
| ^^^ cannot infer type for reference `&'a ()`
9+
|
10+
= note: cannot satisfy `&'a (): Foo`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)