Skip to content

Commit

Permalink
Fix missing ui tests annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 9, 2024
1 parent 49179d6 commit c3b3cb3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/ui/bind_instead_of_map.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ pub fn main() {
let x = Some(5);
// the easiest cases
let _ = x;
//~^ bind_instead_of_map
let _ = x.map(|o| o + 1);
//~^ bind_instead_of_map
// and an easy counter-example
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });

// Different type
let x: Result<u32, &str> = Ok(1);
let _ = x;
//~^ bind_instead_of_map
}

pub fn foo() -> Option<String> {
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/bind_instead_of_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ pub fn main() {
let x = Some(5);
// the easiest cases
let _ = x.and_then(Some);
//~^ bind_instead_of_map
let _ = x.and_then(|o| Some(o + 1));
//~^ bind_instead_of_map
// and an easy counter-example
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });

// Different type
let x: Result<u32, &str> = Ok(1);
let _ = x.and_then(Ok);
//~^ bind_instead_of_map
}

pub fn foo() -> Option<String> {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/bind_instead_of_map.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ LL | #![deny(clippy::bind_instead_of_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> tests/ui/bind_instead_of_map.rs:9:13
--> tests/ui/bind_instead_of_map.rs:10:13
|
LL | let _ = x.and_then(|o| Some(o + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`

error: using `Result.and_then(Ok)`, which is a no-op
--> tests/ui/bind_instead_of_map.rs:15:13
--> tests/ui/bind_instead_of_map.rs:17:13
|
LL | let _ = x.and_then(Ok);
| ^^^^^^^^^^^^^^ help: use the expression directly: `x`
Expand Down

0 comments on commit c3b3cb3

Please sign in to comment.