-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #61147 - estebank:suggest-as-ref, r=oli-obk
- Loading branch information
Showing
4 changed files
with
189 additions
and
77 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
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,39 @@ | ||
//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 selection.1.as_ref().unwrap().contains(selection.0) { | ||
//~^ ERROR cannot move out of borrowed content | ||
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 selection.1.as_ref().unwrap().contains(selection.0) { | ||
//~^ ERROR cannot move out of borrowed content | ||
return Err(selection.0); | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn main() {} |
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,39 @@ | ||
//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 selection.1.unwrap().contains(selection.0) { | ||
//~^ ERROR cannot move out of borrowed content | ||
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 selection.1.unwrap().contains(selection.0) { | ||
//~^ ERROR cannot move out of borrowed content | ||
return Err(selection.0); | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn main() {} |
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,21 @@ | ||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/option-content-move.rs:11:20 | ||
| | ||
LL | if selection.1.unwrap().contains(selection.0) { | ||
| ^^^^^^^^^^^ | ||
| | | ||
| cannot move out of borrowed content | ||
| help: consider borrowing the `Option`'s content: `selection.1.as_ref()` | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/option-content-move.rs:29:20 | ||
| | ||
LL | if selection.1.unwrap().contains(selection.0) { | ||
| ^^^^^^^^^^^ | ||
| | | ||
| cannot move out of borrowed content | ||
| help: consider borrowing the `Result`'s content: `selection.1.as_ref()` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0507`. |