Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, r=estebank
Better method call error messages Rebase/continuation of #71827 ~Based on #92360~ ~Based on #93118~ There's a decent description in #71827 that I won't copy here (for now at least) In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now. I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given. ~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~ r? `@estebank` as the original reviewer of #71827
This commit is contained in:
commit
07bb916d44
180 changed files with 10446 additions and 3067 deletions
|
@ -1448,6 +1448,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
mut values: Option<ValuePairs<'tcx>>,
|
||||
terr: &TypeError<'tcx>,
|
||||
swap_secondary_and_primary: bool,
|
||||
force_label: bool,
|
||||
) {
|
||||
let span = cause.span(self.tcx);
|
||||
debug!("note_type_err cause={:?} values={:?}, terr={:?}", cause, values, terr);
|
||||
|
@ -1623,7 +1624,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
TypeError::ObjectUnsafeCoercion(_) => {}
|
||||
_ => {
|
||||
let mut label_or_note = |span: Span, msg: &str| {
|
||||
if &[span] == diag.span.primary_spans() {
|
||||
if force_label || &[span] == diag.span.primary_spans() {
|
||||
diag.span_label(span, msg);
|
||||
} else {
|
||||
diag.span_note(span, msg);
|
||||
|
@ -2171,7 +2172,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
struct_span_err!(self.tcx.sess, span, E0644, "{}", failure_str)
|
||||
}
|
||||
};
|
||||
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false);
|
||||
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false, false);
|
||||
diag
|
||||
}
|
||||
|
||||
|
@ -2765,7 +2766,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
enum FailureCode {
|
||||
pub enum FailureCode {
|
||||
Error0038(DefId),
|
||||
Error0317(&'static str),
|
||||
Error0580(&'static str),
|
||||
|
@ -2773,7 +2774,7 @@ enum FailureCode {
|
|||
Error0644(&'static str),
|
||||
}
|
||||
|
||||
trait ObligationCauseExt<'tcx> {
|
||||
pub trait ObligationCauseExt<'tcx> {
|
||||
fn as_failure_code(&self, terr: &TypeError<'tcx>) -> FailureCode;
|
||||
fn as_requirement_str(&self) -> &'static str;
|
||||
}
|
||||
|
|
|
@ -385,8 +385,8 @@ impl<'tcx> ValuePairs<'tcx> {
|
|||
/// See the `error_reporting` module for more details.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TypeTrace<'tcx> {
|
||||
cause: ObligationCause<'tcx>,
|
||||
values: ValuePairs<'tcx>,
|
||||
pub cause: ObligationCause<'tcx>,
|
||||
pub values: ValuePairs<'tcx>,
|
||||
}
|
||||
|
||||
/// The origin of a `r1 <= r2` constraint.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue