mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-24 21:05:12 +00:00
Ignore str::len() in or_fun_call lint.
This commit is contained in:
parent
aca95aac7b
commit
45e775697e
@ -91,7 +91,7 @@ pub(super) fn check<'tcx>(
|
|||||||
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
|
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
|
||||||
|
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Slice(_) | ty::Array(_, _) => return,
|
ty::Slice(_) | ty::Array(_, _) | ty::Str => return,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,9 @@ fn test_or_with_ctors() {
|
|||||||
|
|
||||||
let slice = &["foo"][..];
|
let slice = &["foo"][..];
|
||||||
let _ = opt.ok_or(slice.len());
|
let _ = opt.ok_or(slice.len());
|
||||||
|
|
||||||
|
let string = "foo";
|
||||||
|
let _ = opt.ok_or(string.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue 4514 - early return
|
// Issue 4514 - early return
|
||||||
|
@ -120,6 +120,9 @@ fn test_or_with_ctors() {
|
|||||||
|
|
||||||
let slice = &["foo"][..];
|
let slice = &["foo"][..];
|
||||||
let _ = opt.ok_or(slice.len());
|
let _ = opt.ok_or(slice.len());
|
||||||
|
|
||||||
|
let string = "foo";
|
||||||
|
let _ = opt.ok_or(string.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue 4514 - early return
|
// Issue 4514 - early return
|
||||||
|
@ -115,19 +115,19 @@ LL | .or(Some(Bar(b, Duration::from_secs(2))));
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`
|
||||||
|
|
||||||
error: use of `unwrap_or` followed by a function call
|
error: use of `unwrap_or` followed by a function call
|
||||||
--> $DIR/or_fun_call.rs:138:14
|
--> $DIR/or_fun_call.rs:141:14
|
||||||
|
|
|
|
||||||
LL | None.unwrap_or(s.as_mut_vec());
|
LL | None.unwrap_or(s.as_mut_vec());
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| s.as_mut_vec())`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| s.as_mut_vec())`
|
||||||
|
|
||||||
error: use of `unwrap_or` followed by a function call
|
error: use of `unwrap_or` followed by a function call
|
||||||
--> $DIR/or_fun_call.rs:143:14
|
--> $DIR/or_fun_call.rs:146:14
|
||||||
|
|
|
|
||||||
LL | None.unwrap_or(unsafe { s.as_mut_vec() });
|
LL | None.unwrap_or(unsafe { s.as_mut_vec() });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`
|
||||||
|
|
||||||
error: use of `unwrap_or` followed by a function call
|
error: use of `unwrap_or` followed by a function call
|
||||||
--> $DIR/or_fun_call.rs:145:14
|
--> $DIR/or_fun_call.rs:148:14
|
||||||
|
|
|
|
||||||
LL | None.unwrap_or( unsafe { s.as_mut_vec() } );
|
LL | None.unwrap_or( unsafe { s.as_mut_vec() } );
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`
|
||||||
|
Loading…
Reference in New Issue
Block a user