diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-12-19 11:23:57 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-12-24 22:25:45 -0800 |
| commit | 93fb219579b3c012dbef7594b676f62070cd666e (patch) | |
| tree | eca7d83099fab7c06d37c99eac3f8f3871b83eb1 | |
| parent | 245f62eb8a298892618a9d90327663fe932d493a (diff) | |
| download | rust-93fb219579b3c012dbef7594b676f62070cd666e.tar.gz rust-93fb219579b3c012dbef7594b676f62070cd666e.zip | |
Fix suggestion span for typo in associated type name
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/associated-types/associated-types-path-1.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0220.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-23595-2.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-39211.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-59029-1.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/span/type-binding.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/not_well_formed.stderr | 4 |
8 files changed, 22 insertions, 18 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 291a8baaf26..8f6940cc0ce 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1995,6 +1995,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) where I: Iterator<Item = ty::PolyTraitRef<'tcx>>, { + // The fallback span is needed because `assoc_name` might be an `Fn()`'s `Output` without a + // valid span, so we point at the whole path segment instead. + let span = if assoc_name.span != DUMMY_SP { assoc_name.span } else { span }; let mut err = struct_span_err!( self.tcx().sess, span, @@ -2012,11 +2015,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) .collect(); - if let Some(suggested_name) = - find_best_match_for_name(all_candidate_names.iter(), &assoc_name.as_str(), None) - { + if let (Some(suggested_name), true) = ( + find_best_match_for_name(all_candidate_names.iter(), &assoc_name.as_str(), None), + assoc_name.span != DUMMY_SP, + ) { err.span_suggestion( - span, + assoc_name.span, "there is an associated type with a similar name", suggested_name.to_string(), Applicability::MaybeIncorrect, diff --git a/src/test/ui/associated-types/associated-types-path-1.stderr b/src/test/ui/associated-types/associated-types-path-1.stderr index b7856e20afa..60db7749082 100644 --- a/src/test/ui/associated-types/associated-types-path-1.stderr +++ b/src/test/ui/associated-types/associated-types-path-1.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `A` not found for `T` - --> $DIR/associated-types-path-1.rs:10:23 + --> $DIR/associated-types-path-1.rs:10:26 | LL | pub fn f1<T>(a: T, x: T::A) {} - | ^^^^ associated type `A` not found + | ^ associated type `A` not found error[E0221]: ambiguous associated type `A` in bounds of `T` --> $DIR/associated-types-path-1.rs:11:34 diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr index 73e66ceb845..4fa83d8bf6e 100644 --- a/src/test/ui/error-codes/E0220.stderr +++ b/src/test/ui/error-codes/E0220.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `F` not found for `Trait` - --> $DIR/E0220.rs:5:16 + --> $DIR/E0220.rs:5:22 | LL | type Foo = dyn Trait<F=i32>; - | ^^^^^^^^^^^^ associated type `F` not found + | ^ associated type `F` not found error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified --> $DIR/E0220.rs:5:16 diff --git a/src/test/ui/issues/issue-23595-2.stderr b/src/test/ui/issues/issue-23595-2.stderr index f1004db0b09..dded673f6ee 100644 --- a/src/test/ui/issues/issue-23595-2.stderr +++ b/src/test/ui/issues/issue-23595-2.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `anything_here_kills_it` not found for `Self` - --> $DIR/issue-23595-2.rs:6:16 + --> $DIR/issue-23595-2.rs:6:22 | LL | type B = C<Self::anything_here_kills_it>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `anything_here_kills_it` not found + | ^^^^^^^^^^^^^^^^^^^^^^ associated type `anything_here_kills_it` not found error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39211.stderr b/src/test/ui/issues/issue-39211.stderr index ea850ea57d5..c14c663e5a1 100644 --- a/src/test/ui/issues/issue-39211.stderr +++ b/src/test/ui/issues/issue-39211.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Row` not found for `M` - --> $DIR/issue-39211.rs:11:17 + --> $DIR/issue-39211.rs:11:20 | LL | let a = [3; M::Row::DIM]; - | ^^^^^^^^^^^ associated type `Row` not found + | ^^^ associated type `Row` not found error: aborting due to previous error diff --git a/src/test/ui/issues/issue-59029-1.stderr b/src/test/ui/issues/issue-59029-1.stderr index ed1d98c40d1..fb1de9759c5 100644 --- a/src/test/ui/issues/issue-59029-1.stderr +++ b/src/test/ui/issues/issue-59029-1.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Res` not found for `Self` - --> $DIR/issue-59029-1.rs:5:46 + --> $DIR/issue-59029-1.rs:5:52 | LL | trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>; - | ^^^^^^^^^ associated type `Res` not found + | ^^^ associated type `Res` not found error: aborting due to previous error diff --git a/src/test/ui/span/type-binding.stderr b/src/test/ui/span/type-binding.stderr index 5b64fe18892..f6989933553 100644 --- a/src/test/ui/span/type-binding.stderr +++ b/src/test/ui/span/type-binding.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Trget` not found for `std::ops::Deref` - --> $DIR/type-binding.rs:6:14 + --> $DIR/type-binding.rs:6:20 | LL | fn homura<T: Deref<Trget = i32>>(_: T) {} - | ^^^^^^^^^^^ help: there is an associated type with a similar name: `Target` + | ^^^^^ help: there is an associated type with a similar name: `Target` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/not_well_formed.stderr b/src/test/ui/type-alias-impl-trait/not_well_formed.stderr index d374d6d33ee..c2b6f7eae9f 100644 --- a/src/test/ui/type-alias-impl-trait/not_well_formed.stderr +++ b/src/test/ui/type-alias-impl-trait/not_well_formed.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Assoc` not found for `V` - --> $DIR/not_well_formed.rs:10:26 + --> $DIR/not_well_formed.rs:10:29 | LL | type Foo<V> = impl Trait<V::Assoc>; - | ^^^^^^^^ associated type `Assoc` not found + | ^^^^^ associated type `Assoc` not found error: aborting due to previous error |
