@@ -49,7 +49,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
49
49
use rustc_data_structures:: sorted_map:: SortedMap ;
50
50
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
51
51
use rustc_data_structures:: sync:: Lrc ;
52
- use rustc_errors:: { struct_span_err, Applicability } ;
52
+ use rustc_errors:: { struct_span_err, Applicability , Handler } ;
53
53
use rustc_hir as hir;
54
54
use rustc_hir:: def:: { DefKind , LifetimeRes , Namespace , PartialRes , PerNS , Res } ;
55
55
use rustc_hir:: def_id:: { LocalDefId , CRATE_DEF_ID } ;
@@ -58,7 +58,6 @@ use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
58
58
use rustc_index:: vec:: { Idx , IndexVec } ;
59
59
use rustc_middle:: ty:: { ResolverAstLowering , TyCtxt } ;
60
60
use rustc_session:: parse:: feature_err;
61
- use rustc_session:: Session ;
62
61
use rustc_span:: hygiene:: MacroKind ;
63
62
use rustc_span:: source_map:: DesugaringKind ;
64
63
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -83,7 +82,6 @@ mod path;
83
82
84
83
struct LoweringContext < ' a , ' hir > {
85
84
tcx : TyCtxt < ' hir > ,
86
- sess : & ' hir Session ,
87
85
resolver : & ' a mut ResolverAstLowering ,
88
86
89
87
/// Used to allocate HIR nodes.
@@ -681,8 +679,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
681
679
self . resolver . get_import_res ( id) . present_items ( )
682
680
}
683
681
684
- fn diagnostic ( & self ) -> & rustc_errors :: Handler {
685
- self . sess . diagnostic ( )
682
+ fn diagnostic ( & self ) -> & Handler {
683
+ self . tcx . sess . diagnostic ( )
686
684
}
687
685
688
686
/// 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> {
694
692
allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
695
693
) -> Span {
696
694
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)
698
696
} )
699
697
}
700
698
701
699
/// Intercept all spans entering HIR.
702
700
/// Mark a span as relative to the current owning item.
703
701
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 {
705
703
span. with_parent ( Some ( self . current_hir_id_owner ) )
706
704
} else {
707
705
// Do not make spans relative when not using incremental compilation.
@@ -1048,7 +1046,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1048
1046
}
1049
1047
1050
1048
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 (
1052
1050
data. span ,
1053
1051
"parenthesized generic arguments cannot be used in associated type constraints" ,
1054
1052
) ;
@@ -1093,7 +1091,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1093
1091
ast:: GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . lower_lifetime ( & lt) ) ,
1094
1092
ast:: GenericArg :: Type ( ty) => {
1095
1093
match ty. kind {
1096
- TyKind :: Infer if self . sess . features_untracked ( ) . generic_arg_infer => {
1094
+ TyKind :: Infer if self . tcx . features ( ) . generic_arg_infer => {
1097
1095
return GenericArg :: Infer ( hir:: InferArg {
1098
1096
hir_id : self . lower_node_id ( ty. id ) ,
1099
1097
span : self . lower_span ( ty. span ) ,
@@ -1190,7 +1188,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1190
1188
} else {
1191
1189
self . next_node_id ( )
1192
1190
} ;
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 ( ) ) ;
1194
1192
Lifetime { ident : Ident :: new ( kw:: UnderscoreLifetime , span) , id }
1195
1193
} ) ;
1196
1194
let lifetime = self . lower_lifetime ( & region) ;
@@ -1294,7 +1292,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1294
1292
}
1295
1293
ImplTraitContext :: Disallowed ( position) => {
1296
1294
let mut err = struct_span_err ! (
1297
- self . sess,
1295
+ self . tcx . sess,
1298
1296
t. span,
1299
1297
E0562 ,
1300
1298
"`impl Trait` only allowed in function and inherent method return types, not in {}" ,
@@ -1307,7 +1305,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1307
1305
}
1308
1306
TyKind :: MacCall ( _) => panic ! ( "`TyKind::MacCall` should have been expanded by now" ) ,
1309
1307
TyKind :: CVarArgs => {
1310
- self . sess . delay_span_bug (
1308
+ self . tcx . sess . delay_span_bug (
1311
1309
t. span ,
1312
1310
"`TyKind::CVarArgs` should have been handled elsewhere" ,
1313
1311
) ;
@@ -1912,7 +1910,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1912
1910
hir_id,
1913
1911
name,
1914
1912
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) ,
1916
1914
kind,
1917
1915
colon_span : param. colon_span . map ( |s| self . lower_span ( s) ) ,
1918
1916
}
@@ -2054,11 +2052,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2054
2052
fn lower_array_length ( & mut self , c : & AnonConst ) -> hir:: ArrayLen {
2055
2053
match c. value . kind {
2056
2054
ExprKind :: Underscore => {
2057
- if self . sess . features_untracked ( ) . generic_arg_infer {
2055
+ if self . tcx . features ( ) . generic_arg_infer {
2058
2056
hir:: ArrayLen :: Infer ( self . lower_node_id ( c. id ) , c. value . span )
2059
2057
} else {
2060
2058
feature_err (
2061
- & self . sess . parse_sess ,
2059
+ & self . tcx . sess . parse_sess ,
2062
2060
sym:: generic_arg_infer,
2063
2061
c. value . span ,
2064
2062
"using `_` for array lengths is unstable" ,
0 commit comments