Skip to content

Commit

Permalink
rv 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 1, 2022
1 parent 6d7a773 commit e66eeba
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
5 changes: 2 additions & 3 deletions tests/ui/assertions_on_result_states.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::uninlined_format_args)]

use std::result::Result;

Expand Down Expand Up @@ -47,10 +46,10 @@ fn main() {

// test ok that shouldn't be moved
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
fn test_ref_unmovable_ok(r: &Result<CopyFoo, DebugFoo>) {
fn test_ref_unmoveable_ok(r: &Result<CopyFoo, DebugFoo>) {
assert!(r.is_ok());
}
test_ref_unmovable_ok(&r);
test_ref_unmoveable_ok(&r);
assert!(r.is_ok());
r.unwrap();

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/assertions_on_result_states.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::uninlined_format_args)]

use std::result::Result;

Expand Down Expand Up @@ -47,10 +46,10 @@ fn main() {

// test ok that shouldn't be moved
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
fn test_ref_unmovable_ok(r: &Result<CopyFoo, DebugFoo>) {
fn test_ref_unmoveable_ok(r: &Result<CopyFoo, DebugFoo>) {
assert!(r.is_ok());
}
test_ref_unmovable_ok(&r);
test_ref_unmoveable_ok(&r);
assert!(r.is_ok());
r.unwrap();

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/assertions_on_result_states.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:25:5
--> $DIR/assertions_on_result_states.rs:24:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
|
= note: `-D clippy::assertions-on-result-states` implied by `-D warnings`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:43:5
--> $DIR/assertions_on_result_states.rs:42:5
|
LL | assert!(get_ok().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:46:5
--> $DIR/assertions_on_result_states.rs:45:5
|
LL | assert!(get_ok_macro!().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:59:5
--> $DIR/assertions_on_result_states.rs:58:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:65:9
--> $DIR/assertions_on_result_states.rs:64:9
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:73:5
--> $DIR/assertions_on_result_states.rs:72:5
|
LL | assert!(r.is_err());
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:83:5
--> $DIR/assertions_on_result_states.rs:82:5
|
LL | assert!(res.is_err())
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/branches_sharing_code/shared_at_bottom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ fn simple_examples() {
let start_value = 0;
println!("=^.^=");

// Same but not movable due to `start_value`
// Same but not moveable due to `start_value`
let _ = start_value;

// The rest is self contained and movable => Only lint the rest
// The rest is self contained and moveable => Only lint the rest
let result = false;
println!("Block end!");
result
Expand All @@ -24,10 +24,10 @@ fn simple_examples() {
let start_value = 8;
println!("xD");

// Same but not movable due to `start_value`
// Same but not moveable due to `start_value`
let _ = start_value;

// The rest is self contained and movable => Only lint the rest
// The rest is self contained and moveable => Only lint the rest
let result = false;
println!("Block end!");
result
Expand Down Expand Up @@ -56,15 +56,15 @@ fn simple_examples() {
println!("I'm a local because I use the value `z`: `{}`", z);

println!(
"I'm movable because I know: `outer_scope_value`: '{}'",
"I'm moveable because I know: `outer_scope_value`: '{}'",
outer_scope_value
);
} else {
let z = 45678000;
println!("I'm a local because I use the value `z`: `{}`", z);

println!(
"I'm movable because I know: `outer_scope_value`: '{}'",
"I'm moveable because I know: `outer_scope_value`: '{}'",
outer_scope_value
);
}
Expand Down Expand Up @@ -111,7 +111,7 @@ fn simple_but_suggestion_is_invalid() {
}

/// Tests where the blocks are not linted due to the used value scope
fn not_movable_due_to_value_scope() {
fn not_moveable_due_to_value_scope() {
let x = 18;

// Using a local value in the moved code
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/branches_sharing_code/shared_at_bottom.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ error: all if blocks contain the same code at the end
--> $DIR/shared_at_bottom.rs:66:5
|
LL | / println!(
LL | | "I'm movable because I know: `outer_scope_value`: '{}'",
LL | | "I'm moveable because I know: `outer_scope_value`: '{}'",
LL | | outer_scope_value
LL | | );
LL | | }
Expand All @@ -48,7 +48,7 @@ help: consider moving these statements after the if
|
LL ~ }
LL + println!(
LL + "I'm movable because I know: `outer_scope_value`: '{}'",
LL + "I'm moveable because I know: `outer_scope_value`: '{}'",
LL + outer_scope_value
LL + );
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/branches_sharing_code/shared_at_top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ fn simple_but_suggestion_is_invalid() {
let _ = can_be_overridden;
if x == 11 {
let can_be_overridden = "Move me";
println!("I'm also movable");
println!("I'm also moveable");
let _ = 111;
} else {
let can_be_overridden = "Move me";
println!("I'm also movable");
println!("I'm also moveable");
let _ = 222;
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/branches_sharing_code/shared_at_top.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ error: all if blocks contain the same code at the start
|
LL | / if x == 11 {
LL | | let can_be_overridden = "Move me";
LL | | println!("I'm also movable");
| |_____________________________________^
LL | | println!("I'm also moveable");
| |______________________________________^
|
= warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
|
LL ~ let can_be_overridden = "Move me";
LL + println!("I'm also movable");
LL + println!("I'm also moveable");
LL + if x == 11 {
|

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/empty_line_after_outer_attribute.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// aux-build:proc_macro_attr.rs
#![warn(clippy::empty_line_after_outer_attr)]
#![allow(clippy::assertions_on_constants)]
#![feature(custom_inner_attributes)]
#![rustfmt::skip]
#![warn(clippy::empty_line_after_outer_attr)]
#![allow(clippy::assertions_on_constants, clippy::uninlined_format_args)]

#[macro_use]
extern crate proc_macro_attr;
Expand Down

0 comments on commit e66eeba

Please sign in to comment.