@@ -26,7 +26,7 @@ use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
2626use rustc_middle:: ty:: { GenericArgs , GenericArgsRef } ;
2727use rustc_session:: lint:: builtin:: COHERENCE_LEAK_CHECK ;
2828use rustc_session:: lint:: builtin:: ORDER_DEPENDENT_TRAIT_OBJECTS ;
29- use rustc_span:: { ErrorGuaranteed , Span , DUMMY_SP } ;
29+ use rustc_span:: { sym , ErrorGuaranteed , Span , DUMMY_SP } ;
3030
3131use super :: util;
3232use super :: SelectionContext ;
@@ -144,8 +144,22 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
144144 // taking advantage of upstream ones.
145145 let features = tcx. features ( ) ;
146146 let specialization_enabled = features. specialization || features. min_specialization ;
147- if !specialization_enabled && ( impl1_def_id. is_local ( ) || impl2_def_id. is_local ( ) ) {
148- return false ;
147+ if !specialization_enabled && impl1_def_id. is_local ( ) {
148+ let span = tcx. def_span ( impl1_def_id) ;
149+ if !span. allows_unstable ( sym:: specialization)
150+ && !span. allows_unstable ( sym:: min_specialization)
151+ {
152+ return false ;
153+ }
154+ }
155+
156+ if !specialization_enabled && impl2_def_id. is_local ( ) {
157+ let span = tcx. def_span ( impl2_def_id) ;
158+ if !span. allows_unstable ( sym:: specialization)
159+ && !span. allows_unstable ( sym:: min_specialization)
160+ {
161+ return false ;
162+ }
149163 }
150164
151165 // We determine whether there's a subset relationship by:
0 commit comments