Skip to content

Commit 35e86c2

Browse files
committed
Add more complete tests of possible rust-call cases
1 parent 7cece8e commit 35e86c2

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

compiler/rustc_typeck/src/check/check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ pub(super) fn check_fn<'a, 'tcx>(
104104
kind: hir::ImplItemKind::Fn(header, ..), ..
105105
}) => Some(header),
106106
Node::TraitItem(hir::TraitItem {
107-
kind: hir::TraitItemKind::Fn(header, .. ), ..
107+
kind: hir::TraitItemKind::Fn(header, ..),
108+
..
108109
}) => Some(header),
109110
// Closures are RustCall, but they tuple their arguments, so shouldn't be checked
110111
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => None,

src/test/ui/abi/issues/issue-22565-rust-call.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33
extern "rust-call" fn b(_i: i32) {}
44
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument that is a tuple
55

6+
trait Tr {
7+
extern "rust-call" fn a();
8+
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument
9+
10+
extern "rust-call" fn b() {}
11+
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument
12+
}
13+
14+
struct Foo;
15+
16+
impl Foo {
17+
extern "rust-call" fn bar() {}
18+
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument
19+
}
20+
21+
impl Tr for Foo {
22+
fn a() {}
23+
//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument
24+
}
25+
626
fn main () {
727
b(10);
28+
29+
Foo::bar();
30+
31+
<Foo as Tr>::a();
32+
<Foo as Tr>::b();
833
}

0 commit comments

Comments
 (0)