Skip to content

Commit 42180ca

Browse files
committed
Specialization can switch to DefineOpaqueTypes::Yes without having an effect.
The reason is that in specialization graph computation we use `DefiningAnchor::Error`, so there's no difference anyway. And in the other use cases, we * already errored in the specialization_graph computation, or * already errored in coherence, or * are comparing opaque types with inference variables already, or * there are no opaque types involved
1 parent 318b372 commit 42180ca

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/specialize

1 file changed

+6
-1
lines changed

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,12 @@ fn fulfill_implication<'tcx>(
246246
// do the impls unify? If not, no specialization.
247247
let Ok(InferOk { obligations: more_obligations, .. }) = infcx
248248
.at(&ObligationCause::dummy(), param_env)
249-
.eq(DefineOpaqueTypes::No, source_trait, target_trait)
249+
// Ok to use `Yes`, as all the generic params are already replaced by inference variables,
250+
// which will match the opaque type no matter if it is defining or not.
251+
// Any concrete type that would match the opaque would already be handled by coherence rules,
252+
// and thus either be ok to match here and already have errored, or it won't match, in which
253+
// case there is no issue anyway.
254+
.eq(DefineOpaqueTypes::Yes, source_trait, target_trait)
250255
else {
251256
debug!("fulfill_implication: {:?} does not unify with {:?}", source_trait, target_trait);
252257
return Err(());

0 commit comments

Comments
 (0)