@@ -133,8 +133,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
133
133
Some ( self . new_module (
134
134
parent,
135
135
ModuleKind :: Def ( def_kind, def_id, name) ,
136
- self . cstore ( ) . module_expansion_untracked ( def_id, & self . session ) ,
137
- self . cstore ( ) . get_span_untracked ( def_id, & self . session ) ,
136
+ self . cstore ( ) . module_expansion_untracked ( def_id, & self . tcx . sess ) ,
137
+ self . cstore ( ) . get_span_untracked ( def_id, & self . tcx . sess ) ,
138
138
// FIXME: Account for `#[no_implicit_prelude]` attributes.
139
139
parent. map_or ( false , |module| module. no_implicit_prelude ) ,
140
140
) )
@@ -179,7 +179,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
179
179
return macro_data. clone ( ) ;
180
180
}
181
181
182
- let ( ext, macro_rules) = match self . cstore ( ) . load_macro_untracked ( def_id, & self . session ) {
182
+ let ( ext, macro_rules) = match self . cstore ( ) . load_macro_untracked ( def_id, & self . tcx . sess ) {
183
183
LoadedMacro :: MacroDef ( item, edition) => (
184
184
Lrc :: new ( self . compile_macro ( & item, edition) . 0 ) ,
185
185
matches ! ( item. kind, ItemKind :: MacroDef ( def) if def. macro_rules) ,
@@ -205,7 +205,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
205
205
206
206
pub ( crate ) fn build_reduced_graph_external ( & mut self , module : Module < ' a > ) {
207
207
for child in
208
- Vec :: from_iter ( self . cstore ( ) . module_children_untracked ( module. def_id ( ) , self . session ) )
208
+ Vec :: from_iter ( self . cstore ( ) . module_children_untracked ( module. def_id ( ) , self . tcx . sess ) )
209
209
{
210
210
let parent_scope = ParentScope :: module ( module, self ) ;
211
211
BuildReducedGraphVisitor { r : self , parent_scope }
@@ -346,7 +346,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
346
346
347
347
fn insert_field_names_extern ( & mut self , def_id : DefId ) {
348
348
let field_names =
349
- self . r . cstore ( ) . struct_field_names_untracked ( def_id, self . r . session ) . collect ( ) ;
349
+ self . r . cstore ( ) . struct_field_names_untracked ( def_id, self . r . tcx . sess ) . collect ( ) ;
350
350
self . r . field_names . insert ( def_id, field_names) ;
351
351
}
352
352
@@ -539,14 +539,15 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
539
539
}
540
540
541
541
self . r
542
- . session
542
+ . tcx
543
+ . sess
543
544
. struct_span_err ( item. span , "`$crate` may not be imported" )
544
545
. emit ( ) ;
545
546
}
546
547
}
547
548
548
549
if ident. name == kw:: Crate {
549
- self . r . session . span_err (
550
+ self . r . tcx . sess . span_err (
550
551
ident. span ,
551
552
"crate root imports need to be explicitly named: \
552
553
`use crate as name;`",
@@ -575,7 +576,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
575
576
}
576
577
ast:: UseTreeKind :: Glob => {
577
578
let kind = ImportKind :: Glob {
578
- is_prelude : self . r . session . contains_name ( & item. attrs , sym:: prelude_import) ,
579
+ is_prelude : self . r . tcx . sess . contains_name ( & item. attrs , sym:: prelude_import) ,
579
580
max_vis : Cell :: new ( None ) ,
580
581
id,
581
582
} ;
@@ -690,7 +691,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
690
691
expansion. to_expn_id ( ) ,
691
692
item. span ,
692
693
parent. no_implicit_prelude
693
- || self . r . session . contains_name ( & item. attrs , sym:: no_implicit_prelude) ,
694
+ || self . r . tcx . sess . contains_name ( & item. attrs , sym:: no_implicit_prelude) ,
694
695
) ;
695
696
self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
696
697
@@ -755,7 +756,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
755
756
// If the structure is marked as non_exhaustive then lower the visibility
756
757
// to within the crate.
757
758
let mut ctor_vis = if vis. is_public ( )
758
- && self . r . session . contains_name ( & item. attrs , sym:: non_exhaustive)
759
+ && self . r . tcx . sess . contains_name ( & item. attrs , sym:: non_exhaustive)
759
760
{
760
761
ty:: Visibility :: Restricted ( CRATE_DEF_ID )
761
762
} else {
@@ -837,7 +838,8 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
837
838
838
839
let ( used, module, binding) = if orig_name. is_none ( ) && ident. name == kw:: SelfLower {
839
840
self . r
840
- . session
841
+ . tcx
842
+ . sess
841
843
. struct_span_err ( item. span , "`extern crate self;` requires renaming" )
842
844
. span_suggestion (
843
845
item. span ,
@@ -887,7 +889,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
887
889
{
888
890
let msg = "macro-expanded `extern crate` items cannot \
889
891
shadow names passed with `--extern`";
890
- self . r . session . span_err ( item. span , msg) ;
892
+ self . r . tcx . sess . span_err ( item. span , msg) ;
891
893
}
892
894
}
893
895
let entry = self . r . extern_prelude . entry ( ident. normalize_to_macros_2_0 ( ) ) . or_insert (
@@ -1014,7 +1016,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1014
1016
}
1015
1017
Res :: Def ( DefKind :: Union , def_id) => self . insert_field_names_extern ( def_id) ,
1016
1018
Res :: Def ( DefKind :: AssocFn , def_id) => {
1017
- if cstore. fn_has_self_parameter_untracked ( def_id, self . r . session ) {
1019
+ if cstore. fn_has_self_parameter_untracked ( def_id, self . r . tcx . sess ) {
1018
1020
self . r . has_self . insert ( def_id) ;
1019
1021
}
1020
1022
}
@@ -1033,7 +1035,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1033
1035
let msg = format ! ( "`{}` is already in scope" , name) ;
1034
1036
let note =
1035
1037
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)" ;
1036
- self . r . session . struct_span_err ( span, & msg) . note ( note) . emit ( ) ;
1038
+ self . r . tcx . sess . struct_span_err ( span, & msg) . note ( note) . emit ( ) ;
1037
1039
}
1038
1040
}
1039
1041
@@ -1045,7 +1047,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1045
1047
if attr. has_name ( sym:: macro_use) {
1046
1048
if self . parent_scope . module . parent . is_some ( ) {
1047
1049
struct_span_err ! (
1048
- self . r. session ,
1050
+ self . r. tcx . sess ,
1049
1051
item. span,
1050
1052
E0468 ,
1051
1053
"an `extern crate` loading macros must be at the crate root"
@@ -1055,7 +1057,8 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1055
1057
if let ItemKind :: ExternCrate ( Some ( orig_name) ) = item. kind {
1056
1058
if orig_name == kw:: SelfLower {
1057
1059
self . r
1058
- . session
1060
+ . tcx
1061
+ . sess
1059
1062
. struct_span_err (
1060
1063
attr. span ,
1061
1064
"`#[macro_use]` is not supported on `extern crate self`" ,
@@ -1064,7 +1067,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1064
1067
}
1065
1068
}
1066
1069
let ill_formed = |span| {
1067
- struct_span_err ! ( self . r. session , span, E0466 , "bad macro import" ) . emit ( ) ;
1070
+ struct_span_err ! ( self . r. tcx . sess , span, E0466 , "bad macro import" ) . emit ( ) ;
1068
1071
} ;
1069
1072
match attr. meta ( ) {
1070
1073
Some ( meta) => match meta. kind {
@@ -1135,8 +1138,13 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1135
1138
allow_shadowing,
1136
1139
) ;
1137
1140
} else {
1138
- struct_span_err ! ( self . r. session, ident. span, E0469 , "imported macro not found" )
1139
- . emit ( ) ;
1141
+ struct_span_err ! (
1142
+ self . r. tcx. sess,
1143
+ ident. span,
1144
+ E0469 ,
1145
+ "imported macro not found"
1146
+ )
1147
+ . emit ( ) ;
1140
1148
}
1141
1149
}
1142
1150
}
@@ -1148,7 +1156,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1148
1156
for attr in attrs {
1149
1157
if attr. has_name ( sym:: macro_escape) {
1150
1158
let msg = "`#[macro_escape]` is a deprecated synonym for `#[macro_use]`" ;
1151
- let mut err = self . r . session . struct_span_warn ( attr. span , msg) ;
1159
+ let mut err = self . r . tcx . sess . struct_span_warn ( attr. span , msg) ;
1152
1160
if let ast:: AttrStyle :: Inner = attr. style {
1153
1161
err. help ( "try an outer attribute: `#[macro_use]`" ) . emit ( ) ;
1154
1162
} else {
@@ -1159,7 +1167,10 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1159
1167
}
1160
1168
1161
1169
if !attr. is_word ( ) {
1162
- self . r . session . span_err ( attr. span , "arguments to `macro_use` are not allowed here" ) ;
1170
+ self . r
1171
+ . tcx
1172
+ . sess
1173
+ . span_err ( attr. span , "arguments to `macro_use` are not allowed here" ) ;
1163
1174
}
1164
1175
return true ;
1165
1176
}
@@ -1183,11 +1194,11 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1183
1194
}
1184
1195
1185
1196
fn proc_macro_stub ( & self , item : & ast:: Item ) -> Option < ( MacroKind , Ident , Span ) > {
1186
- if self . r . session . contains_name ( & item. attrs , sym:: proc_macro) {
1197
+ if self . r . tcx . sess . contains_name ( & item. attrs , sym:: proc_macro) {
1187
1198
return Some ( ( MacroKind :: Bang , item. ident , item. span ) ) ;
1188
- } else if self . r . session . contains_name ( & item. attrs , sym:: proc_macro_attribute) {
1199
+ } else if self . r . tcx . sess . contains_name ( & item. attrs , sym:: proc_macro_attribute) {
1189
1200
return Some ( ( MacroKind :: Attr , item. ident , item. span ) ) ;
1190
- } else if let Some ( attr) = self . r . session . find_by_name ( & item. attrs , sym:: proc_macro_derive)
1201
+ } else if let Some ( attr) = self . r . tcx . sess . find_by_name ( & item. attrs , sym:: proc_macro_derive)
1191
1202
{
1192
1203
if let Some ( nested_meta) = attr. meta_item_list ( ) . and_then ( |list| list. get ( 0 ) . cloned ( ) ) {
1193
1204
if let Some ( ident) = nested_meta. ident ( ) {
@@ -1222,7 +1233,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1222
1233
let def_id = self . r . local_def_id ( item. id ) ;
1223
1234
let ( ext, ident, span, macro_rules, rule_spans) = match & item. kind {
1224
1235
ItemKind :: MacroDef ( def) => {
1225
- let ( ext, rule_spans) = self . r . compile_macro ( item, self . r . session . edition ( ) ) ;
1236
+ let ( ext, rule_spans) = self . r . compile_macro ( item, self . r . tcx . sess . edition ( ) ) ;
1226
1237
let ext = Lrc :: new ( ext) ;
1227
1238
( ext, item. ident , item. span , def. macro_rules , rule_spans)
1228
1239
}
@@ -1243,7 +1254,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1243
1254
if macro_rules {
1244
1255
let ident = ident. normalize_to_macros_2_0 ( ) ;
1245
1256
self . r . macro_names . insert ( ident) ;
1246
- let is_macro_export = self . r . session . contains_name ( & item. attrs , sym:: macro_export) ;
1257
+ let is_macro_export = self . r . tcx . sess . contains_name ( & item. attrs , sym:: macro_export) ;
1247
1258
let vis = if is_macro_export {
1248
1259
ty:: Visibility :: Public
1249
1260
} else {
@@ -1507,7 +1518,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1507
1518
1508
1519
// If the variant is marked as non_exhaustive then lower the visibility to within the crate.
1509
1520
let ctor_vis = if vis. is_public ( )
1510
- && self . r . session . contains_name ( & variant. attrs , sym:: non_exhaustive)
1521
+ && self . r . tcx . sess . contains_name ( & variant. attrs , sym:: non_exhaustive)
1511
1522
{
1512
1523
ty:: Visibility :: Restricted ( CRATE_DEF_ID )
1513
1524
} else {
0 commit comments