query-fy type_name

This commit is contained in:
Mark Mansi
2019-06-02 23:20:36 -05:00
parent b7f5eab11c
commit 0f822d775f
5 changed files with 12 additions and 3 deletions
-1
View File
@@ -2684,7 +2684,6 @@ dependencies = [
"rustc_errors 0.0.0",
"rustc_fs_util 0.0.0",
"rustc_incremental 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
+9
View File
@@ -441,6 +441,15 @@
no_force
desc { "extract field of const" }
}
/// Produces an absolute path representation of the given type. See also the documentation
/// on `std::any::type_name`.
query type_name(key: Ty<'tcx>) -> &'tcx ty::Const<'tcx> {
eval_always
no_force
desc { "get absolute path of type" }
}
}
TypeChecking {
+1 -1
View File
@@ -212,7 +212,7 @@ fn codegen_intrinsic_call(
}
"type_name" => {
let tp_ty = substs.type_at(0);
let ty_name = rustc_mir::interpret::type_name(self.tcx, tp_ty);
let ty_name = self.tcx.type_name(tp_ty);
OperandRef::from_const(self, ty_name).immediate_or_packed_pair(self)
}
"type_id" => {
+1 -1
View File
@@ -33,4 +33,4 @@
pub use self::validity::RefTracking;
pub use self::intrinsics::type_name;
pub(super) use self::intrinsics::type_name;
+1
View File
@@ -67,6 +67,7 @@ pub fn provide(providers: &mut Providers<'_>) {
let (param_env, (value, field)) = param_env_and_value.into_parts();
const_eval::const_field(tcx, param_env, None, field, value)
};
providers.type_name = interpret::type_name;
}
__build_diagnostic_array! { librustc_mir, DIAGNOSTICS }