mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
6efb3a2b9a
addresses https://github.com/rust-lang/rust-clippy/issues/7886 added `seek_from_current` complexity lint. it checks use of `Seek#seek` with `SeekFrom::Current(0)` and suggests `Seek#stream_position` method fix: add msrv fix: register LintInfo fix: remove unnecessary files fix: add test for msrv fix: remove fix fix: remove docs
26 lines
593 B
Rust
26 lines
593 B
Rust
// run-rustfix
|
|
#![warn(clippy::seek_from_current)]
|
|
#![feature(custom_inner_attributes)]
|
|
|
|
use std::fs::File;
|
|
use std::io::{self, Seek, SeekFrom, Write};
|
|
|
|
fn _msrv_1_50() -> io::Result<()> {
|
|
#![clippy::msrv = "1.50"]
|
|
let mut f = File::create("foo.txt")?;
|
|
f.write_all(b"Hi!")?;
|
|
f.seek(SeekFrom::Current(0))?;
|
|
f.seek(SeekFrom::Current(1))?;
|
|
Ok(())
|
|
}
|
|
|
|
fn _msrv_1_51() -> io::Result<()> {
|
|
#![clippy::msrv = "1.51"]
|
|
let mut f = File::create("foo.txt")?;
|
|
f.write_all(b"Hi!")?;
|
|
f.stream_position()?;
|
|
f.seek(SeekFrom::Current(1))?;
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {}
|