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

Enable report_in_external_macro in unaligned_references #82587

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Feb 27, 2021

Fixes an issue where unaligned_references is not triggered in external macros, unlike safe_packed_borrows.
Also, given that this lint is planned to eventually change to hard error (#82525), it would make sense for this lint to be triggered for external macros as well.

See taiki-e/pin-project-lite#55 (comment) and taiki-e/pin-project-lite#55 (comment) for more.

r? @RalfJung

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2021
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
Copy link
Member

Choose a reason for hiding this comment

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

Can you allow this lint, just to make sure we focus on the one we really care about here?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. Updated to allow safe_packed_borrows.

@RalfJung
Copy link
Member

The change makes sense at first sight, but I don't feel comfortable approving this since I have no idea if there are any side-effects to using this flag.

Cc @rust-lang/compiler -- does anyone know what report_in_external_macro does to a lint and can reveiw this (tiny) PR?

@taiki-e taiki-e force-pushed the unaligned_references branch from 8f16211 to 62b4b8d Compare February 27, 2021 12:25
@oli-obk
Copy link
Contributor

oli-obk commented Mar 1, 2021

Technically all lint changes need to be approved by the lang team. I'm going ahead and accept this however, since the lint is allow-by-default so if it is denied, the user must be expecting it to occur. This can theoretically be a breaking change in a bin crate that uses a macro that (uselessly) denies this right now.

@bors r+ rollup=never (for bisection)

@bors
Copy link
Contributor

bors commented Mar 1, 2021

📌 Commit 62b4b8d has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2021
@RalfJung
Copy link
Member

RalfJung commented Mar 1, 2021

Furthermore, when/if this becomes a hard error, it will certainly also be a hard error when the code originates in an external macro.

since the lint is allow-by-default

FWIW, I am hoping to change this soon with #82525.

@bors
Copy link
Contributor

bors commented Mar 1, 2021

⌛ Testing commit 62b4b8d with merge ccad218...

@bors
Copy link
Contributor

bors commented Mar 1, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing ccad218 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 1, 2021
@bors bors merged commit ccad218 into rust-lang:master Mar 1, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 1, 2021
@taiki-e taiki-e deleted the unaligned_references branch March 2, 2021 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants