From 89df289ebee019ed594c762e9f780186d2761b0a Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Sat, 3 Sep 2022 01:16:09 +0800 Subject: [PATCH 1/2] Add trait_upcasting related languages changes --- src/behavior-considered-undefined.md | 1 + src/type-coercions.md | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index e810e8c0d..ff3c24367 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -34,6 +34,7 @@ code. * Invoking undefined behavior via compiler intrinsics. * Executing code compiled with platform features that the current platform does not support (see [`target_feature`]), *except* if the platform explicitly documents this to be safe. +* Performing non-nop coercion on a dangling or unaligned raw pointer. * Calling a function with the wrong call ABI or unwinding from a function with the wrong unwind ABI. * Producing an invalid value, even in private fields and locals. "Producing" a value happens any time a value is assigned to or read from a place, passed to diff --git a/src/type-coercions.md b/src/type-coercions.md index 45d81d386..9a8b1939b 100644 --- a/src/type-coercions.md +++ b/src/type-coercions.md @@ -159,7 +159,7 @@ Coercion is allowed between the following types: ### Unsized Coercions The following coercions are called `unsized coercions`, since they -relate to converting sized types to unsized types, and are permitted in a few +relate to converting types to unsized types, and are permitted in a few cases where other coercions are not, as described above. They can still happen anywhere else a coercion can occur. @@ -172,6 +172,8 @@ an implementation of `Unsize` for `T` will be provided: * `T` to `dyn U`, when `T` implements `U + Sized`, and `U` is [object safe]. +* `dyn T` to `dyn U`, when `T` has `U` as one of its ancestor trait. + * `Foo<..., T, ...>` to `Foo<..., U, ...>`, when: * `Foo` is a struct. * `T` implements `Unsize`. From 75d48ad86a97203d6acb0fa0b5989f9c4a93e333 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Wed, 22 Nov 2023 13:07:36 +0800 Subject: [PATCH 2/2] Address review comments. Co-authored-by: Michael Goulet --- src/type-coercions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type-coercions.md b/src/type-coercions.md index 9a8b1939b..4841d5c2c 100644 --- a/src/type-coercions.md +++ b/src/type-coercions.md @@ -172,7 +172,7 @@ an implementation of `Unsize` for `T` will be provided: * `T` to `dyn U`, when `T` implements `U + Sized`, and `U` is [object safe]. -* `dyn T` to `dyn U`, when `T` has `U` as one of its ancestor trait. +* `dyn T` to `dyn U`, when `U` is one of `T`'s supertraits. * `Foo<..., T, ...>` to `Foo<..., U, ...>`, when: * `Foo` is a struct.