@@ -22,6 +22,7 @@ pub mod generics;
2222use std:: assert_matches:: assert_matches;
2323use std:: slice;
2424
25+ use rustc_ast:: LitKind ;
2526use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
2627use rustc_errors:: codes:: * ;
2728use rustc_errors:: {
@@ -2391,6 +2392,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23912392 hir:: ConstArgKind :: Anon ( anon) => self . lower_const_arg_anon ( anon) ,
23922393 hir:: ConstArgKind :: Infer ( ( ) ) => self . ct_infer ( None , const_arg. span ) ,
23932394 hir:: ConstArgKind :: Error ( e) => ty:: Const :: new_error ( tcx, e) ,
2395+ hir:: ConstArgKind :: Literal ( kind) if let FeedConstTy :: WithTy ( anon_const_type) = feed => {
2396+ self . lower_const_arg_literal ( & kind, anon_const_type, const_arg. span )
2397+ }
2398+ hir:: ConstArgKind :: Literal ( ..) => {
2399+ let e = self . dcx ( ) . span_err ( const_arg. span , "literal of unknown type" ) ;
2400+ ty:: Const :: new_error ( tcx, e)
2401+ }
23942402 }
23952403 }
23962404
@@ -2773,6 +2781,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
27732781 }
27742782 }
27752783
2784+ #[ instrument( skip( self ) , level = "debug" ) ]
2785+ fn lower_const_arg_literal ( & self , kind : & LitKind , ty : Ty < ' tcx > , span : Span ) -> Const < ' tcx > {
2786+ let tcx = self . tcx ( ) ;
2787+ let input = LitToConstInput { lit : * kind, ty, neg : false } ;
2788+ tcx. at ( span) . lit_to_const ( input)
2789+ }
2790+
27762791 #[ instrument( skip( self ) , level = "debug" ) ]
27772792 fn try_lower_anon_const_lit (
27782793 & self ,
0 commit comments