A confusion about dependency

I have a Cargo.toml only declares hyper, but I can use http crate without declaring the dependency.
I tried cargo tree and only hyper depends on http, I am not sure how this happens. In my opinion, if I want to use a crate in my project, I have to declare a dependency in Cargo.toml.

A lot of the API from the http crate is re-exported in hyper, too. Maybe that’s what you’re observing? You should not be able to refer to the http crate’s API via http::… paths (e.g. something like http::header::HeaderName as opposed to the re-export hyper::header::HeaderName) if it isn’t in Cargo.toml. Please add a more detailed description of what’s actually happening :wink:

1 Like

Yes, you are right. I review my code again and found that my IDE automatically add use hyper::http

Interesting, I didn’t notice that there’s even a hidden public re-export of the whole http crate.

Isn't it a semver hazard for IDEs to autocomplete #[doc(hidden)] reexports?

I'd say making the reexport public is the hazard. You could import it no matter what your ide does or doesn't do. Hiding docs doesn't cancel its existence.

That said, the ide having the option to not autocomplete would be good too I suppose.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.