@@ -1291,28 +1291,26 @@ pub fn suggest_impl_trait<'tcx>(
12911291 None
12921292}
12931293
1294- fn impl_trait_header ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Option < ty:: ImplTraitHeader < ' _ > > {
1294+ fn impl_trait_header ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> ty:: ImplTraitHeader < ' _ > {
12951295 let icx = ItemCtxt :: new ( tcx, def_id) ;
12961296 let item = tcx. hir_expect_item ( def_id) ;
12971297 let impl_ = item. expect_impl ( ) ;
1298+ let of_trait = impl_
1299+ . of_trait
1300+ . unwrap_or_else ( || panic ! ( "expected impl trait, found inherent impl on {def_id:?}" ) ) ;
1301+ let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
12981302 let is_rustc_reservation = tcx. has_attr ( def_id, sym:: rustc_reservation_impl) ;
1299- if is_rustc_reservation && impl_. of_trait . is_none ( ) {
1300- tcx. dcx ( ) . span_err ( item. span , "reservation impls can't be inherent" ) ;
1301- }
1302- impl_. of_trait . map ( |of_trait| {
1303- let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13041303
1305- check_impl_constness ( tcx, of_trait. constness , & of_trait. trait_ref ) ;
1304+ check_impl_constness ( tcx, of_trait. constness , & of_trait. trait_ref ) ;
13061305
1307- let trait_ref = icx. lowerer ( ) . lower_impl_trait_ref ( & of_trait. trait_ref , selfty) ;
1306+ let trait_ref = icx. lowerer ( ) . lower_impl_trait_ref ( & of_trait. trait_ref , selfty) ;
13081307
1309- ty:: ImplTraitHeader {
1310- trait_ref : ty:: EarlyBinder :: bind ( trait_ref) ,
1311- safety : of_trait. safety ,
1312- polarity : polarity_of_impl ( tcx, of_trait, is_rustc_reservation) ,
1313- constness : of_trait. constness ,
1314- }
1315- } )
1308+ ty:: ImplTraitHeader {
1309+ trait_ref : ty:: EarlyBinder :: bind ( trait_ref) ,
1310+ safety : of_trait. safety ,
1311+ polarity : polarity_of_impl ( tcx, of_trait, is_rustc_reservation) ,
1312+ constness : of_trait. constness ,
1313+ }
13161314}
13171315
13181316fn check_impl_constness (
0 commit comments