From 3f868b1791587e6af77e3b42a3b941f7fef03bcc Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 17 Jan 2021 14:58:34 +0100 Subject: [PATCH] Opacify query invocation. --- .../rustc_middle/src/ty/query/plumbing.rs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 91a267e38d5..b084fd01327 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -450,8 +450,7 @@ macro_rules! define_queries { Err(lookup) => lookup, }; - let qcx = QueryCtxt(self.tcx); - get_query::, _>(qcx, DUMMY_SP, key, lookup, QueryMode::Ensure); + self.tcx.queries.$name(self.tcx, DUMMY_SP, key, lookup, QueryMode::Ensure); })* } @@ -542,8 +541,7 @@ macro_rules! define_queries { Err(lookup) => lookup, }; - let qcx = QueryCtxt(self.tcx); - get_query::, _>(qcx, self.span, key, lookup, QueryMode::Get).unwrap() + self.tcx.queries.$name(self.tcx, self.span, key, lookup, QueryMode::Get).unwrap() })* } @@ -598,6 +596,20 @@ macro_rules! define_queries_struct { Some(jobs) } + + $($(#[$attr])* + #[inline(always)] + fn $name( + &self, + tcx: TyCtxt<$tcx>, + span: Span, + key: query_keys::$name<$tcx>, + lookup: QueryLookup, + mode: QueryMode, + ) -> Option> { + let qcx = QueryCtxt(tcx); + get_query::, _>(qcx, span, key, lookup, mode) + })* } }; }