Merge pull request #371 from est31/stable_type_name

Replace type_name intrinsic by stable type_name
This commit is contained in:
Yehuda Katz 2019-08-24 09:33:13 -07:00 committed by GitHub
commit b7c426e952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View file

@ -3,7 +3,6 @@
#![feature(generators)] #![feature(generators)]
#![feature(try_trait)] #![feature(try_trait)]
#![feature(bind_by_move_pattern_guards)] #![feature(bind_by_move_pattern_guards)]
#![feature(core_intrinsics)]
#![feature(option_flattening)] #![feature(option_flattening)]
#![feature(specialization)] #![feature(specialization)]
#![feature(proc_macro_hygiene)] #![feature(proc_macro_hygiene)]

View file

@ -14,7 +14,7 @@ pub trait ExtractType: Sized {
impl<T> ExtractType for T { impl<T> ExtractType for T {
default fn extract(_value: &Tagged<Value>) -> Result<T, ShellError> { default fn extract(_value: &Tagged<Value>) -> Result<T, ShellError> {
let name = std::intrinsics::type_name::<T>(); let name = std::any::type_name::<T>();
Err(ShellError::unimplemented(format!( Err(ShellError::unimplemented(format!(
"<T> ExtractType for {}", "<T> ExtractType for {}",
name name
@ -32,7 +32,7 @@ impl<T> ExtractType for T {
impl<T: ExtractType> ExtractType for Vec<Tagged<T>> { impl<T: ExtractType> ExtractType for Vec<Tagged<T>> {
fn extract(value: &Tagged<Value>) -> Result<Self, ShellError> { fn extract(value: &Tagged<Value>) -> Result<Self, ShellError> {
let name = std::intrinsics::type_name::<T>(); let name = std::any::type_name::<T>();
trace!("<Vec> Extracting {:?} for Vec<{}>", value, name); trace!("<Vec> Extracting {:?} for Vec<{}>", value, name);
match value.item() { match value.item() {
@ -69,8 +69,8 @@ impl<T: ExtractType> ExtractType for Vec<Tagged<T>> {
impl<T: ExtractType, U: ExtractType> ExtractType for (T, U) { impl<T: ExtractType, U: ExtractType> ExtractType for (T, U) {
fn extract(value: &Tagged<Value>) -> Result<(T, U), ShellError> { fn extract(value: &Tagged<Value>) -> Result<(T, U), ShellError> {
let t_name = std::intrinsics::type_name::<T>(); let t_name = std::any::type_name::<T>();
let u_name = std::intrinsics::type_name::<U>(); let u_name = std::any::type_name::<U>();
trace!("Extracting {:?} for ({}, {})", value, t_name, u_name); trace!("Extracting {:?} for ({}, {})", value, t_name, u_name);
@ -98,7 +98,7 @@ impl<T: ExtractType, U: ExtractType> ExtractType for (T, U) {
impl<T: ExtractType> ExtractType for Option<T> { impl<T: ExtractType> ExtractType for Option<T> {
fn extract(value: &Tagged<Value>) -> Result<Option<T>, ShellError> { fn extract(value: &Tagged<Value>) -> Result<Option<T>, ShellError> {
let name = std::intrinsics::type_name::<T>(); let name = std::any::type_name::<T>();
trace!("<Option> Extracting {:?} for Option<{}>", value, name); trace!("<Option> Extracting {:?} for Option<{}>", value, name);
let result = match value.item() { let result = match value.item() {
@ -123,7 +123,7 @@ impl<T: ExtractType> ExtractType for Option<T> {
impl<T: ExtractType> ExtractType for Tagged<T> { impl<T: ExtractType> ExtractType for Tagged<T> {
fn extract(value: &Tagged<Value>) -> Result<Tagged<T>, ShellError> { fn extract(value: &Tagged<Value>) -> Result<Tagged<T>, ShellError> {
let name = std::intrinsics::type_name::<T>(); let name = std::any::type_name::<T>();
trace!("<Tagged> Extracting {:?} for Tagged<{}>", value, name); trace!("<Tagged> Extracting {:?} for Tagged<{}>", value, name);
Ok(T::extract(value)?.tagged(value.tag())) Ok(T::extract(value)?.tagged(value.tag()))

View file

@ -70,7 +70,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> {
V: Visitor<'de>, V: Visitor<'de>,
{ {
let value = self.pop(); let value = self.pop();
let name = std::intrinsics::type_name::<V::Value>(); let name = std::any::type_name::<V::Value>();
trace!("<Deserialize any> Extracting {:?}", name); trace!("<Deserialize any> Extracting {:?}", name);
V::Value::extract(&value.val) V::Value::extract(&value.val)
@ -237,7 +237,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> {
if self.saw_root { if self.saw_root {
let value = self.pop(); let value = self.pop();
let name = std::intrinsics::type_name::<V::Value>(); let name = std::any::type_name::<V::Value>();
trace!("Extracting {:?} for {:?}", value.val, name); trace!("Extracting {:?} for {:?}", value.val, name);
V::Value::extract(&value.val) V::Value::extract(&value.val)
} else { } else {