Skip to content

Commit c0b081c

Browse files
Add test obligation-span.rs
1 parent 2a61ba8 commit c0b081c

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This test checks that the span of c-variadics is handled correctly when creating obligations
2+
3+
struct NeedsCopy<T: Copy>(T);
4+
5+
extern "C" {
6+
fn f1(...) -> NeedsCopy<String>;
7+
//~^ ERROR the trait bound `String: Copy` is not satisfied
8+
fn f2(x: i32, ...) -> NeedsCopy<String>;
9+
//~^ ERROR the trait bound `String: Copy` is not satisfied
10+
fn f3(..., x: i32) -> NeedsCopy<String>;
11+
//~^ ERROR `...` must be the last argument of a C-variadic function
12+
//~| ERROR the trait bound `String: Copy` is not satisfied
13+
}
14+
15+
fn main() { }
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
error: `...` must be the last argument of a C-variadic function
2+
--> $DIR/obligation-span.rs:10:11
3+
|
4+
LL | fn f3(..., x: i32) -> NeedsCopy<String>;
5+
| ^^^
6+
7+
error[E0277]: the trait bound `String: Copy` is not satisfied
8+
--> $DIR/obligation-span.rs:6:19
9+
|
10+
LL | fn f1(...) -> NeedsCopy<String>;
11+
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
12+
|
13+
note: required by a bound in `NeedsCopy`
14+
--> $DIR/obligation-span.rs:3:21
15+
|
16+
LL | struct NeedsCopy<T: Copy>(T);
17+
| ^^^^ required by this bound in `NeedsCopy`
18+
19+
error[E0277]: the trait bound `String: Copy` is not satisfied
20+
--> $DIR/obligation-span.rs:8:27
21+
|
22+
LL | fn f2(x: i32, ...) -> NeedsCopy<String>;
23+
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
24+
|
25+
note: required by a bound in `NeedsCopy`
26+
--> $DIR/obligation-span.rs:3:21
27+
|
28+
LL | struct NeedsCopy<T: Copy>(T);
29+
| ^^^^ required by this bound in `NeedsCopy`
30+
31+
error[E0277]: the trait bound `String: Copy` is not satisfied
32+
--> $DIR/obligation-span.rs:10:27
33+
|
34+
LL | fn f3(..., x: i32) -> NeedsCopy<String>;
35+
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
36+
|
37+
note: required by a bound in `NeedsCopy`
38+
--> $DIR/obligation-span.rs:3:21
39+
|
40+
LL | struct NeedsCopy<T: Copy>(T);
41+
| ^^^^ required by this bound in `NeedsCopy`
42+
43+
error: aborting due to 4 previous errors
44+
45+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)