Skip to content

Commit c34d9e6

Browse files
committed
add comments
1 parent d64c90d commit c34d9e6

File tree

1 file changed

+8
-0
lines changed
  • src/librustc_typeck/check

1 file changed

+8
-0
lines changed

src/librustc_typeck/check/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -3372,6 +3372,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33723372
vec![self.tcx.types.err; len]
33733373
}
33743374

3375+
/// Given a vec of evaluated `FullfillmentError`s and an `fn` call argument expressions, we
3376+
/// walk the resolved types for each argument to see if any of the `FullfillmentError`s
3377+
/// reference a type argument. If they do, and there's only *one* argument that does, we point
3378+
/// at the corresponding argument's expression span instead of the `fn` call path span.
33753379
fn point_at_arg_instead_of_call_if_possible(
33763380
&self,
33773381
errors: &mut Vec<traits::FulfillmentError<'_>>,
@@ -3384,9 +3388,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33843388
// the `?` operator.
33853389
for error in errors {
33863390
if let ty::Predicate::Trait(predicate) = error.obligation.predicate {
3391+
// Collect the argument position for all arguments that could have caused this
3392+
// `FullfillmentError`.
33873393
let mut referenced_in = final_arg_types.iter()
33883394
.flat_map(|(i, ty)| {
33893395
let ty = self.resolve_vars_if_possible(ty);
3396+
// We walk the argument type because the argument's type could have
3397+
// been `Option<T>`, but the `FullfillmentError` references `T`.
33903398
ty.walk()
33913399
.filter(|&ty| ty == predicate.skip_binder().self_ty())
33923400
.map(move |_| *i)

0 commit comments

Comments
 (0)