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

Implement Stream automatically for Reader + Writer #8984

Closed
wants to merge 1 commit into from

Conversation

chris-morgan
Copy link
Member

This is consistent with the existing documentation but was not the
actual behaviour, which I've found to be rather a nuisance, actually.

This is consistent with the existing documentation but was not the
actual behaviour, which I've found to be rather a nuisance, actually.
bors added a commit that referenced this pull request Sep 5, 2013
This is consistent with the existing documentation but was not the
actual behaviour, which I've found to be rather a nuisance, actually.
@bors bors closed this Sep 5, 2013
chris-morgan added a commit to chris-morgan/rust-http that referenced this pull request Sep 6, 2013
With the landing of rust-lang/rust#8984, we can finally use Stream
meaningfully...
pcwalton pushed a commit to servo/rust-http that referenced this pull request Oct 3, 2013
With the landing of rust-lang/rust#8984, we can finally use Stream
meaningfully...
Jarcho pushed a commit to Jarcho/rust that referenced this pull request Aug 29, 2022
Implemented `suspicious_to_owned` lint to check if `to_owned` is called on a `Cow`

changelog: Add lint ``[`suspicious_to_owned`]``

-----------------
Hi,
posting this unsolicited PR as I've been burned by this issue :)
Being unsolicited, feel free to reject it or reassign a different lint level etc.

This lint checks whether `to_owned` is called on `Cow<'_, _>`. This is done because `to_owned` is very similarly named to `into_owned`, but the effect of calling those two methods is completely different (one makes the `Cow::Borrowed` into a `Cow::Owned`, the other just clones the `Cow`). If the cow is then passed to code for which the type is not checked (e.g. generics, closures, etc.) it might slip through and if the cow data is coming from an unsafe context there is the potential for accidentally cause undefined behavior.
Even if not falling into this painful case, there's really no reason to call `to_owned` on a `Cow` other than confusing people reading the code: either `into_owned` or `clone` should be called.

Note that this overlaps perfectly with `implicit_clone` as a warning, but `implicit_clone` is classified pedantic (while the consequences for `Cow` might be of a wider blast radius than just pedantry); given the overlap, I set-up the lint so that if `suspicious_to_owned` triggers `implicit_clone` will not trigger. I'm not 100% sure this is done in the correct way (I tried to copy what other lints were doing) so please provide feedback on it if it isn't.

### Checklist

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
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.

4 participants