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

Missing safety comment: which variants are upheld? #3554

Open
burakemir opened this issue Feb 2, 2024 · 1 comment
Open

Missing safety comment: which variants are upheld? #3554

burakemir opened this issue Feb 2, 2024 · 1 comment
Labels
A-http2 Area: HTTP/2 specific. C-chore Category: chore. a general chore or maintenance task.

Comments

@burakemir
Copy link

Per Rust API Guidelines, unsafe functions should be documented with invariants:
https://rust-lang.github.io/api-guidelines/documentation.html

During review of the source, it was pointed out there is no safety comment here that describes what invariants are upheld:

send_stream: unsafe { UpgradedSendStream::new(send_stream) },

Also UpgradedSendStream::new does not state which invariants need to be upheld.

Would it be possible to add this?

@seanmonstar
Copy link
Member

@nox any thoughts? Looking at fn new(), all it does is transmute to the uninhabitable type. Perhaps the unsafety can be contained inside the constructor? Is there any time calling it would be wrong?

@seanmonstar seanmonstar added A-http2 Area: HTTP/2 specific. C-chore Category: chore. a general chore or maintenance task. labels Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http2 Area: HTTP/2 specific. C-chore Category: chore. a general chore or maintenance task.
Projects
None yet
Development

No branches or pull requests

2 participants