Fix incorrect suggestion when calling an associated type with a type anchor

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
Jonathan Brouwer 2025-06-14 00:08:28 +02:00
parent c9995d2492
commit 1d036f408e
No known key found for this signature in database
GPG key ID: 13619B051B673C52
3 changed files with 3 additions and 3 deletions

View file

@ -724,7 +724,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let def_path = tcx.def_path_str(adt_def.did());
err.span_suggestion(
ty.span.to(item_ident.span),
sugg_span,
format!("to construct a value of type `{}`, use the explicit path", def_path),
def_path,
Applicability::MachineApplicable,

View file

@ -14,7 +14,7 @@ impl Trait for () {
type Assoc = T;
fn f() {
<T();
T();
//~^ ERROR no associated item named `Assoc` found for unit type `()` in the current scope
}
}

View file

@ -7,7 +7,7 @@ LL | <Self>::Assoc();
help: to construct a value of type `T`, use the explicit path
|
LL - <Self>::Assoc();
LL + <T();
LL + T();
|
error: aborting due to 1 previous error