1
Fork 0

Rollup merge of #132243 - compiler-errors:no-span, r=jieyouxu

Remove `ObligationCause::span()` method

I think it's an incredibly confusing footgun to expose both `obligation_cause.span` and `obligation_cause.span()`. Especially because `ObligationCause::span()` (the method) seems to just be hacking around a single quirk in the way we set up obligation causes for match arms.

First commit removes the need for that hack, with only one diagnostic span changing (but IMO not really getting worse -- I'd argue that it was already confusing).
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-10-28 13:36:21 +08:00 committed by GitHub
commit 3e3feac7c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 38 additions and 46 deletions

View file

@ -611,7 +611,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
Err(terr) => {
let mut diag = struct_span_code_err!(
tcx.dcx(),
cause.span(),
cause.span,
E0053,
"method `{}` has an incompatible return type for trait",
trait_m.name
@ -1169,7 +1169,7 @@ fn extract_spans_for_error_reporting<'tcx>(
TypeError::ArgumentMutability(i) | TypeError::ArgumentSorts(ExpectedFound { .. }, i) => {
(impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i)))
}
_ => (cause.span(), tcx.hir().span_if_local(trait_m.def_id)),
_ => (cause.span, tcx.hir().span_if_local(trait_m.def_id)),
}
}

View file

@ -612,7 +612,7 @@ pub fn check_function_signature<'tcx>(
match err {
TypeError::ArgumentMutability(i)
| TypeError::ArgumentSorts(ExpectedFound { .. }, i) => args.nth(i).unwrap(),
_ => cause.span(),
_ => cause.span,
}
}