Skip to content

Commit

Permalink
Avoid a Ty::new_misc_error when an ErrorGuaranteed is available
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 12, 2024
1 parent 9065889 commit 6299071
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
}

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

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Err(guar) => Err(guar),
};
if let Err(guar) = has_error {
let err_inputs = self.err_args(args_no_rcvr.len());
let err_inputs = self.err_args(args_no_rcvr.len(), guar);

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

0 comments on commit 6299071

Please sign in to comment.