Skip to content

Commit 3d9ce6c

Browse files
committed
Add PhantomData for erased query result types
1 parent e4a6b06 commit 3d9ce6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_middle/src/ty/query.rs

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use rustc_span::symbol::Symbol;
6767
use rustc_span::{Span, DUMMY_SP};
6868
use rustc_target::abi;
6969
use rustc_target::spec::PanicStrategy;
70+
use std::marker::PhantomData;
7071
use std::ops::Deref;
7172
use std::path::PathBuf;
7273
use std::sync::Arc;
@@ -76,6 +77,8 @@ pub struct QuerySystem<'tcx> {
7677
pub extern_providers: Box<ExternProviders>,
7778
pub arenas: QueryArenas<'tcx>,
7879
pub caches: QueryCaches<'tcx>,
80+
// Since we erase query value types we tell the typesystem about them with `PhantomData`.
81+
_phantom_values: QueryPhantomValues<'tcx>,
7982
}
8083

8184
impl<'tcx> QuerySystem<'tcx> {
@@ -85,6 +88,7 @@ impl<'tcx> QuerySystem<'tcx> {
8588
extern_providers: Box::new(extern_providers),
8689
arenas: Default::default(),
8790
caches: Default::default(),
91+
_phantom_values: Default::default(),
8892
}
8993
}
9094
}
@@ -303,6 +307,11 @@ macro_rules! define_callbacks {
303307
),)*
304308
}
305309

310+
#[derive(Default)]
311+
pub struct QueryPhantomValues<'tcx> {
312+
$($(#[$attr])* pub $name: PhantomData<query_values::$name<'tcx>>,)*
313+
}
314+
306315
#[derive(Default)]
307316
pub struct QueryCaches<'tcx> {
308317
$($(#[$attr])* pub $name: query_storage::$name<'tcx>,)*

0 commit comments

Comments
 (0)