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

Change defaults of accept-comment-above-statement and accept-comment-above-attributes #11170

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

tgross35
Copy link
Contributor

This patch sets the two configuration options for undocumented_unsafe_blocks to true by default: these are accept-comment-above-statement and accept-comment-above-attributes. Having these values false by default prevents what many users would consider clean code, e.g. placing the // SAFETY: comment above a single-line functino call, rather than directly next to the argument.

This was originally discussed in #11162

changelog: [undocumented_unsafe_blocks]: set
accept-comment-above-statement and accept-comment-above-attributes to true by default.

@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2023

r? @giraffate

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 17, 2023
@tgross35 tgross35 force-pushed the undocumented-unsafe-blocks-defaults branch from dcfb32e to d90de23 Compare July 17, 2023 04:49
@bors
Copy link
Contributor

bors commented Jul 21, 2023

☔ The latest upstream changes (presumably #11003) made this pull request unmergeable. Please resolve the merge conflicts.

@tgross35 tgross35 force-pushed the undocumented-unsafe-blocks-defaults branch from d90de23 to 90c37e1 Compare August 4, 2023 01:03
@tgross35
Copy link
Contributor Author

tgross35 commented Aug 4, 2023

Conflicts should be resolved

Since you were involved in the original conversation:

r? @Centri3

@rustbot rustbot assigned Centri3 and unassigned giraffate Aug 4, 2023
@Centri3
Copy link
Member

Centri3 commented Aug 9, 2023

LGTM, though we should probably use revisions for the default/custom configuration options instead of duplicating the file with minor comment changes, but that's not a big deal

Ideally however, these wouldn't even be configuration options as I highly doubt there are any cases (other than bugs) where somebody would actually want to have these set to false. We could probably deprecate them and say that this behavior will be forced in the future, but that can be done in a future PR.

@bors r+

@bors
Copy link
Contributor

bors commented Aug 9, 2023

📌 Commit 90c37e1 has been approved by Centri3

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 9, 2023

⌛ Testing commit 90c37e1 with merge 07dc32a...

bors added a commit that referenced this pull request Aug 9, 2023
…r=Centri3

Change defaults of `accept-comment-above-statement` and `accept-comment-above-attributes`

This patch sets the two configuration options for `undocumented_unsafe_blocks` to `true` by default: these are `accept-comment-above-statement` and `accept-comment-above-attributes`. Having these values `false` by default prevents what many users would consider clean code, e.g. placing the `// SAFETY:` comment above a single-line functino call, rather than directly next to the argument.

This was originally discussed in #11162

changelog: [`undocumented_unsafe_blocks`]: set
`accept-comment-above-statement` and `accept-comment-above-attributes` to `true` by default.
@bors
Copy link
Contributor

bors commented Aug 9, 2023

💔 Test failed - checks-action_test

@tgross35
Copy link
Contributor Author

tgross35 commented Aug 9, 2023

LGTM, though we should probably use revisions for the default/custom configuration options instead of duplicating the file with minor comment changes, but that's not a big deal

If this is something that we can do now, is there an example? I have to fix something here anyway it seems so might as well change that too if possible

@Centri3
Copy link
Member

Centri3 commented Aug 9, 2023

You usually put the following headers at the top of the file:

//@revisions: a b
//@[a] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/mylint/a
//@[b] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/mylint/b

With a clippy.toml file existing in both subdirectories a and b. Doubt you can conditionally add a comment though so just have something like SAFETY: will be allowed if <configoption> is true

@bors
Copy link
Contributor

bors commented Aug 31, 2023

☔ The latest upstream changes (presumably #11418) made this pull request unmergeable. Please resolve the merge conflicts.

@Centri3
Copy link
Member

Centri3 commented Sep 20, 2023

Hey @tgross35, any progress on the revisions? If not, this just needs a cargo collect-metadata run and a rebase and this can be merged.

@tgross35 tgross35 force-pushed the undocumented-unsafe-blocks-defaults branch 2 times, most recently from 468c39e to e57bf7e Compare September 20, 2023 07:14
@tgross35
Copy link
Contributor Author

@Centri3 sorry about that, it fell off my radar. I think I got the dual config working right as you suggested, and did the rebase.

I'm not sure why github shows the four deleted/renamed files as conflicts when my tree is clean, I am trying to figure this out but do you have any ideas?

@tgross35 tgross35 force-pushed the undocumented-unsafe-blocks-defaults branch from e57bf7e to 872590f Compare September 20, 2023 07:39
This patch sets the two configuration options for
`undocumented_unsafe_blocks` to `true` by default: these are
`accept-comment-above-statement` and `accept-comment-above-attributes`.
Having these values `false` by default prevents what many users would
consider clean code, e.g. placing the `// SAFETY:` comment above a
single-line functino call, rather than directly next to the argument.

changelog: [`undocumented_unsafe_blocks`]: set
`accept-comment-above-statement` and `accept-comment-above-attributes`
to `true` by default.
@tgross35 tgross35 force-pushed the undocumented-unsafe-blocks-defaults branch from 872590f to 1b3e5dd Compare September 20, 2023 07:41
@tgross35
Copy link
Contributor Author

I guess I was just rebasing against my own fork instead of upstream 🤦 I think this should be good to go

@Centri3
Copy link
Member

Centri3 commented Sep 20, 2023

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Sep 20, 2023

📌 Commit 1b3e5dd has been approved by Centri3

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 20, 2023

⌛ Testing commit 1b3e5dd with merge ddbe110...

@bors
Copy link
Contributor

bors commented Sep 20, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Centri3
Pushing ddbe110 to master...

@bors bors merged commit ddbe110 into rust-lang:master Sep 20, 2023
7 checks passed
@tgross35 tgross35 deleted the undocumented-unsafe-blocks-defaults branch September 20, 2023 08:21
jwnrt added a commit to jwnrt/opentitan that referenced this pull request May 14, 2024
This commit moves the safety comments above what they're annotating.

It also adds a safety comment about the `transmute` from bytes loaded
from an ELF into an extern C struct.

Had to extract `mod_id_ptr` to change the `is_err_status` line's
formatting to fit on one line. This is to work around a clippy bug
which is fixed in
<rust-lang/rust-clippy#11170>
but our Rust toolchain is too old.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request May 23, 2024
This commit moves the safety comments above what they're annotating.

It also adds a safety comment about the `transmute` from bytes loaded
from an ELF into an extern C struct.

Had to extract `mod_id_ptr` to change the `is_err_status` line's
formatting to fit on one line. This is to work around a clippy bug
which is fixed in
<rust-lang/rust-clippy#11170>
but our Rust toolchain is too old.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to lowRISC/opentitan that referenced this pull request May 31, 2024
This commit moves the safety comments above what they're annotating.

It also adds a safety comment about the `transmute` from bytes loaded
from an ELF into an extern C struct.

Had to extract `mod_id_ptr` to change the `is_err_status` line's
formatting to fit on one line. This is to work around a clippy bug
which is fixed in
<rust-lang/rust-clippy#11170>
but our Rust toolchain is too old.

Signed-off-by: James Wainwright <[email protected]>
AlexJones0 pushed a commit to AlexJones0/opentitan that referenced this pull request Jul 8, 2024
This commit moves the safety comments above what they're annotating.

It also adds a safety comment about the `transmute` from bytes loaded
from an ELF into an extern C struct.

Had to extract `mod_id_ptr` to change the `is_err_status` line's
formatting to fit on one line. This is to work around a clippy bug
which is fixed in
<rust-lang/rust-clippy#11170>
but our Rust toolchain is too old.

Signed-off-by: James Wainwright <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants