about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2025-02-12 15:17:52 +0000
committerGitHub <noreply@github.com>2025-02-12 15:17:52 +0000
commit1cb4236a95b7ecd10b01d91e598bfd7f6c5188ad (patch)
tree6912d23d7ffb464dcac3480bdb49aefbcdd1b900 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parenta342340e6deb329b8eb9f2cf57275fd282ad14c8 (diff)
parent8b6de49ef74de5bc5485ccb507178fa72dff9c87 (diff)
downloadrust-1cb4236a95b7ecd10b01d91e598bfd7f6c5188ad.tar.gz
rust-1cb4236a95b7ecd10b01d91e598bfd7f6c5188ad.zip
New lint: `unbuffered_bytes` (#14089)
Checks for `Read::bytes()` on an unbuffered Read type.
The default implementation calls `read` for each byte, which can be very
inefficient for data that’s not in memory, such as `File`.

Considerations which I'd like to have feedback on:
* Currently this lint triggers when `.bytes()` is called on any type
that implements `std::io::Read` but not `std::io::BufRead`. This is
quite aggressive and in and may result in false positives. Alternatives:
* Only trigger on concrete types, not generic types. This does mean that
cases where a function is generic over a `R: Read` and calls `.bytes()`
are not caught by the lint, which could be quite a nasty case of this
bug.
  * Only trigger on an allowlist of stdlib types
* Compromise: Is it possible to make this lint `pedantic` on types that
are not on a allowlist?
* Theoretically, a trait implementation of `Read` could override
`.bytes()` with an efficient implementation. I'm not sure how to add
this check to the lint, and I can't find any cases of this being done in
practice.
* I don't think an automatic fix for this lint is possible, but I'd love
to be proven wrong
* This is my first time contributing to clippy, please let me know if I
did anything wrong

Fixes #14087
```
changelog: [`unbuffered_bytes`]: new lint
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions