Skip to content

Commit fb01170

Browse files
authored
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
2 parents 037f568 + 6bb60ef commit fb01170

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/librustc_typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
17091709
err.span_suggestion(
17101710
span,
17111711
"use fully-qualified syntax",
1712-
format!("<{} as {}>::{}", qself_ty, "Trait", assoc_ident),
1713-
Applicability::HasPlaceholders,
1712+
format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
1713+
Applicability::MachineApplicable,
17141714
).emit();
17151715
}
17161716

src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: ambiguous associated item
22
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
33
|
44
LL | fn f() -> Self::V { 0 }
5-
| ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
5+
| ^^^^^^^ help: use fully-qualified syntax: `<E as Tr>::V`
66
|
77
= note: #[deny(ambiguous_associated_items)] on by default
88
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

0 commit comments

Comments
 (0)