Skip to content

Commit 7f4e36b

Browse files
committed
Add section on non-derive macros
1 parent a9104e7 commit 7f4e36b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

text/3621-derive-smart-pointer.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,22 @@ This RFC does not propose that solution because:
521521

522522
The authors are not aware of any macros using a `#[pointee]` attribute today.
523523

524+
## Derive macro or not?
525+
526+
Stabilizing this as a derive macro more or less locks us in with the decision
527+
that the compiler will use traits to specify which types are compatible with
528+
trait objects. However, one could imagine other mechanisms. For example, stable
529+
Rust currently has logic saying that any struct where the last field is `?Sized`
530+
will work with unsizing operations. (E.g., if `Wrapper` is such a struct, then
531+
you can convert from `Box<Wrapper<[u8; 10]>>` to `Box<Wrapper<[u8]>>`.) That
532+
mechanism is not specified using a trait.
533+
534+
However, using traits for this functionality seems to be the most flexible. To
535+
solve the unresolved questions, we most likely need to constrain the
536+
implementations of these traits for `Pin` with stricter trait bounds than what
537+
is specified on the struct. That will get much more complicated if we use a
538+
mechanism other than traits to specify this logic.
539+
524540
# Prior art
525541
[prior-art]: #prior-art
526542

0 commit comments

Comments
 (0)