File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: --test
2
+
1
3
#![ warn( clippy:: unwrap_used) ]
2
4
3
5
fn unwrap_option ( ) {
@@ -10,7 +12,13 @@ fn unwrap_result() {
10
12
let _ = res. unwrap ( ) ;
11
13
}
12
14
13
- fn main ( ) {
14
- unwrap_option ( ) ;
15
- unwrap_result ( ) ;
15
+ #[ cfg( test) ]
16
+ mod test {
17
+ #[ test]
18
+ fn test_flag ( ) {
19
+ let opt = Some ( 0 ) ;
20
+ let _ = opt. unwrap ( ) ;
21
+ }
16
22
}
23
+
24
+ fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error: used `unwrap()` on `an Option` value
2
- --> $DIR/unwrap.rs:5 :13
2
+ --> $DIR/unwrap.rs:7 :13
3
3
|
4
4
LL | let _ = opt.unwrap();
5
5
| ^^^^^^^^^^^^
@@ -8,12 +8,20 @@ LL | let _ = opt.unwrap();
8
8
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
9
9
10
10
error: used `unwrap()` on `a Result` value
11
- --> $DIR/unwrap.rs:10 :13
11
+ --> $DIR/unwrap.rs:12 :13
12
12
|
13
13
LL | let _ = res.unwrap();
14
14
| ^^^^^^^^^^^^
15
15
|
16
16
= help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message
17
17
18
- error: aborting due to 2 previous errors
18
+ error: used `unwrap()` on `an Option` value
19
+ --> $DIR/unwrap.rs:20:17
20
+ |
21
+ LL | let _ = opt.unwrap();
22
+ | ^^^^^^^^^^^^
23
+ |
24
+ = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
25
+
26
+ error: aborting due to 3 previous errors
19
27
You can’t perform that action at this time.
0 commit comments