@@ -1291,24 +1291,26 @@ pub fn suggest_impl_trait<'tcx>(
1291
1291
None
1292
1292
}
1293
1293
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 < ' _ > {
1295
1295
let icx = ItemCtxt :: new ( tcx, def_id) ;
1296
1296
let item = tcx. hir_expect_item ( def_id) ;
1297
1297
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 ( ) ;
1300
1303
1301
- check_impl_constness ( tcx, impl_. constness , ast_trait_ref) ;
1304
+ check_impl_constness ( tcx, impl_. constness , ast_trait_ref) ;
1302
1305
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) ;
1304
1307
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
+ }
1312
1314
}
1313
1315
1314
1316
fn check_impl_constness (
0 commit comments