Rollup merge of #98869 - compiler-errors:stop_guessing_head_span, r=cjgillot
Remove some usages of `guess_head_span` No need to pass things through `guess_head_span` if they already point to the head span. Only major change is that we point to the head span of `enum`s on some errors now, which I prefer. r? `@cjgillot`
This commit is contained in:
commit
e0e6f1d1cb
35 changed files with 162 additions and 223 deletions
|
@ -714,10 +714,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {
|
||||
span_bug!(
|
||||
self.cause.span(self.infcx.tcx),
|
||||
"generic_const_exprs: unreachable `const_equate`"
|
||||
);
|
||||
span_bug!(self.cause.span(), "generic_const_exprs: unreachable `const_equate`");
|
||||
}
|
||||
|
||||
fn normalization() -> NormalizationStrategy {
|
||||
|
|
|
@ -1435,7 +1435,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
swap_secondary_and_primary: bool,
|
||||
force_label: bool,
|
||||
) {
|
||||
let span = cause.span(self.tcx);
|
||||
let span = cause.span();
|
||||
|
||||
// For some types of errors, expected-found does not make
|
||||
// sense, so just ignore the values we were given.
|
||||
|
@ -2085,7 +2085,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
|
||||
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
|
||||
|
||||
let span = trace.cause.span(self.tcx);
|
||||
let span = trace.cause.span();
|
||||
let failure_code = trace.cause.as_failure_code(terr);
|
||||
let mut diag = match failure_code {
|
||||
FailureCode::Error0038(did) => {
|
||||
|
|
|
@ -204,7 +204,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
|||
expected_substs: SubstsRef<'tcx>,
|
||||
actual_substs: SubstsRef<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let span = cause.span(self.tcx());
|
||||
let span = cause.span();
|
||||
let msg = format!(
|
||||
"implementation of `{}` is not general enough",
|
||||
self.tcx().def_path_str(trait_def_id),
|
||||
|
|
|
@ -18,20 +18,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
trait_item_def_id: DefId,
|
||||
requirement: &dyn fmt::Display,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let msg = "impl has stricter requirements than trait";
|
||||
let sp = self.tcx.sess.source_map().guess_head_span(error_span);
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
error_span,
|
||||
E0276,
|
||||
"impl has stricter requirements than trait"
|
||||
);
|
||||
|
||||
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
|
||||
|
||||
if trait_item_def_id.is_local() {
|
||||
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
||||
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
|
||||
err.span_label(
|
||||
self.tcx.def_span(trait_item_def_id),
|
||||
format!("definition of `{}` from trait", item_name),
|
||||
);
|
||||
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
||||
}
|
||||
|
||||
err.span_label(sp, format!("impl has extra requirement {}", requirement));
|
||||
err.span_label(error_span, format!("impl has extra requirement {}", requirement));
|
||||
|
||||
err
|
||||
}
|
||||
|
@ -48,7 +47,6 @@ pub fn report_object_safety_error<'tcx>(
|
|||
hir::Node::Item(item) => Some(item.ident.span),
|
||||
_ => None,
|
||||
});
|
||||
let span = tcx.sess.source_map().guess_head_span(span);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue