@@ -49,7 +49,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
4949use rustc_data_structures:: sorted_map:: SortedMap ;
5050use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
5151use rustc_data_structures:: sync:: Lrc ;
52- use rustc_errors:: { struct_span_err, Applicability } ;
52+ use rustc_errors:: { struct_span_err, Applicability , Handler } ;
5353use rustc_hir as hir;
5454use rustc_hir:: def:: { DefKind , LifetimeRes , Namespace , PartialRes , PerNS , Res } ;
5555use rustc_hir:: def_id:: { LocalDefId , CRATE_DEF_ID } ;
@@ -58,7 +58,6 @@ use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
5858use rustc_index:: vec:: { Idx , IndexVec } ;
5959use rustc_middle:: ty:: { ResolverAstLowering , TyCtxt } ;
6060use rustc_session:: parse:: feature_err;
61- use rustc_session:: Session ;
6261use rustc_span:: hygiene:: MacroKind ;
6362use rustc_span:: source_map:: DesugaringKind ;
6463use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -83,7 +82,6 @@ mod path;
8382
8483struct LoweringContext < ' a , ' hir > {
8584 tcx : TyCtxt < ' hir > ,
86- sess : & ' hir Session ,
8785 resolver : & ' a mut ResolverAstLowering ,
8886
8987 /// Used to allocate HIR nodes.
@@ -681,8 +679,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
681679 self . resolver . get_import_res ( id) . present_items ( )
682680 }
683681
684- fn diagnostic ( & self ) -> & rustc_errors :: Handler {
685- self . sess . diagnostic ( )
682+ fn diagnostic ( & self ) -> & Handler {
683+ self . tcx . sess . diagnostic ( )
686684 }
687685
688686 /// Reuses the span but adds information like the kind of the desugaring and features that are
@@ -694,14 +692,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
694692 allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
695693 ) -> Span {
696694 self . tcx . with_stable_hashing_context ( |hcx| {
697- span. mark_with_reason ( allow_internal_unstable, reason, self . sess . edition ( ) , hcx)
695+ span. mark_with_reason ( allow_internal_unstable, reason, self . tcx . sess . edition ( ) , hcx)
698696 } )
699697 }
700698
701699 /// Intercept all spans entering HIR.
702700 /// Mark a span as relative to the current owning item.
703701 fn lower_span ( & self , span : Span ) -> Span {
704- if self . sess . opts . debugging_opts . incremental_relative_spans {
702+ if self . tcx . sess . opts . debugging_opts . incremental_relative_spans {
705703 span. with_parent ( Some ( self . current_hir_id_owner ) )
706704 } else {
707705 // Do not make spans relative when not using incremental compilation.
@@ -1048,7 +1046,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10481046 }
10491047
10501048 fn emit_bad_parenthesized_trait_in_assoc_ty ( & self , data : & ParenthesizedArgs ) {
1051- let mut err = self . sess . struct_span_err (
1049+ let mut err = self . tcx . sess . struct_span_err (
10521050 data. span ,
10531051 "parenthesized generic arguments cannot be used in associated type constraints" ,
10541052 ) ;
@@ -1093,7 +1091,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10931091 ast:: GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . lower_lifetime ( & lt) ) ,
10941092 ast:: GenericArg :: Type ( ty) => {
10951093 match ty. kind {
1096- TyKind :: Infer if self . sess . features_untracked ( ) . generic_arg_infer => {
1094+ TyKind :: Infer if self . tcx . features ( ) . generic_arg_infer => {
10971095 return GenericArg :: Infer ( hir:: InferArg {
10981096 hir_id : self . lower_node_id ( ty. id ) ,
10991097 span : self . lower_span ( ty. span ) ,
@@ -1190,7 +1188,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11901188 } else {
11911189 self . next_node_id ( )
11921190 } ;
1193- let span = self . sess . source_map ( ) . next_point ( t. span . shrink_to_lo ( ) ) ;
1191+ let span = self . tcx . sess . source_map ( ) . next_point ( t. span . shrink_to_lo ( ) ) ;
11941192 Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
11951193 } ) ;
11961194 let lifetime = self . lower_lifetime ( & region) ;
@@ -1294,7 +1292,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12941292 }
12951293 ImplTraitContext :: Disallowed ( position) => {
12961294 let mut err = struct_span_err ! (
1297- self . sess,
1295+ self . tcx . sess,
12981296 t. span,
12991297 E0562 ,
13001298 "`impl Trait` only allowed in function and inherent method return types, not in {}" ,
@@ -1307,7 +1305,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13071305 }
13081306 TyKind :: MacCall ( _) => panic ! ( "`TyKind::MacCall` should have been expanded by now" ) ,
13091307 TyKind :: CVarArgs => {
1310- self . sess . delay_span_bug (
1308+ self . tcx . sess . delay_span_bug (
13111309 t. span ,
13121310 "`TyKind::CVarArgs` should have been handled elsewhere" ,
13131311 ) ;
@@ -1912,7 +1910,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19121910 hir_id,
19131911 name,
19141912 span : self . lower_span ( param. span ( ) ) ,
1915- pure_wrt_drop : self . sess . contains_name ( & param. attrs , sym:: may_dangle) ,
1913+ pure_wrt_drop : self . tcx . sess . contains_name ( & param. attrs , sym:: may_dangle) ,
19161914 kind,
19171915 colon_span : param. colon_span . map ( |s| self . lower_span ( s) ) ,
19181916 }
@@ -2054,11 +2052,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20542052 fn lower_array_length ( & mut self , c : & AnonConst ) -> hir:: ArrayLen {
20552053 match c. value . kind {
20562054 ExprKind :: Underscore => {
2057- if self . sess . features_untracked ( ) . generic_arg_infer {
2055+ if self . tcx . features ( ) . generic_arg_infer {
20582056 hir:: ArrayLen :: Infer ( self . lower_node_id ( c. id ) , c. value . span )
20592057 } else {
20602058 feature_err (
2061- & self . sess . parse_sess ,
2059+ & self . tcx . sess . parse_sess ,
20622060 sym:: generic_arg_infer,
20632061 c. value . span ,
20642062 "using `_` for array lengths is unstable" ,
0 commit comments