File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ fn or_fun_call() {
7070 let opt = Some(1);
7171 let hello = "Hello";
7272 let _ = opt.ok_or(format!("{} world.", hello));
73+
74+ // index
75+ let map = HashMap::<u64, u64>::new();
76+ let _ = Some(1).unwrap_or_else(|| map[&1]);
7377}
7478
7579struct Foo(u8);
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ fn or_fun_call() {
7070 let opt = Some ( 1 ) ;
7171 let hello = "Hello" ;
7272 let _ = opt. ok_or ( format ! ( "{} world." , hello) ) ;
73+
74+ // index
75+ let map = HashMap :: < u64 , u64 > :: new ( ) ;
76+ let _ = Some ( 1 ) . unwrap_or ( map[ & 1 ] ) ;
7377}
7478
7579struct Foo ( u8 ) ;
Original file line number Diff line number Diff line change @@ -78,17 +78,23 @@ error: use of `unwrap_or` followed by a function call
7878LL | let _ = stringy.unwrap_or("".to_owned());
7979 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
8080
81+ error: use of `unwrap_or` followed by a function call
82+ --> $DIR/or_fun_call.rs:76:21
83+ |
84+ LL | let _ = Some(1).unwrap_or(map[&1]);
85+ | ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`
86+
8187error: use of `or` followed by a function call
82- --> $DIR/or_fun_call.rs:93 :35
88+ --> $DIR/or_fun_call.rs:97 :35
8389 |
8490LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
8591 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
8692
8793error: use of `or` followed by a function call
88- --> $DIR/or_fun_call.rs:97 :10
94+ --> $DIR/or_fun_call.rs:101 :10
8995 |
9096LL | .or(Some(Bar(b, Duration::from_secs(2))));
9197 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`
9298
93- error: aborting due to 15 previous errors
99+ error: aborting due to 16 previous errors
94100
You can’t perform that action at this time.
0 commit comments