Skip to content

E0621 when converting dyn reference to dyn pointer #81474

Open
@obsgolem

Description

@obsgolem

I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fa659e7e2652bb05a7e407a9925b1344

I expected to see this happen: The reference should convert to a pointer, losing all lifetime information.

Instead, this happened: Rust askes that the reference be given a static lifetime. This doesn't occur with non-dyn references. In addition, if you make a small modification to the code then it works: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1257118244ee5aef365f12906c3b52fc

Meta

rustc --version --verbose:

1.49.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutA-lifetimesArea: Lifetimes / regionsA-raw-pointersArea: raw pointers, MaybeUninit, NonNullD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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