hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.42k stars 1.59k forks source link

Missing safety comment: which variants are upheld? #3554

Open burakemir opened 7 months ago

burakemir commented 7 months ago

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: https://github.com/hyperium/hyper/blob/90eb95f62a32981cb662b0f750027231d8a2586b/src/proto/h2/server.rs#L478

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

Would it be possible to add this?

seanmonstar commented 7 months ago

@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?