Add guard checking for associated types before computing intercrate ambiguity of projections. Bless test with more specific notes on the ambiguity cause.
This commit is contained in:
parent
60d99ab883
commit
caae1e08ec
@ -20,6 +20,7 @@
|
|||||||
};
|
};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::Diagnostic;
|
use rustc_errors::Diagnostic;
|
||||||
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||||
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
|
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
|
||||||
use rustc_infer::traits::{util, TraitEngine};
|
use rustc_infer::traits::{util, TraitEngine};
|
||||||
@ -1002,7 +1003,12 @@ fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) -> ControlFlow<Self::Brea
|
|||||||
// and then prove the resulting predicate as a nested goal.
|
// and then prove the resulting predicate as a nested goal.
|
||||||
let trait_ref = match predicate.kind().no_bound_vars() {
|
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::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)
|
proj.projection_ty.trait_ref(infcx.tcx)
|
||||||
}
|
}
|
||||||
_ => return ControlFlow::Continue(()),
|
_ => return ControlFlow::Continue(()),
|
||||||
|
@ -6,6 +6,8 @@ LL | impl<T: Send> AnotherTrait for T {}
|
|||||||
...
|
...
|
||||||
LL | impl AnotherTrait for D<OpaqueType> {
|
LL | impl AnotherTrait for D<OpaqueType> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||||
|
|
|
||||||
|
= note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user