@@ -739,34 +739,6 @@ fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bo
739
739
740
740
ty:: Adt ( def, _) => def_id_is_local ( def. did ( ) , in_crate) ,
741
741
ty:: Foreign ( did) => def_id_is_local ( did, in_crate) ,
742
- ty:: Opaque ( ..) => {
743
- // This merits some explanation.
744
- // Normally, opaque types are not involved when performing
745
- // coherence checking, since it is illegal to directly
746
- // implement a trait on an opaque type. However, we might
747
- // end up looking at an opaque type during coherence checking
748
- // if an opaque type gets used within another type (e.g. as
749
- // a type parameter). This requires us to decide whether or
750
- // not an opaque type should be considered 'local' or not.
751
- //
752
- // We choose to treat all opaque types as non-local, even
753
- // those that appear within the same crate. This seems
754
- // somewhat surprising at first, but makes sense when
755
- // you consider that opaque types are supposed to hide
756
- // the underlying type *within the same crate*. When an
757
- // opaque type is used from outside the module
758
- // where it is declared, it should be impossible to observe
759
- // anything about it other than the traits that it implements.
760
- //
761
- // The alternative would be to look at the underlying type
762
- // to determine whether or not the opaque type itself should
763
- // be considered local. However, this could make it a breaking change
764
- // to switch the underlying ('defining') type from a local type
765
- // to a remote type. This would violate the rule that opaque
766
- // types should be completely opaque apart from the traits
767
- // that they implement, so we don't use this behavior.
768
- false
769
- }
770
742
771
743
ty:: Dynamic ( ref tt, ..) => {
772
744
if let Some ( principal) = tt. principal ( ) {
@@ -786,7 +758,7 @@ fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bo
786
758
//
787
759
// See `test/ui/coherence/coherence-with-closure.rs` for an example where this
788
760
// could happens.
789
- ty:: Closure ( ..) | ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
761
+ ty:: Opaque ( .. ) | ty :: Closure ( ..) | ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
790
762
tcx. sess . delay_span_bug (
791
763
DUMMY_SP ,
792
764
format ! ( "ty_is_local invoked on closure or generator: {:?}" , ty) ,
0 commit comments