forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that the ABI of the instance we are inlining is correct
- Loading branch information
1 parent
899c895
commit 9789e88
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// compile-flags: -Zpolymorphize=on -Zinline-mir=yes -Zmir-opt-level=0 | ||
|
||
#![feature(fn_traits, unboxed_closures)] | ||
struct Foo<T>(T); | ||
|
||
impl<T: Copy> Fn<()> for Foo<T> { | ||
extern "C" fn call(&self, _: ()) -> T { | ||
//~^ ERROR method `call` has an incompatible type for trait | ||
match *self { | ||
Foo(t) => t, | ||
} | ||
} | ||
} | ||
|
||
impl<T: Copy> FnMut<()> for Foo<T> { | ||
extern "rust-call" fn call_mut(&mut self, _: ()) -> T { | ||
self.call(()) | ||
} | ||
} | ||
|
||
impl<T: Copy> FnOnce<()> for Foo<T> { | ||
type Output = T; | ||
|
||
extern "rust-call" fn call_once(self, _: ()) -> T { | ||
self.call(()) | ||
} | ||
} | ||
|
||
fn main() { | ||
let t: u8 = 1; | ||
println!("{}", Foo(t)()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0053]: method `call` has an incompatible type for trait | ||
--> $DIR/inline-wrong-abi.rs:7:5 | ||
| | ||
LL | extern "C" fn call(&self, _: ()) -> T { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "C" fn | ||
| | ||
= note: expected signature `extern "rust-call" fn(&Foo<_>, ()) -> _` | ||
found signature `extern "C" fn(&Foo<_>, ()) -> _` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0053`. |