Skip to content

Commit e1d573c

Browse files
committed
try macro is deprecated now, so Clippy will drop the support for it also
1 parent 9533fa5 commit e1d573c

7 files changed

+21
-43
lines changed

tests/ui/cognitive_complexity.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ fn try_() -> Result<i32, &'static str> {
322322

323323
#[clippy::cognitive_complexity = "0"]
324324
fn try_again() -> Result<i32, &'static str> {
325-
let _ = r#try!(Ok(42));
326-
let _ = r#try!(Ok(43));
327-
let _ = r#try!(Ok(44));
328-
let _ = r#try!(Ok(45));
329-
let _ = r#try!(Ok(46));
330-
let _ = r#try!(Ok(47));
331-
let _ = r#try!(Ok(48));
332-
let _ = r#try!(Ok(49));
325+
let _ = Ok(42)?;
326+
let _ = Ok(43)?;
327+
let _ = Ok(44)?;
328+
let _ = Ok(45)?;
329+
let _ = Ok(46)?;
330+
let _ = Ok(47)?;
331+
let _ = Ok(48)?;
332+
let _ = Ok(49)?;
333333
match 5 {
334334
5 => Ok(5),
335335
_ => return Err("bla"),

tests/ui/cognitive_complexity.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ error: the function has a cognitive complexity of 1
230230
--> $DIR/cognitive_complexity.rs:324:1
231231
|
232232
LL | / fn try_again() -> Result<i32, &'static str> {
233-
LL | | let _ = r#try!(Ok(42));
234-
LL | | let _ = r#try!(Ok(43));
235-
LL | | let _ = r#try!(Ok(44));
233+
LL | | let _ = Ok(42)?;
234+
LL | | let _ = Ok(43)?;
235+
LL | | let _ = Ok(44)?;
236236
... |
237237
LL | | }
238238
LL | | }

tests/ui/if_same_then_else.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ fn if_same_then_else() -> Result<&'static str, ()> {
215215
};
216216

217217
if true {
218-
r#try!(Ok("foo"));
218+
Ok("foo")?;
219219
} else {
220220
//~ ERROR same body as `if` block
221-
r#try!(Ok("foo"));
221+
Ok("foo")?;
222222
}
223223

224224
if true {

tests/ui/if_same_then_else.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ error: this `if` has identical blocks
197197
LL | } else {
198198
| ____________^
199199
LL | | //~ ERROR same body as `if` block
200-
LL | | r#try!(Ok("foo"));
200+
LL | | Ok("foo")?;
201201
LL | | }
202202
| |_____^
203203
|
@@ -206,7 +206,7 @@ note: same as this
206206
|
207207
LL | if true {
208208
| _____________^
209-
LL | | r#try!(Ok("foo"));
209+
LL | | Ok("foo")?;
210210
LL | | } else {
211211
| |_____^
212212

tests/ui/redundant_closure_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ fn main() {
1919
#[allow(clippy::needless_return)]
2020
(|| return 2)();
2121
(|| -> Option<i32> { None? })();
22-
(|| -> Result<i32, i32> { r#try!(Err(2)) })();
22+
(|| -> Result<i32, i32> { Err(2)? })();
2323
}

tests/ui/unused_io_amount.rs

-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33

44
use std::io;
55

6-
fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
7-
r#try!(s.write(b"test"));
8-
let mut buf = [0u8; 4];
9-
r#try!(s.read(&mut buf));
10-
Ok(())
11-
}
12-
136
fn question_mark<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
147
s.write(b"test")?;
158
let mut buf = [0u8; 4];

tests/ui/unused_io_amount.stderr

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
11
error: handle written amount returned or use `Write::write_all` instead
22
--> $DIR/unused_io_amount.rs:7:5
33
|
4-
LL | r#try!(s.write(b"test"));
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | s.write(b"test")?;
5+
| ^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::unused-io-amount` implied by `-D warnings`
8-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
98

109
error: handle read amount returned or use `Read::read_exact` instead
1110
--> $DIR/unused_io_amount.rs:9:5
1211
|
13-
LL | r#try!(s.read(&mut buf));
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15-
|
16-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
17-
18-
error: handle written amount returned or use `Write::write_all` instead
19-
--> $DIR/unused_io_amount.rs:14:5
20-
|
21-
LL | s.write(b"test")?;
22-
| ^^^^^^^^^^^^^^^^^
23-
24-
error: handle read amount returned or use `Read::read_exact` instead
25-
--> $DIR/unused_io_amount.rs:16:5
26-
|
2712
LL | s.read(&mut buf)?;
2813
| ^^^^^^^^^^^^^^^^^
2914

3015
error: handle written amount returned or use `Write::write_all` instead
31-
--> $DIR/unused_io_amount.rs:21:5
16+
--> $DIR/unused_io_amount.rs:14:5
3217
|
3318
LL | s.write(b"test").unwrap();
3419
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3520

3621
error: handle read amount returned or use `Read::read_exact` instead
37-
--> $DIR/unused_io_amount.rs:23:5
22+
--> $DIR/unused_io_amount.rs:16:5
3823
|
3924
LL | s.read(&mut buf).unwrap();
4025
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4126

42-
error: aborting due to 6 previous errors
27+
error: aborting due to 4 previous errors
4328

0 commit comments

Comments
 (0)