Unify secondary_span and swap_secondary_and_primary
This commit is contained in:
parent
a0c2aba29a
commit
4886e9a134
@ -592,14 +592,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
|||||||
&cause,
|
&cause,
|
||||||
hir.get_if_local(impl_m.def_id)
|
hir.get_if_local(impl_m.def_id)
|
||||||
.and_then(|node| node.fn_decl())
|
.and_then(|node| node.fn_decl())
|
||||||
.map(|decl| (decl.output.span(), Cow::from("return type in trait"))),
|
.map(|decl| (decl.output.span(), Cow::from("return type in trait"), false)),
|
||||||
Some(infer::ValuePairs::Terms(ExpectedFound {
|
Some(infer::ValuePairs::Terms(ExpectedFound {
|
||||||
expected: trait_return_ty.into(),
|
expected: trait_return_ty.into(),
|
||||||
found: impl_return_ty.into(),
|
found: impl_return_ty.into(),
|
||||||
})),
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
return Err(diag.emit());
|
return Err(diag.emit());
|
||||||
}
|
}
|
||||||
@ -1018,14 +1017,13 @@ fn report_trait_method_mismatch<'tcx>(
|
|||||||
infcx.err_ctxt().note_type_err(
|
infcx.err_ctxt().note_type_err(
|
||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
trait_err_span.map(|sp| (sp, Cow::from("type in trait"))),
|
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
|
||||||
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
Some(infer::ValuePairs::PolySigs(ExpectedFound {
|
||||||
expected: ty::Binder::dummy(trait_sig),
|
expected: ty::Binder::dummy(trait_sig),
|
||||||
found: ty::Binder::dummy(impl_sig),
|
found: ty::Binder::dummy(impl_sig),
|
||||||
})),
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
diag.emit()
|
diag.emit()
|
||||||
@ -1825,14 +1823,13 @@ fn compare_const_predicate_entailment<'tcx>(
|
|||||||
infcx.err_ctxt().note_type_err(
|
infcx.err_ctxt().note_type_err(
|
||||||
&mut diag,
|
&mut diag,
|
||||||
&cause,
|
&cause,
|
||||||
trait_c_span.map(|span| (span, Cow::from("type in trait"))),
|
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
|
||||||
Some(infer::ValuePairs::Terms(ExpectedFound {
|
Some(infer::ValuePairs::Terms(ExpectedFound {
|
||||||
expected: trait_ty.into(),
|
expected: trait_ty.into(),
|
||||||
found: impl_ty.into(),
|
found: impl_ty.into(),
|
||||||
})),
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
return Err(diag.emit());
|
return Err(diag.emit());
|
||||||
};
|
};
|
||||||
|
@ -652,7 +652,6 @@ fn extract_span_for_error_reporting<'tcx>(
|
|||||||
})),
|
})),
|
||||||
err,
|
err,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
return Err(diag.emit());
|
return Err(diag.emit());
|
||||||
}
|
}
|
||||||
|
@ -1114,7 +1114,6 @@ enum SuggestionText {
|
|||||||
None,
|
None,
|
||||||
Some(trace.values),
|
Some(trace.values),
|
||||||
e,
|
e,
|
||||||
false,
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2302,7 +2302,6 @@ fn check_proc_macro(&self, hir_id: HirId, target: Target, kind: ProcMacroKind) {
|
|||||||
})),
|
})),
|
||||||
terr,
|
terr,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
diag.emit();
|
diag.emit();
|
||||||
self.abort.set(true);
|
self.abort.set(true);
|
||||||
|
@ -1127,18 +1127,14 @@ fn lifetime_display(lifetime: Region<'_>) -> String {
|
|||||||
/// the message in `secondary_span` as the primary label, and apply the message that would
|
/// the message in `secondary_span` as the primary label, and apply the message that would
|
||||||
/// otherwise be used for the primary label on the `secondary_span` `Span`. This applies on
|
/// otherwise be used for the primary label on the `secondary_span` `Span`. This applies on
|
||||||
/// E0271, like `tests/ui/issues/issue-39970.stderr`.
|
/// E0271, like `tests/ui/issues/issue-39970.stderr`.
|
||||||
#[instrument(
|
#[instrument(level = "debug", skip(self, diag, secondary_span, prefer_label))]
|
||||||
level = "debug",
|
|
||||||
skip(self, diag, secondary_span, swap_secondary_and_primary, prefer_label)
|
|
||||||
)]
|
|
||||||
pub fn note_type_err(
|
pub fn note_type_err(
|
||||||
&self,
|
&self,
|
||||||
diag: &mut Diag<'_>,
|
diag: &mut Diag<'_>,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
secondary_span: Option<(Span, Cow<'static, str>)>,
|
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
|
||||||
mut values: Option<ValuePairs<'tcx>>,
|
mut values: Option<ValuePairs<'tcx>>,
|
||||||
terr: TypeError<'tcx>,
|
terr: TypeError<'tcx>,
|
||||||
swap_secondary_and_primary: bool,
|
|
||||||
prefer_label: bool,
|
prefer_label: bool,
|
||||||
) {
|
) {
|
||||||
let span = cause.span();
|
let span = cause.span();
|
||||||
@ -1304,7 +1300,7 @@ enum Mismatch<'a> {
|
|||||||
diag.span_note(span, msg);
|
diag.span_note(span, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Some((sp, msg)) = secondary_span {
|
if let Some((secondary_span, secondary_msg, swap_secondary_and_primary)) = secondary_span {
|
||||||
if swap_secondary_and_primary {
|
if swap_secondary_and_primary {
|
||||||
let terr = if let Some(infer::ValuePairs::Terms(ExpectedFound {
|
let terr = if let Some(infer::ValuePairs::Terms(ExpectedFound {
|
||||||
expected, ..
|
expected, ..
|
||||||
@ -1314,11 +1310,11 @@ enum Mismatch<'a> {
|
|||||||
} else {
|
} else {
|
||||||
terr.to_string(self.tcx)
|
terr.to_string(self.tcx)
|
||||||
};
|
};
|
||||||
label_or_note(sp, terr);
|
label_or_note(secondary_span, terr);
|
||||||
label_or_note(span, msg);
|
label_or_note(span, secondary_msg);
|
||||||
} else {
|
} else {
|
||||||
label_or_note(span, terr.to_string(self.tcx));
|
label_or_note(span, terr.to_string(self.tcx));
|
||||||
label_or_note(sp, msg);
|
label_or_note(secondary_span, secondary_msg);
|
||||||
}
|
}
|
||||||
} else if let Some(values) = values
|
} else if let Some(values) = values
|
||||||
&& let Some((e, f)) = values.ty()
|
&& let Some((e, f)) = values.ty()
|
||||||
@ -1788,7 +1784,7 @@ pub fn report_and_explain_type_error(
|
|||||||
self.type_error_additional_suggestions(&trace, terr),
|
self.type_error_additional_suggestions(&trace, terr),
|
||||||
);
|
);
|
||||||
let mut diag = self.dcx().create_err(failure_code);
|
let mut diag = self.dcx().create_err(failure_code);
|
||||||
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false, false);
|
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false);
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,6 @@ pub fn report_selection_error(
|
|||||||
None,
|
None,
|
||||||
TypeError::Sorts(ty::error::ExpectedFound::new(true, expected_ty, ct_ty)),
|
TypeError::Sorts(ty::error::ExpectedFound::new(true, expected_ty, ct_ty)),
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
@ -1435,6 +1434,7 @@ pub(super) fn report_projection_error(
|
|||||||
cx.into_buffer()
|
cx.into_buffer()
|
||||||
}
|
}
|
||||||
))),
|
))),
|
||||||
|
true,
|
||||||
)),
|
)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
@ -1452,7 +1452,6 @@ pub(super) fn report_projection_error(
|
|||||||
))
|
))
|
||||||
}),
|
}),
|
||||||
err,
|
err,
|
||||||
true,
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
self.note_obligation_cause(&mut diag, obligation);
|
self.note_obligation_cause(&mut diag, obligation);
|
||||||
|
Loading…
Reference in New Issue
Block a user