Use source_span
query instead of passing the untracked vec around
This commit is contained in:
parent
a6b381a11b
commit
a04e78730e
2 changed files with 14 additions and 23 deletions
|
@ -12,11 +12,10 @@ use rustc_errors::{struct_span_err, SuggestionStyle};
|
||||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||||
use rustc_hir::def::Namespace::{self, *};
|
use rustc_hir::def::Namespace::{self, *};
|
||||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PerNS};
|
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PerNS};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||||
use rustc_hir::PrimTy;
|
use rustc_hir::PrimTy;
|
||||||
use rustc_index::vec::IndexVec;
|
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::DefIdTree;
|
use rustc_middle::ty::{DefIdTree, TyCtxt};
|
||||||
use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE;
|
use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE;
|
||||||
use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
|
use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
|
||||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||||
|
@ -154,8 +153,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
|
|
||||||
if !candidates.is_empty() {
|
if !candidates.is_empty() {
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.tcx.sess,
|
self.tcx,
|
||||||
&self.tcx.untracked().source_span.read(),
|
|
||||||
&mut err,
|
&mut err,
|
||||||
span,
|
span,
|
||||||
&candidates,
|
&candidates,
|
||||||
|
@ -687,8 +685,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
err.span_help(span, &help_msg);
|
err.span_help(span, &help_msg);
|
||||||
}
|
}
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.tcx.sess,
|
self.tcx,
|
||||||
&self.tcx.untracked().source_span.read(),
|
|
||||||
&mut err,
|
&mut err,
|
||||||
Some(span),
|
Some(span),
|
||||||
&import_suggestions,
|
&import_suggestions,
|
||||||
|
@ -1352,8 +1349,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
let import_suggestions =
|
let import_suggestions =
|
||||||
self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected);
|
self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected);
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.tcx.sess,
|
self.tcx,
|
||||||
&self.tcx.untracked().source_span.read(),
|
|
||||||
err,
|
err,
|
||||||
None,
|
None,
|
||||||
&import_suggestions,
|
&import_suggestions,
|
||||||
|
@ -2358,8 +2354,7 @@ pub(crate) enum DiagnosticMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn import_candidates(
|
pub(crate) fn import_candidates(
|
||||||
session: &Session,
|
tcx: TyCtxt<'_>,
|
||||||
source_span: &IndexVec<LocalDefId, Span>,
|
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
// This is `None` if all placement locations are inside expansions
|
// This is `None` if all placement locations are inside expansions
|
||||||
use_placement_span: Option<Span>,
|
use_placement_span: Option<Span>,
|
||||||
|
@ -2368,8 +2363,7 @@ pub(crate) fn import_candidates(
|
||||||
append: &str,
|
append: &str,
|
||||||
) {
|
) {
|
||||||
show_candidates(
|
show_candidates(
|
||||||
session,
|
tcx,
|
||||||
source_span,
|
|
||||||
err,
|
err,
|
||||||
use_placement_span,
|
use_placement_span,
|
||||||
candidates,
|
candidates,
|
||||||
|
@ -2385,8 +2379,7 @@ pub(crate) fn import_candidates(
|
||||||
/// entities with that name in all crates. This method allows outputting the
|
/// entities with that name in all crates. This method allows outputting the
|
||||||
/// results of this search in a programmer-friendly way
|
/// results of this search in a programmer-friendly way
|
||||||
fn show_candidates(
|
fn show_candidates(
|
||||||
session: &Session,
|
tcx: TyCtxt<'_>,
|
||||||
source_span: &IndexVec<LocalDefId, Span>,
|
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
// This is `None` if all placement locations are inside expansions
|
// This is `None` if all placement locations are inside expansions
|
||||||
use_placement_span: Option<Span>,
|
use_placement_span: Option<Span>,
|
||||||
|
@ -2511,8 +2504,8 @@ fn show_candidates(
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) {
|
if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) {
|
||||||
let span = source_span[local_def_id];
|
let span = tcx.source_span(local_def_id);
|
||||||
let span = session.source_map().guess_head_span(span);
|
let span = tcx.sess.source_map().guess_head_span(span);
|
||||||
let mut multi_span = MultiSpan::from_span(span);
|
let mut multi_span = MultiSpan::from_span(span);
|
||||||
multi_span.push_span_label(span, "not accessible");
|
multi_span.push_span_label(span, "not accessible");
|
||||||
err.span_note(multi_span, &msg);
|
err.span_note(multi_span, &msg);
|
||||||
|
@ -2542,8 +2535,8 @@ fn show_candidates(
|
||||||
let mut spans = Vec::new();
|
let mut spans = Vec::new();
|
||||||
for (name, _, def_id, _) in &inaccessible_path_strings {
|
for (name, _, def_id, _) in &inaccessible_path_strings {
|
||||||
if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) {
|
if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) {
|
||||||
let span = source_span[local_def_id];
|
let span = tcx.source_span(local_def_id);
|
||||||
let span = session.source_map().guess_head_span(span);
|
let span = tcx.sess.source_map().guess_head_span(span);
|
||||||
spans.push((name, span));
|
spans.push((name, span));
|
||||||
} else {
|
} else {
|
||||||
if !has_colon {
|
if !has_colon {
|
||||||
|
|
|
@ -548,8 +548,7 @@ impl<'a, 'b, 'tcx> ImportResolver<'a, 'b, 'tcx> {
|
||||||
if let Some(candidates) = &err.candidates {
|
if let Some(candidates) = &err.candidates {
|
||||||
match &import.kind {
|
match &import.kind {
|
||||||
ImportKind::Single { nested: false, source, target, .. } => import_candidates(
|
ImportKind::Single { nested: false, source, target, .. } => import_candidates(
|
||||||
self.r.tcx.sess,
|
self.r.tcx,
|
||||||
&self.r.tcx.untracked().source_span.read(),
|
|
||||||
&mut diag,
|
&mut diag,
|
||||||
Some(err.span),
|
Some(err.span),
|
||||||
&candidates,
|
&candidates,
|
||||||
|
@ -561,8 +560,7 @@ impl<'a, 'b, 'tcx> ImportResolver<'a, 'b, 'tcx> {
|
||||||
),
|
),
|
||||||
ImportKind::Single { nested: true, source, target, .. } => {
|
ImportKind::Single { nested: true, source, target, .. } => {
|
||||||
import_candidates(
|
import_candidates(
|
||||||
self.r.tcx.sess,
|
self.r.tcx,
|
||||||
&self.r.tcx.untracked().source_span.read(),
|
|
||||||
&mut diag,
|
&mut diag,
|
||||||
None,
|
None,
|
||||||
&candidates,
|
&candidates,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue