hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Missing safety comment: which variants are upheld?

Open burakemir opened this issue 1 year ago • 1 comments

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?

burakemir avatar Feb 02 '24 15:02 burakemir

@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 avatar Feb 05 '24 14:02 seanmonstar