1515//! crate as a kind of pass. This should eventually be factored away.
1616
1717use std:: cell:: Cell ;
18- use std:: ops:: ControlFlow ;
1918use std:: { assert_matches, iter} ;
2019
2120use rustc_abi:: { ExternAbi , Size } ;
@@ -24,13 +23,12 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2423use rustc_errors:: {
2524 Applicability , Diag , DiagCtxtHandle , Diagnostic , E0228 , ErrorGuaranteed , Level , StashKey ,
2625} ;
27- use rustc_hir:: def:: { DefKind , Res } ;
26+ use rustc_hir:: def:: DefKind ;
2827use rustc_hir:: def_id:: { DefId , LocalDefId } ;
29- use rustc_hir:: intravisit:: { self , InferKind , Visitor , VisitorExt } ;
28+ use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt } ;
3029use rustc_hir:: { self as hir, GenericParamKind , HirId , Node , PreciseCapturingArgKind , find_attr} ;
3130use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
3231use rustc_infer:: traits:: { DynCompatibilityViolation , ObligationCause } ;
33- use rustc_middle:: hir:: nested_filter;
3432use rustc_middle:: query:: Providers ;
3533use rustc_middle:: ty:: util:: { Discr , IntTypeExt } ;
3634use rustc_middle:: ty:: {
@@ -1644,12 +1642,7 @@ fn anon_const_kind<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> ty::AnonConstKin
16441642 return ty:: AnonConstKind :: MCG ;
16451643 }
16461644
1647- let body = tcx. hir_body_owned_by ( def) ;
1648- let mut visitor = GCAParamVisitor ( tcx) ;
1649- match visitor. visit_body ( body) {
1650- ControlFlow :: Break ( UsesParam ) => ty:: AnonConstKind :: GCA ,
1651- ControlFlow :: Continue ( ( ) ) => ty:: AnonConstKind :: MCG ,
1652- }
1645+ ty:: AnonConstKind :: MCG
16531646 } else if tcx. features ( ) . min_generic_const_args ( ) {
16541647 ty:: AnonConstKind :: MCG
16551648 } else if let hir:: Node :: Expr ( hir:: Expr {
@@ -1688,29 +1681,6 @@ fn is_anon_const_rhs_of_const_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId)
16881681 def_id == rhs_anon. def_id
16891682}
16901683
1691- struct GCAParamVisitor < ' tcx > ( TyCtxt < ' tcx > ) ;
1692-
1693- struct UsesParam ;
1694-
1695- impl < ' tcx > Visitor < ' tcx > for GCAParamVisitor < ' tcx > {
1696- type NestedFilter = nested_filter:: OnlyBodies ;
1697- type Result = ControlFlow < UsesParam > ;
1698-
1699- fn maybe_tcx ( & mut self ) -> TyCtxt < ' tcx > {
1700- self . 0
1701- }
1702-
1703- fn visit_path ( & mut self , path : & hir:: Path < ' tcx > , _id : HirId ) -> ControlFlow < UsesParam > {
1704- if let Res :: Def ( DefKind :: TyParam | DefKind :: ConstParam | DefKind :: LifetimeParam , _) =
1705- path. res
1706- {
1707- return ControlFlow :: Break ( UsesParam ) ;
1708- }
1709-
1710- intravisit:: walk_path ( self , path)
1711- }
1712- }
1713-
17141684#[ instrument( level = "debug" , skip( tcx) , ret) ]
17151685fn const_of_item < ' tcx > (
17161686 tcx : TyCtxt < ' tcx > ,
0 commit comments