Skip to content

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

Closed

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementation
    on Aug 23, 2024
  2. dingxiangfei2009 commented on Aug 23, 2024

    @dingxiangfei2009
    Contributor

    @rustbot claim

  3. Darksonn commented on Aug 23, 2024

    @Darksonn
    MemberAuthor

    Oh, also, the error message says "At least one generic" but it's not valid to have several pointees.

  4. added a commit that references this issue on Aug 28, 2024
    4168c39
  5. added 2 commits that reference this issue on Aug 29, 2024
    c05e451
    d2418cb
  6. added a commit that references this issue on Aug 29, 2024
    52c9ca0
  7. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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