Skip to content

Commit 1707d71

Browse files
Fix incorrect suggestion when calling an associated type with a type anchor
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
1 parent c38569d commit 1707d71

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
724724
{
725725
let def_path = tcx.def_path_str(adt_def.did());
726726
err.span_suggestion(
727-
ty.span.to(item_ident.span),
727+
sugg_span,
728728
format!("to construct a value of type `{}`, use the explicit path", def_path),
729729
def_path,
730730
Applicability::MachineApplicable,

tests/ui/associated-types/associated-type-suggestion-142473.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl Trait for () {
1212
type Assoc = T;
1313

1414
fn f() {
15-
<T();
15+
T();
1616
//~^ ERROR no associated item named `Assoc` found for unit type `()` in the current scope
1717
}
1818
}

tests/ui/associated-types/associated-type-suggestion-142473.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | <Self>::Assoc();
77
help: to construct a value of type `T`, use the explicit path
88
|
99
LL - <Self>::Assoc();
10-
LL + <T();
10+
LL + T();
1111
|
1212

1313
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)