- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationFeature: RFC 3621's oft-renamed implementationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
When deriving SmartPointer
on a struct with additional bounds the resulting impl
is missing a bound resulting in a compile error. This behavior was not explicitly mentioned in SmartPointer
RFC, so I assume it's a bug. See #123430
I tried this code: (playground)
#![feature(derive_smart_pointer)] #[derive(core::marker::SmartPointer)] #[repr(transparent)] // Remove the OnDrop bound to make it compile but then the functionality is lost pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> { data: &'a mut T, x: core::marker::PhantomData<X>, } pub trait OnDrop { fn on_drop(&mut self); }
I expected to see this happen: the code compiles and provides a smart pointer that executes on_drop
when the smart pointer is dropped.
Instead, this happened: compile error:
error[E0277]: the trait bound `__S: OnDrop` is not satisfied --> src/lib.rs:3:10 | 3 | #[derive(core::marker::SmartPointer)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `OnDrop` is not implemented for `__S` | note: required by a bound in `Ptr` --> src/lib.rs:6:34 | 6 | pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> { | ^^^^^^ required by this bound in `Ptr` = note: this error originates in the derive macro `core::marker::SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. error: could not compile `playground` (lib) due to 1 previous error
Meta
rustc --version --verbose
:
1.81.0-nightly 2024-07-11 5315cbe15b79533f380b
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationFeature: RFC 3621's oft-renamed implementationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.