mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Rustup to rust-lang/rust#62672
try macro is deprecated now, so Clippy will drop the support for it also
This commit is contained in:
parent
9533fa5b19
commit
e1d573c242
@ -322,14 +322,14 @@ fn try_() -> Result<i32, &'static str> {
|
||||
|
||||
#[clippy::cognitive_complexity = "0"]
|
||||
fn try_again() -> Result<i32, &'static str> {
|
||||
let _ = r#try!(Ok(42));
|
||||
let _ = r#try!(Ok(43));
|
||||
let _ = r#try!(Ok(44));
|
||||
let _ = r#try!(Ok(45));
|
||||
let _ = r#try!(Ok(46));
|
||||
let _ = r#try!(Ok(47));
|
||||
let _ = r#try!(Ok(48));
|
||||
let _ = r#try!(Ok(49));
|
||||
let _ = Ok(42)?;
|
||||
let _ = Ok(43)?;
|
||||
let _ = Ok(44)?;
|
||||
let _ = Ok(45)?;
|
||||
let _ = Ok(46)?;
|
||||
let _ = Ok(47)?;
|
||||
let _ = Ok(48)?;
|
||||
let _ = Ok(49)?;
|
||||
match 5 {
|
||||
5 => Ok(5),
|
||||
_ => return Err("bla"),
|
||||
|
@ -230,9 +230,9 @@ error: the function has a cognitive complexity of 1
|
||||
--> $DIR/cognitive_complexity.rs:324:1
|
||||
|
|
||||
LL | / fn try_again() -> Result<i32, &'static str> {
|
||||
LL | | let _ = r#try!(Ok(42));
|
||||
LL | | let _ = r#try!(Ok(43));
|
||||
LL | | let _ = r#try!(Ok(44));
|
||||
LL | | let _ = Ok(42)?;
|
||||
LL | | let _ = Ok(43)?;
|
||||
LL | | let _ = Ok(44)?;
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
|
@ -215,10 +215,10 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
};
|
||||
|
||||
if true {
|
||||
r#try!(Ok("foo"));
|
||||
Ok("foo")?;
|
||||
} else {
|
||||
//~ ERROR same body as `if` block
|
||||
r#try!(Ok("foo"));
|
||||
Ok("foo")?;
|
||||
}
|
||||
|
||||
if true {
|
||||
|
@ -197,7 +197,7 @@ error: this `if` has identical blocks
|
||||
LL | } else {
|
||||
| ____________^
|
||||
LL | | //~ ERROR same body as `if` block
|
||||
LL | | r#try!(Ok("foo"));
|
||||
LL | | Ok("foo")?;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
@ -206,7 +206,7 @@ note: same as this
|
||||
|
|
||||
LL | if true {
|
||||
| _____________^
|
||||
LL | | r#try!(Ok("foo"));
|
||||
LL | | Ok("foo")?;
|
||||
LL | | } else {
|
||||
| |_____^
|
||||
|
||||
|
@ -19,5 +19,5 @@ fn main() {
|
||||
#[allow(clippy::needless_return)]
|
||||
(|| return 2)();
|
||||
(|| -> Option<i32> { None? })();
|
||||
(|| -> Result<i32, i32> { r#try!(Err(2)) })();
|
||||
(|| -> Result<i32, i32> { Err(2)? })();
|
||||
}
|
||||
|
@ -3,13 +3,6 @@
|
||||
|
||||
use std::io;
|
||||
|
||||
fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
|
||||
r#try!(s.write(b"test"));
|
||||
let mut buf = [0u8; 4];
|
||||
r#try!(s.read(&mut buf));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn question_mark<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
|
||||
s.write(b"test")?;
|
||||
let mut buf = [0u8; 4];
|
||||
|
@ -1,43 +1,28 @@
|
||||
error: handle written amount returned or use `Write::write_all` instead
|
||||
--> $DIR/unused_io_amount.rs:7:5
|
||||
|
|
||||
LL | r#try!(s.write(b"test"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | s.write(b"test")?;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::unused-io-amount` implied by `-D warnings`
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: handle read amount returned or use `Read::read_exact` instead
|
||||
--> $DIR/unused_io_amount.rs:9:5
|
||||
|
|
||||
LL | r#try!(s.read(&mut buf));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: handle written amount returned or use `Write::write_all` instead
|
||||
--> $DIR/unused_io_amount.rs:14:5
|
||||
|
|
||||
LL | s.write(b"test")?;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: handle read amount returned or use `Read::read_exact` instead
|
||||
--> $DIR/unused_io_amount.rs:16:5
|
||||
|
|
||||
LL | s.read(&mut buf)?;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: handle written amount returned or use `Write::write_all` instead
|
||||
--> $DIR/unused_io_amount.rs:21:5
|
||||
--> $DIR/unused_io_amount.rs:14:5
|
||||
|
|
||||
LL | s.write(b"test").unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: handle read amount returned or use `Read::read_exact` instead
|
||||
--> $DIR/unused_io_amount.rs:23:5
|
||||
--> $DIR/unused_io_amount.rs:16:5
|
||||
|
|
||||
LL | s.read(&mut buf).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user