From c9f1162a6ffc81adcb114a616899edad0f7d0750 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 10:17:39 +0100 Subject: [PATCH 1/4] Rephrase the any::type_name docs a bit. This attempts to be a little clearer (including in terminology) about the lack of guarantees that any::type_name provides. --- src/libcore/any.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 39df803bbea30..67698e5409f6a 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -446,14 +446,14 @@ impl TypeId { /// # Note /// /// This is intended for diagnostic use. The exact contents and format of the -/// string are not specified, other than being a best-effort description of the -/// type. For example, `type_name::>()` could return the -/// `"Option"` or `"std::option::Option"`, but not -/// `"foobar"`. In addition, the output may change between versions of the -/// compiler. +/// string retrned are not specified, other than being a best-effort description +/// of the type. For example, amongst the strings +/// that `type_name::>()` might map to are `"Option"` and +/// `"std::option::Option"`. /// -/// The type name should not be considered a unique identifier of a type; -/// multiple types may share the same type name. +/// The returned string must not be considered to be a unique identifier of a +/// type as multiple types may map to the same type name. In addition, the +/// output may change between versions of the compiler. /// /// The current implementation uses the same infrastructure as compiler /// diagnostics and debuginfo, but this is not guaranteed. From 93f877ce870e9fd13ad7c6a05ccb4abd46a3d106 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 11:01:31 +0100 Subject: [PATCH 2/4] Document that lifetimes do not currently appear in any::type_name()'s output. --- src/libcore/any.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 67698e5409f6a..2628f89033238 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -452,7 +452,9 @@ impl TypeId { /// `"std::option::Option"`. /// /// The returned string must not be considered to be a unique identifier of a -/// type as multiple types may map to the same type name. In addition, the +/// type as multiple types may map to the same type name. Similarly, there is no +/// guarantee that all parts of a type will appear in the returned string: for +/// example, lifetime specifiers are currently not included. In addition, the /// output may change between versions of the compiler. /// /// The current implementation uses the same infrastructure as compiler From 876001c8ac331a15661638fbb18b8b64facf2c96 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 4 May 2020 14:28:58 +0100 Subject: [PATCH 3/4] Fix typo. --- src/libcore/any.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 2628f89033238..996a9cdfc4d9d 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -446,8 +446,8 @@ impl TypeId { /// # Note /// /// This is intended for diagnostic use. The exact contents and format of the -/// string retrned are not specified, other than being a best-effort description -/// of the type. For example, amongst the strings +/// string returned are not specified, other than being a best-effort +/// description of the type. For example, amongst the strings /// that `type_name::>()` might map to are `"Option"` and /// `"std::option::Option"`. /// From 003ed802c4a289d959d4212ad80f33df7f3e2bc3 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Tue, 12 May 2020 16:54:29 +0100 Subject: [PATCH 4/4] Map to -> return. --- src/libcore/any.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 996a9cdfc4d9d..79b6304958d51 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -448,7 +448,7 @@ impl TypeId { /// This is intended for diagnostic use. The exact contents and format of the /// string returned are not specified, other than being a best-effort /// description of the type. For example, amongst the strings -/// that `type_name::>()` might map to are `"Option"` and +/// that `type_name::>()` might return are `"Option"` and /// `"std::option::Option"`. /// /// The returned string must not be considered to be a unique identifier of a