Always go through the expn_that_defined query.
This commit is contained in:
parent
835150e702
commit
507a1fdf13
4 changed files with 9 additions and 15 deletions
|
@ -942,7 +942,7 @@ impl EncodeContext<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
record!(self.tables.span[def_id] <- tcx.def_span(def_id));
|
record!(self.tables.span[def_id] <- tcx.def_span(def_id));
|
||||||
record!(self.tables.attributes[def_id] <- tcx.get_attrs(def_id));
|
record!(self.tables.attributes[def_id] <- tcx.get_attrs(def_id));
|
||||||
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expansion_that_defined(def_id));
|
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id));
|
||||||
if should_encode_visibility(def_kind) {
|
if should_encode_visibility(def_kind) {
|
||||||
record!(self.tables.visibility[def_id] <- self.tcx.visibility(def_id));
|
record!(self.tables.visibility[def_id] <- self.tcx.visibility(def_id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,4 +167,8 @@ pub fn provide(providers: &mut Providers) {
|
||||||
};
|
};
|
||||||
providers.opt_def_kind = |tcx, def_id| tcx.hir().opt_def_kind(def_id.expect_local());
|
providers.opt_def_kind = |tcx, def_id| tcx.hir().opt_def_kind(def_id.expect_local());
|
||||||
providers.all_local_trait_impls = |tcx, ()| &tcx.hir_crate(()).trait_impls;
|
providers.all_local_trait_impls = |tcx, ()| &tcx.hir_crate(()).trait_impls;
|
||||||
|
providers.expn_that_defined = |tcx, id| {
|
||||||
|
let id = id.expect_local();
|
||||||
|
tcx.definitions.expansion_that_defined(id)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,7 @@ rustc_queries! {
|
||||||
|
|
||||||
/// Internal helper query. Use `tcx.expansion_that_defined` instead
|
/// Internal helper query. Use `tcx.expansion_that_defined` instead
|
||||||
query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
|
query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
|
||||||
|
eval_always
|
||||||
desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_INDEX};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_INDEX};
|
||||||
use rustc_hir::{Constness, Node};
|
use rustc_hir::{Constness, Node};
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_span::hygiene::ExpnId;
|
|
||||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::Align;
|
use rustc_target::abi::Align;
|
||||||
|
@ -1862,20 +1861,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
&& use_name
|
&& use_name
|
||||||
.span
|
.span
|
||||||
.ctxt()
|
.ctxt()
|
||||||
.hygienic_eq(def_name.span.ctxt(), self.expansion_that_defined(def_parent_def_id))
|
.hygienic_eq(def_name.span.ctxt(), self.expn_that_defined(def_parent_def_id))
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expansion_that_defined(self, scope: DefId) -> ExpnId {
|
|
||||||
match scope.as_local() {
|
|
||||||
// Parsing and expansion aren't incremental, so we don't
|
|
||||||
// need to go through a query for the same-crate case.
|
|
||||||
Some(scope) => self.hir().definitions().expansion_that_defined(scope),
|
|
||||||
None => self.expn_that_defined(scope),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
|
pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
|
||||||
ident.span.normalize_to_macros_2_0_and_adjust(self.expansion_that_defined(scope));
|
ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope));
|
||||||
ident
|
ident
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1886,8 +1876,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
block: hir::HirId,
|
block: hir::HirId,
|
||||||
) -> (Ident, DefId) {
|
) -> (Ident, DefId) {
|
||||||
let scope =
|
let scope =
|
||||||
match ident.span.normalize_to_macros_2_0_and_adjust(self.expansion_that_defined(scope))
|
match ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope)) {
|
||||||
{
|
|
||||||
Some(actual_expansion) => {
|
Some(actual_expansion) => {
|
||||||
self.hir().definitions().parent_module_of_macro_def(actual_expansion)
|
self.hir().definitions().parent_module_of_macro_def(actual_expansion)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue