Skip to content

Commit 480f718

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

File tree

7 files changed

+107
-0
lines changed

7 files changed

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

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)