-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
review comments and make test
run-rustfix
- Loading branch information
Showing
4 changed files
with
100 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//@ run-rustfix | ||
#![deny(unused_assignments, unused_variables)] | ||
struct Object; | ||
|
||
fn change_object(object: &mut Object) { //~ HELP you might have meant to mutate | ||
let object2 = Object; | ||
*object = object2; //~ ERROR mismatched types | ||
} | ||
|
||
fn change_object2(object: &mut Object) { //~ ERROR variable `object` is assigned to, but never used | ||
//~^ HELP you might have meant to mutate | ||
let object2 = Object; | ||
*object = object2; | ||
//~^ ERROR `object2` does not live long enough | ||
//~| ERROR value assigned to `object` is never read | ||
} | ||
|
||
fn main() { | ||
let mut object = Object; | ||
change_object(&mut object); | ||
change_object2(&mut object); | ||
} |
10 changes: 6 additions & 4 deletions
10
tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
//@ run-rustfix | ||
#![deny(unused_assignments, unused_variables)] | ||
struct Object; | ||
|
||
fn change_object(mut object: &Object) { | ||
fn change_object(mut object: &Object) { //~ HELP you might have meant to mutate | ||
let object2 = Object; | ||
object = object2; //~ ERROR mismatched types | ||
} | ||
|
||
fn change_object2(mut object: &Object) { //~ ERROR variable `object` is assigned to, but never used | ||
//~^ HELP you might have meant to mutate | ||
let object2 = Object; | ||
object = &object2; | ||
//~^ ERROR `object2` does not live long enough | ||
//~| ERROR value assigned to `object` is never read | ||
} | ||
|
||
fn main() { | ||
let object = Object; | ||
change_object(&object); | ||
change_object2(&object); | ||
let mut object = Object; | ||
change_object(&mut object); | ||
change_object2(&mut object); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters