Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mark more tests as run-rustfix
  • Loading branch information
estebank committed Dec 4, 2023
commit 1c69c6ab0890a8a4df947e41102dc667d668718e
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// run-rustfix
use std::rc::Rc;

pub fn main() {
let _x = <Vec<i32> as Clone>::clone(&Rc::new(vec![1, 2])).into_iter();
//~^ ERROR [E0507]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// run-rustfix
use std::rc::Rc;

pub fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14
--> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:5:14
|
LL | let _x = Rc::new(vec![1, 2]).into_iter();
| ^^^^^^^^^^^^^^^^^^^ ----------- value moved due to this method call
Expand Down
38 changes: 38 additions & 0 deletions tests/ui/suggestions/option-content-move.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// run-rustfix
pub struct LipogramCorpora {
selections: Vec<(char, Option<String>)>,
}

impl LipogramCorpora {
pub fn validate_all(&mut self) -> Result<(), char> {
for selection in &self.selections {
if selection.1.is_some() {
if <Option<String> as Clone>::clone(&selection.1).unwrap().contains(selection.0) {
//~^ ERROR cannot move out of `selection.1`
return Err(selection.0);
}
}
}
Ok(())
}
}

pub struct LipogramCorpora2 {
selections: Vec<(char, Result<String, String>)>,
}

impl LipogramCorpora2 {
pub fn validate_all(&mut self) -> Result<(), char> {
for selection in &self.selections {
if selection.1.is_ok() {
if <Result<String, String> as Clone>::clone(&selection.1).unwrap().contains(selection.0) {
//~^ ERROR cannot move out of `selection.1`
return Err(selection.0);
}
}
}
Ok(())
}
}

fn main() {}
1 change: 1 addition & 0 deletions tests/ui/suggestions/option-content-move.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// run-rustfix
pub struct LipogramCorpora {
selections: Vec<(char, Option<String>)>,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/suggestions/option-content-move.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of `selection.1` which is behind a shared reference
--> $DIR/option-content-move.rs:9:20
--> $DIR/option-content-move.rs:10:20
|
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
Expand All @@ -15,7 +15,7 @@ LL | if <Option<String> as Clone>::clone(&selection.1).unwrap().
| ++++++++++++++++++++++++++++++++++ +

error[E0507]: cannot move out of `selection.1` which is behind a shared reference
--> $DIR/option-content-move.rs:27:20
--> $DIR/option-content-move.rs:28:20
|
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
Expand Down