3 #![allow(unused_variables)]
5 fn option_unwrap_or() {
61 // cases where the none arm isn't a constant expression
62 // are not linted due to potential ownership issues
64 // ownership issue example, don't lint
66 let mut option: Option<NonCopyable> = None;
70 option = Some(NonCopyable);
76 // ownership issue example, don't lint
77 let option: Option<&str> = None;
80 None => &format!("{} {}!", "hello", "world"),
84 fn result_unwrap_or() {
86 match Ok::<i32, &str>(1) {
91 // int case, scrutinee is a binding
92 let a = Ok::<i32, &str>(1);
98 // int case, suggestion must surround with parenthesis
99 match Ok(1) as Result<i32, &str> {
105 match Ok::<i32, &str>(1) {
111 match Ok::<i32, &str>(1) {
118 match Ok::<i32, &str>(1) {
128 match Ok::<&str, &str>("Bob") {
134 match Ok::<i32, &str>(1) {
138 match Ok::<i32, &str>(1) {
143 match Ok::<i32, &str>(j) {
147 match Ok::<i32, &str>(j) {
153 // don't lint, Err value is used
154 match Ok::<&str, &str>("Alice") {
158 // could lint, but unused_variables takes care of it
159 match Ok::<&str, &str>("Alice") {