Skip to content

Commit 8244d7a

Browse files
committed
yikes
1 parent de19f2b commit 8244d7a

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

compiler/rustc_next_trait_solver/src/coherence.rs

+13-38
Original file line numberDiff line numberDiff line change
@@ -358,47 +358,22 @@ where
358358
// * Otherwise it may normalize to any non-type-generic type
359359
// be it local or non-local.
360360
ty::Alias(kind, _) => {
361-
if ty.has_type_flags(
362-
ty::TypeFlags::HAS_TY_PLACEHOLDER
363-
| ty::TypeFlags::HAS_TY_BOUND
364-
| ty::TypeFlags::HAS_TY_INFER,
365-
) {
366-
match self.in_crate {
367-
InCrate::Local { mode } => match kind {
368-
ty::Projection => {
369-
if let OrphanCheckMode::Compat = mode {
370-
ControlFlow::Continue(())
371-
} else {
372-
self.found_uncovered_ty_param(ty)
373-
}
361+
match self.in_crate {
362+
InCrate::Local { mode } => match kind {
363+
ty::Projection => {
364+
if let OrphanCheckMode::Compat = mode {
365+
ControlFlow::Continue(())
366+
} else {
367+
self.found_uncovered_ty_param(ty)
374368
}
375-
_ => self.found_uncovered_ty_param(ty),
376-
},
377-
InCrate::Remote => {
378-
// The inference variable might be unified with a local
379-
// type in that remote crate.
380-
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
381369
}
370+
_ => self.found_uncovered_ty_param(ty),
371+
},
372+
InCrate::Remote => {
373+
// The inference variable might be unified with a local
374+
// type in that remote crate.
375+
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
382376
}
383-
} else {
384-
// Regarding *opaque types* specifically, we choose to treat them as non-local,
385-
// even those that appear within the same crate. This seems somewhat surprising
386-
// at first, but makes sense when you consider that opaque types are supposed
387-
// to hide the underlying type *within the same crate*. When an opaque type is
388-
// used from outside the module where it is declared, it should be impossible to
389-
// observe anything about it other than the traits that it implements.
390-
//
391-
// The alternative would be to look at the underlying type to determine whether
392-
// or not the opaque type itself should be considered local.
393-
//
394-
// However, this could make it a breaking change to switch the underlying hidden
395-
// type from a local type to a remote type. This would violate the rule that
396-
// opaque types should be completely opaque apart from the traits that they
397-
// implement, so we don't use this behavior.
398-
// Addendum: Moreover, revealing the underlying type is likely to cause cycle
399-
// errors as we rely on coherence / the specialization graph during typeck.
400-
401-
self.found_non_local_ty(ty)
402377
}
403378
}
404379

0 commit comments

Comments
 (0)