@@ -1127,34 +1127,32 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1127
1127
}
1128
1128
// Treat negative impls as unimplemented, and reservation impls as ambiguity.
1129
1129
if let ImplCandidate ( def_id) = candidate {
1130
- match tcx. impl_polarity ( def_id) {
1131
- ty:: ImplPolarity :: Negative if !self . allow_negative_impls => {
1132
- return Err ( Unimplemented ) ;
1133
- }
1134
- ty:: ImplPolarity :: Reservation => {
1135
- if let Some ( intercrate_ambiguity_clauses) =
1136
- & mut self . intercrate_ambiguity_causes
1137
- {
1138
- let attrs = tcx. get_attrs ( def_id) ;
1139
- let attr = tcx. sess . find_by_name ( & attrs, sym:: rustc_reservation_impl) ;
1140
- let value = attr. and_then ( |a| a. value_str ( ) ) ;
1141
- if let Some ( value) = value {
1142
- debug ! (
1143
- "filter_impls: \
1130
+ if let ty:: ImplPolarity :: Reservation = tcx. impl_polarity ( def_id) {
1131
+ if let Some ( intercrate_ambiguity_clauses) = & mut self . intercrate_ambiguity_causes {
1132
+ let attrs = tcx. get_attrs ( def_id) ;
1133
+ let attr = tcx. sess . find_by_name ( & attrs, sym:: rustc_reservation_impl) ;
1134
+ let value = attr. and_then ( |a| a. value_str ( ) ) ;
1135
+ if let Some ( value) = value {
1136
+ debug ! (
1137
+ "filter_impls: \
1144
1138
reservation impl ambiguity on {:?}",
1145
- def_id
1146
- ) ;
1147
- intercrate_ambiguity_clauses. push (
1148
- IntercrateAmbiguityCause :: ReservationImpl {
1149
- message : value. to_string ( ) ,
1150
- } ,
1151
- ) ;
1152
- }
1139
+ def_id
1140
+ ) ;
1141
+ intercrate_ambiguity_clauses. push (
1142
+ IntercrateAmbiguityCause :: ReservationImpl {
1143
+ message : value. to_string ( ) ,
1144
+ } ,
1145
+ ) ;
1153
1146
}
1154
- return Ok ( None ) ;
1155
1147
}
1156
- _ => { }
1157
- } ;
1148
+ return Ok ( None ) ;
1149
+ }
1150
+
1151
+ if !self . allow_negative_impls {
1152
+ if obligation. predicate . skip_binder ( ) . polarity != tcx. impl_polarity ( def_id) {
1153
+ return Err ( Unimplemented ) ;
1154
+ }
1155
+ }
1158
1156
}
1159
1157
Ok ( Some ( candidate) )
1160
1158
}
0 commit comments