@@ -1338,33 +1338,13 @@ fn impl_trait_ref(
13381338 . map ( |ast_trait_ref| {
13391339 let selfty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13401340
1341- if let Some ( ErrorGuaranteed { .. } ) = check_impl_constness (
1341+ check_impl_constness (
13421342 tcx,
13431343 tcx. is_const_trait_impl_raw ( def_id. to_def_id ( ) ) ,
13441344 ast_trait_ref,
1345- ) {
1346- // TODO this is wrong
1347- // we have a const impl, but for a trait without `#[const_trait]`, so
1348- // without the host param. If we continue with the HIR trait ref, we get
1349- // ICEs for generic arg count mismatch. We do a little HIR editing to
1350- // make astconv happy.
1351- let mut path_segments = ast_trait_ref. path . segments . to_vec ( ) ;
1352- let last_segment = path_segments. len ( ) - 1 ;
1353- let mut args = * path_segments[ last_segment] . args ( ) ;
1354- let last_arg = args. args . len ( ) - 1 ;
1355- assert ! ( matches!( args. args[ last_arg] , hir:: GenericArg :: Const ( anon_const) if anon_const. is_desugared_from_effects) ) ;
1356- args. args = & args. args [ ..args. args . len ( ) - 1 ] ;
1357- path_segments[ last_segment] . args = Some ( tcx. hir_arena . alloc ( args) ) ;
1358- let path = hir:: Path {
1359- span : ast_trait_ref. path . span ,
1360- res : ast_trait_ref. path . res ,
1361- segments : tcx. hir_arena . alloc_slice ( & path_segments) ,
1362- } ;
1363- let trait_ref = tcx. hir_arena . alloc ( hir:: TraitRef { path : tcx. hir_arena . alloc ( path) , hir_ref_id : ast_trait_ref. hir_ref_id } ) ;
1364- icx. astconv ( ) . instantiate_mono_trait_ref ( trait_ref, selfty)
1365- } else {
1366- icx. astconv ( ) . instantiate_mono_trait_ref ( ast_trait_ref, selfty)
1367- }
1345+ ) ;
1346+
1347+ icx. astconv ( ) . instantiate_mono_trait_ref ( ast_trait_ref, selfty)
13681348 } )
13691349 . map ( ty:: EarlyBinder :: bind)
13701350}
0 commit comments