Skip to content

Commit dde5d95

Browse files
Add test wf-check-c-variadics.rs
1 parent e6e0676 commit dde5d95

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// In `hir_wf_check.rs` we try to find the innermost type that is not well formed,
2+
// so we can give the user an accurate span.
3+
// This test checks if this happens correctly for c-variadics.
4+
5+
struct NeedsCopy<T: Copy>(T);
6+
7+
unsafe extern "C" {
8+
fn f(x: i32, ...) -> Option<NeedsCopy<String>>;
9+
//~^ ERROR the trait bound `String: Copy` is not satisfied
10+
}
11+
12+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: the trait bound `String: Copy` is not satisfied
2+
--> $DIR/wf-check-c-variadics.rs:8:33
3+
|
4+
LL | fn f(x: i32, ...) -> Option<NeedsCopy<String>>;
5+
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
6+
|
7+
note: required by a bound in `NeedsCopy`
8+
--> $DIR/wf-check-c-variadics.rs:5:21
9+
|
10+
LL | struct NeedsCopy<T: Copy>(T);
11+
| ^^^^ required by this bound in `NeedsCopy`
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)