Skip to content

The #[pointee] attribute is required even if there is only one generic parameter #129465

Closed
@Darksonn

Description

@Darksonn

Currently, the following code triggers a compilation failure.

#![feature(derive_smart_pointer)]
use core::marker::SmartPointer;

#[repr(transparent)]
#[derive(SmartPointer)]
struct MyArc<T: ?Sized> {
    inner: *mut T,
}
error: At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits
 --> src/lib.rs:5:10
  |
5 | #[derive(SmartPointer)]
  |          ^^^^^^^^^^^^
  |
  = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)

However, the RFC says that specifying #[pointee] when the struct has only one type parameter is allowed, but not required.

See also this patch on the LKML.

Tracking issue: #123430
cc @dingxiangfei2009

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions