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

Add TODOs related to #429 and quotes to safety comments. #433

Merged
merged 5 commits into from
Nov 4, 2023

Conversation

samuelselleck
Copy link
Contributor

While reading through some of the code I added some quotes and TODOs here and there related to #429.

@samuelselleck samuelselleck changed the title Safety comments status updates Add TODOs related to #429 and quotes to safety comments. Sep 30, 2023
Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Awesome, thank you so much for these! This is exactly what we're looking for. A few minor style nits, but the content is good.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
samuelselleck added a commit to samuelselleck/zerocopy that referenced this pull request Oct 13, 2023
samuelselleck added a commit to samuelselleck/zerocopy that referenced this pull request Oct 13, 2023
@samuelselleck samuelselleck force-pushed the safety-comments-status-updates branch from d0e7316 to 51d2016 Compare October 13, 2023 19:07
@samuelselleck
Copy link
Contributor Author

samuelselleck commented Oct 13, 2023

Thank you for your feedback! Don't worry about being picky, that's the kind of thing I'm looking to learn :)

I think I've addressed all of your comments, if there is anything else do let me know.

Question: The code still contains safety comments (starting with //SAFETY:) that are not wrapped in the safety_comment! macro. Is this intentional and if so what is the purpose of the differentiation?

(I had some git problems, but think they are fixed? (accidentally merged upstream changes through the github gui). If anything is off do let me know and I'll try to figure it out.)

@joshlf
Copy link
Member

joshlf commented Oct 15, 2023

I think I've addressed all of your comments, if there is anything else do let me know.

Awesome, thanks! I'll try to get to these soon.

Question: The code still contains safety comments (starting with //SAFETY:) that are not wrapped in the safety_comment! macro. Is this intentional and if so what is the purpose of the differentiation?

Yeah, that's intentional. Normally you'd just put a // SAFETY: comment on each unsafe block. The reason for the safety_comment! macro is that we often have a lot of unsafe trait impls whose soundness is based on identical or very similar arguments, and so we'd like to be able to write a single // SAFETY: comment to annotate multiple such impls. Since there's no way to do this that is legible to Clippy, we use the safety_comment! macro instead, which under the hood just annotates each macro invocation with #[allow(clippy::undocumented_unsafe_blocks)]:

zerocopy/src/macros.rs

Lines 24 to 29 in 9ce05f8

macro_rules! safety_comment {
(#[doc = r" SAFETY:"] $($(#[doc = $_doc:literal])* $macro:ident!$args:tt;)*) => {
#[allow(clippy::undocumented_unsafe_blocks)]
const _: () = { $($macro!$args;)* };
}
}

(I had some git problems, but think they are fixed? (accidentally merged upstream changes through the github gui). If anything is off do let me know and I'll try to figure it out.)

Seems fine to me 🤷‍♂️ We have this repo configured to squash all commits into a single one when a PR is merged, so it probably doesn't make much of a difference (perhaps with the exception that the resulting commit message will include a summary of each commit that was included in the PR). Personally my flow is to always just edit the commit and then force push, but whatever flow works for you is fine.

@samuelselleck
Copy link
Contributor Author

Thanks for the explanation of the safety_comment macro, that makes sense! I'll adopt the same push -f method for edits in the future :)

Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Okay, this looks great! Just a few tiny nits, but as soon as these are resolved, I'll approve it 🙂

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@samuelselleck samuelselleck force-pushed the safety-comments-status-updates branch from 51d2016 to 0795819 Compare October 21, 2023 17:15
Copy link
Contributor Author

@samuelselleck samuelselleck left a comment

Choose a reason for hiding this comment

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

Added your changes! I'll make sure to keep spacing and use [] when quoting in the middle of a sentence. merged all commits into one now as well.

src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Thanks again for all your work on this! I cleaned a few things up (deleting spurious extra newlines and such) and it's ready to merge.

@joshlf joshlf enabled auto-merge November 4, 2023 11:58
@joshlf joshlf added this pull request to the merge queue Nov 4, 2023
Merged via the queue into google:main with commit 44513f7 Nov 4, 2023
126 checks passed
@samuelselleck
Copy link
Contributor Author

Apologies for not getting back to you sooner, thanks for taking the time!

@joshlf
Copy link
Member

joshlf commented Nov 4, 2023

Apologies for not getting back to you sooner, thanks for taking the time!

No worries at all! I was just going back and cleaning up old PRs and I figured it was silly to ask you to do a few obvious edits when I was doing it already 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants