Skip to content

Commit 6299071

Browse files
committed
Avoid a Ty::new_misc_error when an ErrorGuaranteed is available
1 parent 9065889 commit 6299071

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
660660
})
661661
}
662662

663-
pub(crate) fn err_args(&self, len: usize) -> Vec<Ty<'tcx>> {
664-
let ty_error = Ty::new_misc_error(self.tcx);
663+
pub(crate) fn err_args(&self, len: usize, guar: ErrorGuaranteed) -> Vec<Ty<'tcx>> {
664+
let ty_error = Ty::new_error(self.tcx, guar);
665665
vec![ty_error; len]
666666
}
667667

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
123123
Err(guar) => Err(guar),
124124
};
125125
if let Err(guar) = has_error {
126-
let err_inputs = self.err_args(args_no_rcvr.len());
126+
let err_inputs = self.err_args(args_no_rcvr.len(), guar);
127127

128128
let err_inputs = match tuple_arguments {
129129
DontTupleArguments => err_inputs,
@@ -237,15 +237,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
237237
_ => {
238238
// Otherwise, there's a mismatch, so clear out what we're expecting, and set
239239
// our input types to err_args so we don't blow up the error messages
240-
struct_span_code_err!(
240+
let guar = struct_span_code_err!(
241241
tcx.dcx(),
242242
call_span,
243243
E0059,
244244
"cannot use call notation; the first type parameter \
245245
for the function trait is neither a tuple nor unit"
246246
)
247247
.emit();
248-
(self.err_args(provided_args.len()), None)
248+
(self.err_args(provided_args.len(), guar), None)
249249
}
250250
}
251251
} else {

0 commit comments

Comments
 (0)