@@ -12,11 +12,10 @@ use rustc_errors::{struct_span_err, SuggestionStyle};
12
12
use rustc_feature:: BUILTIN_ATTRIBUTES ;
13
13
use rustc_hir:: def:: Namespace :: { self , * } ;
14
14
use rustc_hir:: def:: { self , CtorKind , CtorOf , DefKind , NonMacroAttrKind , PerNS } ;
15
- use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
15
+ use rustc_hir:: def_id:: { DefId , CRATE_DEF_ID , LOCAL_CRATE } ;
16
16
use rustc_hir:: PrimTy ;
17
- use rustc_index:: vec:: IndexVec ;
18
17
use rustc_middle:: bug;
19
- use rustc_middle:: ty:: DefIdTree ;
18
+ use rustc_middle:: ty:: { DefIdTree , TyCtxt } ;
20
19
use rustc_session:: lint:: builtin:: ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE ;
21
20
use rustc_session:: lint:: builtin:: MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS ;
22
21
use rustc_session:: lint:: BuiltinLintDiagnostics ;
@@ -154,8 +153,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
154
153
155
154
if !candidates. is_empty ( ) {
156
155
show_candidates (
157
- & self . tcx . sess ,
158
- & self . tcx . untracked ( ) . source_span . read ( ) ,
156
+ self . tcx ,
159
157
& mut err,
160
158
span,
161
159
& candidates,
@@ -687,8 +685,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
687
685
err. span_help ( span, & help_msg) ;
688
686
}
689
687
show_candidates (
690
- & self . tcx . sess ,
691
- & self . tcx . untracked ( ) . source_span . read ( ) ,
688
+ self . tcx ,
692
689
& mut err,
693
690
Some ( span) ,
694
691
& import_suggestions,
@@ -1352,8 +1349,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1352
1349
let import_suggestions =
1353
1350
self . lookup_import_candidates ( ident, Namespace :: MacroNS , parent_scope, is_expected) ;
1354
1351
show_candidates (
1355
- & self . tcx . sess ,
1356
- & self . tcx . untracked ( ) . source_span . read ( ) ,
1352
+ self . tcx ,
1357
1353
err,
1358
1354
None ,
1359
1355
& import_suggestions,
@@ -2358,8 +2354,7 @@ pub(crate) enum DiagnosticMode {
2358
2354
}
2359
2355
2360
2356
pub ( crate ) fn import_candidates (
2361
- session : & Session ,
2362
- source_span : & IndexVec < LocalDefId , Span > ,
2357
+ tcx : TyCtxt < ' _ > ,
2363
2358
err : & mut Diagnostic ,
2364
2359
// This is `None` if all placement locations are inside expansions
2365
2360
use_placement_span : Option < Span > ,
@@ -2368,8 +2363,7 @@ pub(crate) fn import_candidates(
2368
2363
append : & str ,
2369
2364
) {
2370
2365
show_candidates (
2371
- session,
2372
- source_span,
2366
+ tcx,
2373
2367
err,
2374
2368
use_placement_span,
2375
2369
candidates,
@@ -2385,8 +2379,7 @@ pub(crate) fn import_candidates(
2385
2379
/// entities with that name in all crates. This method allows outputting the
2386
2380
/// results of this search in a programmer-friendly way
2387
2381
fn show_candidates (
2388
- session : & Session ,
2389
- source_span : & IndexVec < LocalDefId , Span > ,
2382
+ tcx : TyCtxt < ' _ > ,
2390
2383
err : & mut Diagnostic ,
2391
2384
// This is `None` if all placement locations are inside expansions
2392
2385
use_placement_span : Option < Span > ,
@@ -2511,8 +2504,8 @@ fn show_candidates(
2511
2504
) ;
2512
2505
2513
2506
if let Some ( local_def_id) = def_id. and_then ( |did| did. as_local ( ) ) {
2514
- let span = source_span[ local_def_id] ;
2515
- let span = session . source_map ( ) . guess_head_span ( span) ;
2507
+ let span = tcx . source_span ( local_def_id) ;
2508
+ let span = tcx . sess . source_map ( ) . guess_head_span ( span) ;
2516
2509
let mut multi_span = MultiSpan :: from_span ( span) ;
2517
2510
multi_span. push_span_label ( span, "not accessible" ) ;
2518
2511
err. span_note ( multi_span, & msg) ;
@@ -2542,8 +2535,8 @@ fn show_candidates(
2542
2535
let mut spans = Vec :: new ( ) ;
2543
2536
for ( name, _, def_id, _) in & inaccessible_path_strings {
2544
2537
if let Some ( local_def_id) = def_id. and_then ( |did| did. as_local ( ) ) {
2545
- let span = source_span[ local_def_id] ;
2546
- let span = session . source_map ( ) . guess_head_span ( span) ;
2538
+ let span = tcx . source_span ( local_def_id) ;
2539
+ let span = tcx . sess . source_map ( ) . guess_head_span ( span) ;
2547
2540
spans. push ( ( name, span) ) ;
2548
2541
} else {
2549
2542
if !has_colon {
0 commit comments