@@ -1291,24 +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- impl_. of_trait . as_ref ( ) . map ( |ast_trait_ref| {
1299- let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1298+ let ast_trait_ref = impl_
1299+ . of_trait
1300+ . as_ref ( )
1301+ . unwrap_or_else ( || panic ! ( "expected impl trait, found inherent impl on {def_id:?}" ) ) ;
1302+ let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13001303
1301- check_impl_constness ( tcx, impl_. constness , ast_trait_ref) ;
1304+ check_impl_constness ( tcx, impl_. constness , ast_trait_ref) ;
13021305
1303- let trait_ref = icx. lowerer ( ) . lower_impl_trait_ref ( ast_trait_ref, selfty) ;
1306+ let trait_ref = icx. lowerer ( ) . lower_impl_trait_ref ( ast_trait_ref, selfty) ;
13041307
1305- ty:: ImplTraitHeader {
1306- trait_ref : ty:: EarlyBinder :: bind ( trait_ref) ,
1307- safety : impl_. safety ,
1308- polarity : polarity_of_impl ( tcx, def_id, impl_, item. span ) ,
1309- constness : impl_. constness ,
1310- }
1311- } )
1308+ ty:: ImplTraitHeader {
1309+ trait_ref : ty:: EarlyBinder :: bind ( trait_ref) ,
1310+ safety : impl_. safety ,
1311+ polarity : polarity_of_impl ( tcx, def_id, impl_, item. span ) ,
1312+ constness : impl_. constness ,
1313+ }
13121314}
13131315
13141316fn check_impl_constness (
0 commit comments