@@ -1521,45 +1521,19 @@ fn impl_trait_header(
1521
1521
let icx = ItemCtxt :: new ( tcx, def_id) ;
1522
1522
let item = tcx. hir ( ) . expect_item ( def_id) ;
1523
1523
let impl_ = item. expect_impl ( ) ;
1524
- impl_
1525
- . of_trait
1526
- . as_ref ( )
1527
- . map ( |ast_trait_ref| {
1528
- let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1524
+ impl_. of_trait . as_ref ( ) . map ( |ast_trait_ref| {
1525
+ let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1529
1526
1530
- let trait_ref = if let Some ( ErrorGuaranteed { .. } ) = check_impl_constness (
1531
- tcx,
1532
- tcx. is_const_trait_impl_raw ( def_id. to_def_id ( ) ) ,
1533
- ast_trait_ref,
1534
- ) {
1535
- // TODO this is wrong
1536
- // we have a const impl, but for a trait without `#[const_trait]`, so
1537
- // without the host param. If we continue with the HIR trait ref, we get
1538
- // ICEs for generic arg count mismatch. We do a little HIR editing to
1539
- // make astconv happy.
1540
- let mut path_segments = ast_trait_ref. path . segments . to_vec ( ) ;
1541
- let last_segment = path_segments. len ( ) - 1 ;
1542
- let mut args = * path_segments[ last_segment] . args ( ) ;
1543
- let last_arg = args. args . len ( ) - 1 ;
1544
- assert ! ( matches!( args. args[ last_arg] , hir:: GenericArg :: Const ( anon_const) if anon_const. is_desugared_from_effects) ) ;
1545
- args. args = & args. args [ ..args. args . len ( ) - 1 ] ;
1546
- path_segments[ last_segment] . args = Some ( tcx. hir_arena . alloc ( args) ) ;
1547
- let path = hir:: Path {
1548
- span : ast_trait_ref. path . span ,
1549
- res : ast_trait_ref. path . res ,
1550
- segments : tcx. hir_arena . alloc_slice ( & path_segments) ,
1551
- } ;
1552
- let trait_ref = tcx. hir_arena . alloc ( hir:: TraitRef { path : tcx. hir_arena . alloc ( path) , hir_ref_id : ast_trait_ref. hir_ref_id } ) ;
1553
- icx. astconv ( ) . instantiate_mono_trait_ref ( trait_ref, selfty)
1554
- } else {
1555
- icx. astconv ( ) . instantiate_mono_trait_ref ( ast_trait_ref, selfty)
1556
- } ;
1557
- ty:: EarlyBinder :: bind ( ty:: ImplTraitHeader {
1558
- trait_ref,
1559
- unsafety : impl_. unsafety ,
1560
- polarity : polarity_of_impl ( tcx, def_id, impl_, item. span )
1561
- } )
1527
+ check_impl_constness ( tcx, tcx. is_const_trait_impl_raw ( def_id. to_def_id ( ) ) , ast_trait_ref) ;
1528
+
1529
+ let trait_ref = icx. astconv ( ) . instantiate_mono_trait_ref ( ast_trait_ref, selfty) ;
1530
+
1531
+ ty:: EarlyBinder :: bind ( ty:: ImplTraitHeader {
1532
+ trait_ref,
1533
+ unsafety : impl_. unsafety ,
1534
+ polarity : polarity_of_impl ( tcx, def_id, impl_, item. span ) ,
1562
1535
} )
1536
+ } )
1563
1537
}
1564
1538
1565
1539
fn check_impl_constness (
0 commit comments