mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
implement point_at_index_if_possible
This commit is contained in:
@@ -2649,17 +2649,7 @@ fn check_expr_index(
|
||||
// two-phase not needed because index_ty is never mutable
|
||||
self.demand_coerce(idx, idx_t, index_ty, None, AllowTwoPhase::No);
|
||||
self.select_obligations_where_possible(false, |errors| {
|
||||
for error in errors {
|
||||
match error.obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(predicate)
|
||||
if self.tcx.is_diagnostic_item(
|
||||
sym::SliceIndex,
|
||||
predicate.trait_ref.def_id,
|
||||
) => {}
|
||||
_ => continue,
|
||||
}
|
||||
error.obligation.cause.span = idx.span;
|
||||
}
|
||||
self.point_at_index_if_possible(errors, idx.span)
|
||||
});
|
||||
element_ty
|
||||
}
|
||||
@@ -2704,6 +2694,22 @@ fn check_expr_index(
|
||||
}
|
||||
}
|
||||
|
||||
fn point_at_index_if_possible(
|
||||
&self,
|
||||
errors: &mut Vec<traits::FulfillmentError<'tcx>>,
|
||||
span: Span,
|
||||
) {
|
||||
for error in errors {
|
||||
match error.obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(predicate)
|
||||
if self.tcx.is_diagnostic_item(sym::SliceIndex, predicate.trait_ref.def_id) => {
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
error.obligation.cause.span = span;
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expr_yield(
|
||||
&self,
|
||||
value: &'tcx hir::Expr<'tcx>,
|
||||
|
||||
Reference in New Issue
Block a user