Suppress "erroneous constant used" for constants tainted by errors

When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.
This commit is contained in:
Tomasz Miąsko 2023-05-15 00:00:00 +00:00
parent 2913ad6db0
commit 67f455afe1
33 changed files with 76 additions and 248 deletions

View file

@ -169,14 +169,14 @@ impl<'tcx> ConstEvalErr<'tcx> {
// See <https://github.com/rust-lang/rust/pull/63152>.
let mut err = struct_error(tcx, &self.error.to_string());
self.decorate(&mut err, decorate);
ErrorHandled::Reported(err.emit())
ErrorHandled::Reported(err.emit().into())
}
_ => {
// Report as hard error.
let mut err = struct_error(tcx, message);
err.span_label(self.span, self.error.to_string());
self.decorate(&mut err, decorate);
ErrorHandled::Reported(err.emit())
ErrorHandled::Reported(err.emit().into())
}
}
}