move expr_requires_coercion to clippy_utils & some other adjustments
This commit is contained in:
parent
a2f9861df8
commit
2a4be5365a
5 changed files with 111 additions and 86 deletions
|
|
@ -113,7 +113,16 @@ fn main() {
|
|||
}
|
||||
|
||||
// #6811
|
||||
Some(0).map(|x| vec![x]);
|
||||
match Some(0) {
|
||||
Some(x) => Some(vec![x]),
|
||||
None => None,
|
||||
};
|
||||
|
||||
// Don't lint, coercion
|
||||
let x: Option<Vec<&[u8]>> = match Some(()) {
|
||||
Some(_) => Some(vec![b"1234"]),
|
||||
None => None,
|
||||
};
|
||||
|
||||
option_env!("").map(String::from);
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,12 @@ fn main() {
|
|||
None => None,
|
||||
};
|
||||
|
||||
// Don't lint, coercion
|
||||
let x: Option<Vec<&[u8]>> = match Some(()) {
|
||||
Some(_) => Some(vec![b"1234"]),
|
||||
None => None,
|
||||
};
|
||||
|
||||
match option_env!("") {
|
||||
Some(x) => Some(String::from(x)),
|
||||
None => None,
|
||||
|
|
|
|||
|
|
@ -156,16 +156,7 @@ LL | | };
|
|||
| |_____^ help: try: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:168:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | | Some(x) => Some(vec![x]),
|
||||
LL | | None => None,
|
||||
LL | | };
|
||||
| |_____^ help: try: `Some(0).map(|x| vec![x])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:173:5
|
||||
--> tests/ui/manual_map_option.rs:179:5
|
||||
|
|
||||
LL | / match option_env!("") {
|
||||
LL | | Some(x) => Some(String::from(x)),
|
||||
|
|
@ -174,7 +165,7 @@ LL | | };
|
|||
| |_____^ help: try: `option_env!("").map(String::from)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:193:12
|
||||
--> tests/ui/manual_map_option.rs:199:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
@ -185,7 +176,7 @@ LL | | };
|
|||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> tests/ui/manual_map_option.rs:201:12
|
||||
--> tests/ui/manual_map_option.rs:207:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
@ -195,5 +186,5 @@ LL | | None
|
|||
LL | | };
|
||||
| |_____^ help: try: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue