Skip to content

Commit 400ee06

Browse files
committed
Auto merge of #3846 - mikerite:fix-3839, r=phansch
Ensure `expect_fun_call` bad suggestion is fixed Closes #3839
2 parents a8f61e7 + 464ed58 commit 400ee06

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

tests/ui/expect_fun_call.fixed

+3
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@ fn main() {
8181
Some("foo").unwrap_or_else(|| { panic!(get_static_str()) });
8282
Some("foo").unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) });
8383
}
84+
85+
//Issue #3839
86+
Some(true).unwrap_or_else(|| panic!("key {}, {}", 1, 2));
8487
}

tests/ui/expect_fun_call.rs

+3
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@ fn main() {
8181
Some("foo").expect(get_static_str());
8282
Some("foo").expect(get_non_static_str(&0));
8383
}
84+
85+
//Issue #3839
86+
Some(true).expect(&format!("key {}, {}", 1, 2));
8487
}

tests/ui/expect_fun_call.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,11 @@ error: use of `expect` followed by a function call
6060
LL | Some("foo").expect(get_non_static_str(&0));
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) })`
6262

63-
error: aborting due to 10 previous errors
63+
error: use of `expect` followed by a function call
64+
--> $DIR/expect_fun_call.rs:86:16
65+
|
66+
LL | Some(true).expect(&format!("key {}, {}", 1, 2));
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))`
68+
69+
error: aborting due to 11 previous errors
6470

0 commit comments

Comments
 (0)