Rollup merge of #79675 - CraftSpider:79669, r=estebank
Make sure rust-call errors occur correctly for traits Fixes #79669 Adds trait method resolution to the error, and adds UI tests to ensure it doesn't happen again. Opening as draft because I'm getting weird link errors from unrelated code on my machine, and want to see what CI thinks.
This commit is contained in:
commit
0afd72e313
3 changed files with 47 additions and 1 deletions
|
@ -103,6 +103,10 @@ pub(super) fn check_fn<'a, 'tcx>(
|
|||
Node::ImplItem(hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Fn(header, ..), ..
|
||||
}) => Some(header),
|
||||
Node::TraitItem(hir::TraitItem {
|
||||
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,
|
||||
node => bug!("Item being checked wasn't a function/closure: {:?}", node),
|
||||
|
|
|
@ -3,6 +3,30 @@
|
|||
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();
|
||||
|
||||
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 {
|
||||
extern "rust-call" 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();
|
||||
}
|
||||
|
|
|
@ -4,5 +4,23 @@ error: A function with the "rust-call" ABI must take a single non-self argument
|
|||
LL | extern "rust-call" fn b(_i: i32) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
|
||||
--> $DIR/issue-22565-rust-call.rs:9:5
|
||||
|
|
||||
LL | extern "rust-call" fn b() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
|
||||
--> $DIR/issue-22565-rust-call.rs:16:5
|
||||
|
|
||||
LL | extern "rust-call" fn bar() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple
|
||||
--> $DIR/issue-22565-rust-call.rs:21:5
|
||||
|
|
||||
LL | extern "rust-call" fn a() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue