about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorGavin Gray <gavinleroy6@gmail.com>2023-11-14 13:55:59 +0100
committerGavin Gray <gavinleroy6@gmail.com>2023-11-14 13:55:59 +0100
commitcaae1e08ecfa67f5ab3ccf8b7edf20c252c2268a (patch)
treeb5ff5a477af8787055de42d44700e07e78bde188 /compiler
parent60d99ab8837e973c0df5fe518a2ed136c8ac0f20 (diff)
downloadrust-caae1e08ecfa67f5ab3ccf8b7edf20c252c2268a.tar.gz
rust-caae1e08ecfa67f5ab3ccf8b7edf20c252c2268a.zip
Add guard checking for associated types before computing intercrate ambiguity of projections. Bless test with more specific notes on the ambiguity cause.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/coherence.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs
index dcf5fd86929..87cc8b09c0e 100644
--- a/compiler/rustc_trait_selection/src/traits/coherence.rs
+++ b/compiler/rustc_trait_selection/src/traits/coherence.rs
@@ -20,6 +20,7 @@ use crate::traits::{
 };
 use rustc_data_structures::fx::FxIndexSet;
 use rustc_errors::Diagnostic;
+use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
 use rustc_infer::traits::{util, TraitEngine};
@@ -1002,7 +1003,12 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a> {
         // and then prove the resulting predicate as a nested goal.
         let trait_ref = match predicate.kind().no_bound_vars() {
             Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr))) => tr.trait_ref,
-            Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj))) => {
+            Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)))
+                if matches!(
+                    infcx.tcx.def_kind(proj.projection_ty.def_id),
+                    DefKind::AssocTy | DefKind::AssocConst
+                ) =>
+            {
                 proj.projection_ty.trait_ref(infcx.tcx)
             }
             _ => return ControlFlow::Continue(()),