File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,18 @@ impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *
113113/// `DispatchFromDyn<FTarget>` where `FTarget` is the type of the corresponding coerced field in
114114/// `T`.
115115///
116+ /// Note that we do not support the case where multiple pointer narrowings or downcasting of trait
117+ /// objects into concrete objects are involved in coercing one type to another through
118+ /// the `DispatchFromDyn` trait.
119+ /// For instance, we do not support dispatch from `&Arc<dyn Tr>` to `&Arc<T>`.
120+ /// `&Arc<dyn Tr>` is already behind an immutable reference while the coercion would require a
121+ /// downcasting of the trait object `Arc<dyn Tr>` by chipping of the virtual table.
122+ /// This will break the invariant of an immutable reference that the place behind shall remain
123+ /// not mutated during the access.
124+ /// Similarly, the dispatch from `Box<Box<dyn Tr>>` to `Box<Box<T>>` also requires a similar memory
125+ /// layout change.
126+ /// Therefore, this category of coercion is not supported.
127+ ///
116128/// An example implementation of the trait:
117129///
118130/// ```
You can’t perform that action at this time.
0 commit comments