@@ -11,7 +11,6 @@ use rustc::hir::def_id::DefId;
1111use rustc:: hir:: intravisit:: { Visitor , NestedVisitorMap } ;
1212use rustc:: hir:: map:: Map ;
1313use rustc:: hir;
14- use rustc:: session:: Session ;
1514use rustc:: ty:: TyCtxt ;
1615use rustc:: ty:: query:: Providers ;
1716use syntax:: ast:: Mutability ;
@@ -75,31 +74,29 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
7574
7675#[ derive( Copy , Clone ) ]
7776struct CheckConstVisitor < ' tcx > {
78- sess : & ' tcx Session ,
79- hir_map : & ' tcx Map < ' tcx > ,
77+ tcx : TyCtxt < ' tcx > ,
8078 const_kind : Option < ConstKind > ,
8179}
8280
8381impl < ' tcx > CheckConstVisitor < ' tcx > {
8482 fn new ( tcx : TyCtxt < ' tcx > ) -> Self {
8583 CheckConstVisitor {
86- sess : & tcx. sess ,
87- hir_map : tcx. hir ( ) ,
84+ tcx,
8885 const_kind : None ,
8986 }
9087 }
9188
9289 /// Emits an error when an unsupported expression is found in a const context.
9390 fn const_check_violated ( & self , bad_op : & str , span : Span ) {
94- if self . sess . opts . debugging_opts . unleash_the_miri_inside_of_you {
95- self . sess . span_warn ( span, "skipping const checks" ) ;
91+ if self . tcx . sess . opts . debugging_opts . unleash_the_miri_inside_of_you {
92+ self . tcx . sess . span_warn ( span, "skipping const checks" ) ;
9693 return ;
9794 }
9895
9996 let const_kind = self . const_kind
10097 . expect ( "`const_check_violated` may only be called inside a const context" ) ;
10198
102- span_err ! ( self . sess, span, E0744 , "`{}` is not allowed in a `{}`" , bad_op, const_kind) ;
99+ span_err ! ( self . tcx . sess, span, E0744 , "`{}` is not allowed in a `{}`" , bad_op, const_kind) ;
103100 }
104101
105102 /// Saves the parent `const_kind` before calling `f` and restores it afterwards.
@@ -113,7 +110,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
113110
114111impl < ' tcx > Visitor < ' tcx > for CheckConstVisitor < ' tcx > {
115112 fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' tcx > {
116- NestedVisitorMap :: OnlyBodies ( & self . hir_map )
113+ NestedVisitorMap :: OnlyBodies ( & self . tcx . hir ( ) )
117114 }
118115
119116 fn visit_anon_const ( & mut self , anon : & ' tcx hir:: AnonConst ) {
@@ -122,7 +119,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
122119 }
123120
124121 fn visit_body ( & mut self , body : & ' tcx hir:: Body ) {
125- let kind = ConstKind :: for_body ( body, self . hir_map ) ;
122+ let kind = ConstKind :: for_body ( body, self . tcx . hir ( ) ) ;
126123 self . recurse_into ( kind, |this| hir:: intravisit:: walk_body ( this, body) ) ;
127124 }
128125
0 commit comments