diff options
| author | Rune Tynan <runetynan@gmail.com> | 2020-12-03 15:53:52 -0500 |
|---|---|---|
| committer | Rune Tynan <runetynan@gmail.com> | 2020-12-03 16:45:45 -0500 |
| commit | 35e86c2ab52603bbb5e5561bbab1e7e62c668d9d (patch) | |
| tree | e06d7c615aec57a980cf8416ca47d63a71606493 | |
| parent | 7cece8eca3fa42f93c53acfc1d376077025126f2 (diff) | |
| download | rust-35e86c2ab52603bbb5e5561bbab1e7e62c668d9d.tar.gz rust-35e86c2ab52603bbb5e5561bbab1e7e62c668d9d.zip | |
Add more complete tests of possible rust-call cases
| -rw-r--r-- | compiler/rustc_typeck/src/check/check.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/abi/issues/issue-22565-rust-call.rs | 25 |
2 files changed, 27 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index a4b21e96f05..676386ccf2e 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -104,7 +104,8 @@ pub(super) fn check_fn<'a, 'tcx>( kind: hir::ImplItemKind::Fn(header, ..), .. }) => Some(header), Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Fn(header, .. ), .. + kind: hir::TraitItemKind::Fn(header, ..), + .. }) => Some(header), // Closures are RustCall, but they tuple their arguments, so shouldn't be checked Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => None, diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.rs b/src/test/ui/abi/issues/issue-22565-rust-call.rs index 055d959b46e..f0740185da0 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.rs +++ b/src/test/ui/abi/issues/issue-22565-rust-call.rs @@ -3,6 +3,31 @@ extern "rust-call" fn b(_i: i32) {} //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument that is a tuple +trait Tr { + extern "rust-call" fn a(); + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument + + extern "rust-call" fn b() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + +struct Foo; + +impl Foo { + extern "rust-call" fn bar() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + +impl Tr for Foo { + fn a() {} + //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument +} + fn main () { b(10); + + Foo::bar(); + + <Foo as Tr>::a(); + <Foo as Tr>::b(); } |
