diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-07 05:11:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-07 05:11:56 +0200 |
| commit | fb0117000a89053ab8e964eb5fee1d73a5d019c1 (patch) | |
| tree | 90fcc4cbeeeda9c7b47d74073270a8b995b77037 | |
| parent | 037f568f179e91661a3ddf4e31d5c0d797e3b098 (diff) | |
| parent | 6bb60ef6f2392b029c0bb5e2042f0f5743ae6763 (diff) | |
| download | rust-fb0117000a89053ab8e964eb5fee1d73a5d019c1.tar.gz rust-fb0117000a89053ab8e964eb5fee1d73a5d019c1.zip | |
Rollup merge of #62455 - zackmdavis:name_trait_for_ambiguous_assoc_item, r=petrochenkov
name the trait in ambiguous-associated-items fully qualified suggestion We have the trait at this point, so we can name it in the error message, rather than using "Trait" as a (potentially confusing) placeholder. Thanks to Yuki "@JohnTitor" Okushi for pointing out where to look (in the same file) for a closely related issue for ambiguous associated types (as opposed to items; that was #59225, except that one won't be quite as easy to resolve, because we actually don't have the trait `DefId` at that point). r? @petrochenkov
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7154b7958b9..d314228a232 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1709,8 +1709,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { err.span_suggestion( span, "use fully-qualified syntax", - format!("<{} as {}>::{}", qself_ty, "Trait", assoc_ident), - Applicability::HasPlaceholders, + format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident), + Applicability::MachineApplicable, ).emit(); } diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr index f0dd689934f..ef025e0e146 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr @@ -2,7 +2,7 @@ error: ambiguous associated item --> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15 | LL | fn f() -> Self::V { 0 } - | ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V` + | ^^^^^^^ help: use fully-qualified syntax: `<E as Tr>::V` | = note: #[deny(ambiguous_associated_items)] on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! |
