diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-08 23:15:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-08 23:15:12 +0100 |
| commit | 9041d1cec0e4ee566236307f11dd0a1ef4a17841 (patch) | |
| tree | a8020fc2e7769217375233448875c9c1b94da6bb /compiler | |
| parent | 4df6134f1ace9b29d44b035976801fd0d9981611 (diff) | |
| parent | e4cfe038adffb0cf5785d7c95f809364c6a39f5f (diff) | |
| download | rust-9041d1cec0e4ee566236307f11dd0a1ef4a17841.tar.gz rust-9041d1cec0e4ee566236307f11dd0a1ef4a17841.zip | |
Rollup merge of #118502 - Young-Flash:fix, r=compiler-errors
fix: correct the arg for 'suggest to use associated function syntax' diagnostic close https://github.com/rust-lang/rust/issues/118469
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/method/suggest.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 143454c71e1..b38a6ebd501 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1591,10 +1591,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let sig = self.tcx.fn_sig(assoc.def_id).instantiate_identity(); sig.inputs().skip_binder().get(0).and_then(|first| { - if first.peel_refs() == rcvr_ty.peel_refs() { - None - } else { + let impl_ty = self.tcx.type_of(*impl_did).instantiate_identity(); + // if the type of first arg is the same as the current impl type, we should take the first arg into assoc function + if first.peel_refs() == impl_ty { Some(first.ref_mutability().map_or("", |mutbl| mutbl.ref_prefix_str())) + } else { + None } }) } else { |
