Skip to content

Conversation

pnkfelix
Copy link
Contributor

Lint: warn when mixing #[repr(C)] with Drop

Fix #24585

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

codemap::DUMMY_SP);
ctx.span_lint(DROP_WITH_REPR_EXTERN,
drop_impl_span,
"Structs with `#[repr(C)]` attribute that \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we generally start compiler messages with a lower case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this message could also be rephrased slightly, maybe:

implementing Drop adds hidden state to a struct, possibly conflicting with the #[repr(C)] attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like the fact that I was referring solely to "structs" anyway, when this is slightly more general than that. So, that's fixed now. :)

@alexcrichton
Copy link
Member

Just a few minor nits, otherwise r=me though. Thanks @pnkfelix!

THis includes tests for struct and enum. (I suspect the closure case
is actually unreachable, but i see no harm in including it.)
@pnkfelix
Copy link
Contributor Author

@bors r=alexcrichton 2e23d81 rollup

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 29, 2015
Lint: warn when mixing `#[repr(C)]` with Drop

Fix rust-lang#24585
@bors bors merged commit 2e23d81 into rust-lang:master Apr 30, 2015
@pnkfelix
Copy link
Contributor Author

triage: beta-nominated

@rust-highfive rust-highfive added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 30, 2015
@pnkfelix
Copy link
Contributor Author

accepted for backport to beta channel.

(this is special case for 1.0; post 1.0 a change like this might need stronger motivation...)

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 30, 2015
@brson brson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 30, 2015
@brson
Copy link
Contributor

brson commented Apr 30, 2015

Backported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Drop flag is a footgun for #[repr(C)]
6 participants