query-fy type_name
This commit is contained in:
parent
b7f5eab11c
commit
0f822d775f
5 changed files with 12 additions and 3 deletions
|
@ -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",
|
||||
|
|
|
@ -441,6 +441,15 @@ rustc_queries! {
|
|||
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 {
|
||||
|
|
|
@ -212,7 +212,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
"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" => {
|
||||
|
|
|
@ -33,4 +33,4 @@ pub use self::visitor::{ValueVisitor, MutValueVisitor};
|
|||
|
||||
pub use self::validity::RefTracking;
|
||||
|
||||
pub use self::intrinsics::type_name;
|
||||
pub(super) use self::intrinsics::type_name;
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Add table
Reference in a new issue