-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
verbose-file-reads false positive #5368
Comments
Second bug: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8e49e12c99d43fe69dbfdbe375f785bf |
Third bug: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9f18b7ce2a3758ff5d37cd4e08ca4afe |
I'd move this lint to |
I would like to add another false positive to this lint. Here the provided hint doesn't really make sense at all: use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("example.txt").unwrap();
let mut header = [0; 4];
f.read_exact(&mut header).unwrap();
let mut rest = Vec::new();
f.read_to_end(&mut rest).unwrap();
} Further similar ones would include seeking around the file and reading it multiple times, opening the file sooner, then deleting it on the FS but keeping it open and similar cases. Clippy version:
|
…hiaskrgr Move verbose_file_reads to restriction cc #5368 Using `File::read` instead of `fs::read_to_end` does make sense in multiple cases, so this lint is rather restriction, than complexity changelog: Move [`verbose_file_reads`] to restriction
Reproducer on playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a06d5c34e0ec3cd9eafbd42af458028f
std::fs::read only supports reading from path, not from raw handle.
The text was updated successfully, but these errors were encountered: