8000 add comments · rust-lang/rust@c34d9e6 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c34d9e6

Browse files
committed
add comments 8000
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

Lines changed: 8 additions & 0 deletions
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)
0