Skip to content

Commit b40f11c

Browse files
committed
Migrate 'rust-call incorrect arguments' diagnostic
1 parent 9edeb19 commit b40f11c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

compiler/rustc_hir_typeck/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ hir_typeck_return_stmt_outside_of_fn_body =
9090
.encl_body_label = the {$statement_kind} is part of this body...
9191
.encl_fn_label = ...not the enclosing function body
9292
93+
hir_typeck_rustcall_incorrect_args =
94+
functions with the "rust-call" ABI must take a single non-self tuple argument
95+
9396
hir_typeck_struct_expr_non_exhaustive =
9497
cannot create non-exhaustive {$what} using struct expression
9598

compiler/rustc_hir_typeck/src/callee.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
382382
// to let us test the trait evaluation system.
383383
// Untranslatable diagnostics are okay for rustc internals
384384
#[allow(rustc::untranslatable_diagnostic)]
385-
#[allow(rustc::diagnostic_outside_of_impl)]
385+
#[allow(rustc::diagnostic_outside_of_impl)]
386386
if self.tcx.has_attr(def_id, sym::rustc_evaluate_where_clauses) {
387387
let predicates = self.tcx.predicates_of(def_id);
388388
let predicates = predicates.instantiate(self.tcx, args);
@@ -474,10 +474,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
474474
);
475475
self.require_type_is_sized(ty, sp, traits::RustCall);
476476
} else {
477-
self.tcx.sess.span_err(
478-
sp,
479-
"functions with the \"rust-call\" ABI must take a single non-self tuple argument",
480-
);
477+
self.tcx.sess.emit_err(errors::RustCallIncorrectArgs { span: sp });
481478
}
482479
}
483480

compiler/rustc_hir_typeck/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ impl IntoDiagnosticArg for ReturnLikeStatementKind {
5454
}
5555
}
5656

57+
#[derive(Diagnostic)]
58+
#[diag(hir_typeck_rustcall_incorrect_args)]
59+
pub struct RustCallIncorrectArgs {
60+
#[primary_span]
61+
pub span: Span,
62+
}
63+
5764
#[derive(Diagnostic)]
5865
#[diag(hir_typeck_yield_expr_outside_of_generator, code = "E0627")]
5966
pub struct YieldExprOutsideOfGenerator {

0 commit comments

Comments
 (0)