Skip to content

Commit 0f822d7

Browse files
committed
query-fy type_name
1 parent b7f5eab commit 0f822d7

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2684,7 +2684,6 @@ dependencies = [
26842684
"rustc_errors 0.0.0",
26852685
"rustc_fs_util 0.0.0",
26862686
"rustc_incremental 0.0.0",
2687-
"rustc_mir 0.0.0",
26882687
"rustc_target 0.0.0",
26892688
"serialize 0.0.0",
26902689
"syntax 0.0.0",

src/librustc/query/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,15 @@ rustc_queries! {
441441
no_force
442442
desc { "extract field of const" }
443443
}
444+
445+
/// Produces an absolute path representation of the given type. See also the documentation
446+
/// on `std::any::type_name`.
447+
query type_name(key: Ty<'tcx>) -> &'tcx ty::Const<'tcx> {
448+
eval_always
449+
no_force
450+
desc { "get absolute path of type" }
451+
}
452+
444453
}
445454

446455
TypeChecking {

src/librustc_codegen_llvm/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
212212
}
213213
"type_name" => {
214214
let tp_ty = substs.type_at(0);
215-
let ty_name = rustc_mir::interpret::type_name(self.tcx, tp_ty);
215+
let ty_name = self.tcx.type_name(tp_ty);
216216
OperandRef::from_const(self, ty_name).immediate_or_packed_pair(self)
217217
}
218218
"type_id" => {

src/librustc_mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ pub use self::visitor::{ValueVisitor, MutValueVisitor};
3333

3434
pub use self::validity::RefTracking;
3535

36-
pub use self::intrinsics::type_name;
36+
pub(super) use self::intrinsics::type_name;

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub fn provide(providers: &mut Providers<'_>) {
6767
let (param_env, (value, field)) = param_env_and_value.into_parts();
6868
const_eval::const_field(tcx, param_env, None, field, value)
6969
};
70+
providers.type_name = interpret::type_name;
7071
}
7172

7273
__build_diagnostic_array! { librustc_mir, DIAGNOSTICS }

0 commit comments

Comments
 (0)