Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ixrec opened this issue Jan 21, 2020 · 4 comments
Closed

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

Ixrec opened this issue Jan 21, 2020 · 4 comments
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. F-dropck_eyepatch `#![feature(dropck_eyepatch)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Ixrec
Copy link
Contributor

Ixrec commented Jan 21, 2020

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

@jonas-schievink jonas-schievink added A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-dropck_eyepatch `#![feature(dropck_eyepatch)]` labels Jan 21, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2024

see also https://github.com/rust-lang/rust/pull/128444/files for how the attribute just works on anything like functions, imports, ...

@oli-obk oli-obk added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Aug 1, 2024
@kei519
Copy link

kei519 commented Aug 14, 2024

@rustbot claim

@kei519
Copy link

kei519 commented Sep 9, 2024

This seems to be fixed with 3a9bf4551374893fdc522572ee569028186e22cc.

@jieyouxu
Copy link
Member

Fixed by #129235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. F-dropck_eyepatch `#![feature(dropck_eyepatch)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants