@@ -13,14 +13,13 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
1313use rustc_hir:: pat_util:: EnumerateAndAdjustIterator ;
1414use rustc_hir:: { self as hir, ByRef , LangItem , Mutability , Pinnedness , RangeEnd } ;
1515use rustc_index:: Idx ;
16- use rustc_infer:: infer:: TyCtxtInferExt ;
1716use rustc_middle:: mir:: interpret:: LitToConstInput ;
1817use rustc_middle:: thir:: {
1918 Ascription , FieldPat , LocalVarId , Pat , PatKind , PatRange , PatRangeBoundary ,
2019} ;
2120use rustc_middle:: ty:: adjustment:: { PatAdjust , PatAdjustment } ;
2221use rustc_middle:: ty:: layout:: IntegerExt ;
23- use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty , TyCtxt , TypingMode } ;
22+ use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty , TyCtxt } ;
2423use rustc_middle:: { bug, span_bug} ;
2524use rustc_span:: def_id:: DefId ;
2625use rustc_span:: { ErrorGuaranteed , Span } ;
@@ -621,51 +620,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
621620 pattern
622621 }
623622
624- /// Lowers an inline const block (e.g. `const { 1 + 1 }`) to a pattern.
625- fn lower_inline_const (
626- & mut self ,
627- block : & ' tcx hir:: ConstBlock ,
628- id : hir:: HirId ,
629- span : Span ,
630- ) -> PatKind < ' tcx > {
631- let tcx = self . tcx ;
632- let def_id = block. def_id ;
633- let ty = tcx. typeck ( def_id) . node_type ( block. hir_id ) ;
634-
635- let typeck_root_def_id = tcx. typeck_root_def_id ( def_id. to_def_id ( ) ) ;
636- let parent_args = ty:: GenericArgs :: identity_for_item ( tcx, typeck_root_def_id) ;
637- let args = ty:: InlineConstArgs :: new ( tcx, ty:: InlineConstArgsParts { parent_args, ty } ) . args ;
638-
639- let ct = ty:: UnevaluatedConst { def : def_id. to_def_id ( ) , args } ;
640- let c = ty:: Const :: new_unevaluated ( self . tcx , ct) ;
641- let pattern = self . const_to_pat ( c, ty, id, span) ;
642-
643- // Apply a type ascription for the inline constant.
644- let annotation = {
645- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
646- let args = ty:: InlineConstArgs :: new (
647- tcx,
648- ty:: InlineConstArgsParts { parent_args, ty : infcx. next_ty_var ( span) } ,
649- )
650- . args ;
651- infcx. canonicalize_user_type_annotation ( ty:: UserType :: new ( ty:: UserTypeKind :: TypeOf (
652- def_id. to_def_id ( ) ,
653- ty:: UserArgs { args, user_self_ty : None } ,
654- ) ) )
655- } ;
656- let annotation =
657- CanonicalUserTypeAnnotation { user_ty : Box :: new ( annotation) , span, inferred_ty : ty } ;
658- PatKind :: AscribeUserType {
659- subpattern : pattern,
660- ascription : Ascription {
661- annotation,
662- // Note that we use `Contravariant` here. See the `variance` field documentation
663- // for details.
664- variance : ty:: Contravariant ,
665- } ,
666- }
667- }
668-
669623 /// Lowers the kinds of "expression" that can appear in a HIR pattern:
670624 /// - Paths (e.g. `FOO`, `foo::BAR`, `Option::None`)
671625 /// - Inline const blocks (e.g. `const { 1 + 1 }`)
@@ -677,9 +631,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
677631 ) -> PatKind < ' tcx > {
678632 match & expr. kind {
679633 hir:: PatExprKind :: Path ( qpath) => self . lower_path ( qpath, expr. hir_id , expr. span ) . kind ,
680- hir:: PatExprKind :: ConstBlock ( anon_const) => {
681- self . lower_inline_const ( anon_const, expr. hir_id , expr. span )
682- }
683634 hir:: PatExprKind :: Lit { lit, negated } => {
684635 // We handle byte string literal patterns by using the pattern's type instead of the
685636 // literal's type in `const_to_pat`: if the literal `b"..."` matches on a slice reference,
0 commit comments