Skip to content

Commit

Permalink
review comment: change span argument
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Oct 27, 2024
1 parent f43a874 commit d2e4f44
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
);
let hir = tcx.hir();
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
hir.get_if_local(impl_m.def_id)
Expand All @@ -630,6 +629,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
}))),
terr,
false,
None,
);
return Err(diag.emit());
}
Expand Down Expand Up @@ -1048,7 +1048,6 @@ fn report_trait_method_mismatch<'tcx>(

cause.span = impl_err_span;
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
Expand All @@ -1058,6 +1057,7 @@ fn report_trait_method_mismatch<'tcx>(
}))),
terr,
false,
None,
);

diag.emit()
Expand Down Expand Up @@ -1846,7 +1846,6 @@ fn compare_const_predicate_entailment<'tcx>(
});

infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
Expand All @@ -1856,6 +1855,7 @@ fn compare_const_predicate_entailment<'tcx>(
}))),
terr,
false,
None,
);
return Err(diag.emit());
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ pub fn check_function_signature<'tcx>(
let failure_code = cause.as_failure_code_diag(err, cause.span, vec![]);
let mut diag = tcx.dcx().create_err(failure_code);
err_ctxt.note_type_err(
cause.span,
&mut diag,
&cause,
None,
Expand All @@ -653,6 +652,7 @@ pub fn check_function_signature<'tcx>(
}))),
err,
false,
None,
);
return Err(diag.emit());
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let trace = mk_trace(provided_span, (formal_ty, expected_ty), provided_ty);
if let Some(e) = error {
self.err_ctxt().note_type_err(
trace.cause.span,
&mut err,
&trace.cause,
None,
Some(self.param_env.and(trace.values)),
e,
true,
None,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}

infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
None,
Expand All @@ -2302,6 +2301,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}))),
terr,
false,
None,
);
diag.emit();
self.abort.set(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,14 +1141,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
#[instrument(level = "debug", skip(self, diag, secondary_span, prefer_label))]
pub fn note_type_err(
&self,
span: Span,
diag: &mut Diag<'_>,
cause: &ObligationCause<'tcx>,
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
mut values: Option<ty::ParamEnvAnd<'tcx, ValuePairs<'tcx>>>,
terr: TypeError<'tcx>,
prefer_label: bool,
override_span: Option<Span>,
) {
// We use `override_span` when we want the error to point at a `Span` other than
// `cause.span`. This is used in E0271, when a closure is passed in where the return type
// isn't what was expected. We want to point at the closure's return type (or expression),
// instead of the expression where the closure is passed as call argument.
let span = override_span.unwrap_or(cause.span);
// For some types of errors, expected-found does not make
// sense, so just ignore the values we were given.
if let TypeError::CyclicTy(_) = terr {
Expand Down Expand Up @@ -1799,13 +1804,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
);
let mut diag = self.dcx().create_err(failure_code);
self.note_type_err(
span,
&mut diag,
&trace.cause,
None,
Some(param_env.and(trace.values)),
terr,
false,
None,
);
diag
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
);

self.note_type_err(
span,
&mut diag,
&obligation.cause,
None,
None,
TypeError::Sorts(ty::error::ExpectedFound::new(true, expected_ty, ct_ty)),
false,
None,
);
diag
}
Expand Down Expand Up @@ -1471,7 +1471,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
})();

self.note_type_err(
span,
&mut diag,
&obligation.cause,
secondary_span,
Expand All @@ -1484,6 +1483,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}),
err,
false,
Some(span),
);
self.note_obligation_cause(&mut diag, obligation);
diag.emit()
Expand Down

0 comments on commit d2e4f44

Please sign in to comment.