]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 8 Feb 2023 06:13:29 +0000 (07:13 +0100)
committerGitHub <noreply@github.com>
Wed, 8 Feb 2023 06:13:29 +0000 (07:13 +0100)
Remove astconv usage in diagnostic

Fixes #107775

Location of the test sucks, I know, but I needed to put it somewhere :sweat:
The issue here is that the root cause of the issue has nothing to do with what's being tested, so I couldn't really give it a better name. Oh well.

1  2 
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

index 05e976534126b0ca92781196c678623cf5c88dd2,4e3c20196945a87ba47c2945654bab3807c6440e..eaad57d8c2e9f1088ab839e4e266d62b302ea743
@@@ -1336,16 -1336,17 +1336,17 @@@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> 
                  hir::Path { segments: [segment], .. },
              ))
              | hir::ExprKind::Path(QPath::TypeRelative(ty, segment)) => {
-                 let self_ty = self.astconv().ast_ty_to_ty(ty);
-                 if let Ok(pick) = self.probe_for_name(
-                     Mode::Path,
-                     Ident::new(capitalized_name, segment.ident.span),
-                     Some(expected_ty),
-                     IsSuggestion(true),
-                     self_ty,
-                     expr.hir_id,
-                     ProbeScope::TraitsInScope,
-                 ) {
+                 if let Some(self_ty) = self.typeck_results.borrow().node_type_opt(ty.hir_id)
+                     && let Ok(pick) = self.probe_for_name(
+                         Mode::Path,
+                         Ident::new(capitalized_name, segment.ident.span),
+                         Some(expected_ty),
+                         IsSuggestion(true),
+                         self_ty,
+                         expr.hir_id,
+                         ProbeScope::TraitsInScope,
+                     )
+                 {
                      (pick.item, segment)
                  } else {
                      return false;
                      generics,
                      diag,
                      vec![(param.name.as_str(), "Clone", Some(clone_trait_did))].into_iter(),
 +                    None,
                  );
              } else {
                  self.suggest_derive(diag, &[(trait_ref.to_predicate(self.tcx), None, None)]);