Skip to content

#[may_dangle] compiles on non-Drop impls #68411

Closed

Description

The RFC pretty strongly implies that this attribute is only supposed to be used on Drop, and the semantics of it don't make any sense on other traits. Yet, this compiles:

#![feature(dropck_eyepatch)]

struct Foo<T>(T);

unsafe impl<#[may_dangle] T> std::ops::Deref for Foo<T> {
    type Target = T;
    fn deref(&self) -> &T {
        &self.0
    }
}

playground link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-dropck_eyepatch`#![feature(dropck_eyepatch)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions