Skip to content

Confusing error when using CoercePointee #134846

Closed
@RalfJung

Description

@RalfJung

Code

#![feature(derive_coerce_pointee)]
use std::marker::CoercePointee;
use std::rc::Rc;

#[repr(transparent)]
#[derive(CoercePointee)]
struct RcWithId<T: ?Sized> {
    inner: Rc<(i32, Box<T>)>,
}

Current output

error[E0277]: the trait bound `Box<T>: Unsize<Box<__S>>` is not satisfied
 --> src/main.rs:6:10
  |
6 | #[derive(CoercePointee)]
  |          ^^^^^^^^^^^^^ the trait `Unsize<Box<__S>>` is not implemented for `Box<T>`
  |
  = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
  = note: required for `Rc<(i32, Box<T>)>` to implement `DispatchFromDyn<Rc<(i32, Box<__S>)>>`
  = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Box<T>: Unsize<Box<__S>>` is not satisfied
 --> src/main.rs:6:10
  |
6 | #[derive(CoercePointee)]
  |          ^^^^^^^^^^^^^ the trait `Unsize<Box<__S>>` is not implemented for `Box<T>`
  |
  = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
  = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)

Desired output

Something that does not mention internal things like `Unsize` or `__S`

Rationale and extra context

No response

Other cases

Rust Version

current nightly

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-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