diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-06-04 21:37:05 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-06-04 21:37:34 +0200 |
| commit | 507a1fdf138b6247e0c31bcc00e844f5293c8394 (patch) | |
| tree | c48c553766a0f11c1e53cb3843116c069930259a /compiler/rustc_middle | |
| parent | 835150e70288535bc57bb624792229b9dc94991d (diff) | |
| download | rust-507a1fdf138b6247e0c31bcc00e844f5293c8394.tar.gz rust-507a1fdf138b6247e0c31bcc00e844f5293c8394.zip | |
Always go through the expn_that_defined query.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 17 |
3 files changed, 8 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index b8407833c90..087f772c812 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -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.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) + }; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index f65dfea04eb..6a112a8531c 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -212,6 +212,7 @@ rustc_queries! { /// Internal helper query. Use `tcx.expansion_that_defined` instead query expn_that_defined(key: DefId) -> rustc_span::ExpnId { + eval_always desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index af2be37f387..5da2aab4093 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -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::{Constness, Node}; use rustc_macros::HashStable; -use rustc_span::hygiene::ExpnId; use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::Span; use rustc_target::abi::Align; @@ -1862,20 +1861,11 @@ impl<'tcx> TyCtxt<'tcx> { && use_name .span .ctxt() - .hygienic_eq(def_name.span.ctxt(), self.expansion_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), - } + .hygienic_eq(def_name.span.ctxt(), self.expn_that_defined(def_parent_def_id)) } 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 } @@ -1886,8 +1876,7 @@ impl<'tcx> TyCtxt<'tcx> { block: hir::HirId, ) -> (Ident, DefId) { 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) => { self.hir().definitions().parent_module_of_macro_def(actual_expansion) } |
