diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-05-24 19:30:25 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-05-25 11:12:41 -0700 |
| commit | 1cc42ea6750affbef2bca699bde30ac321e15939 (patch) | |
| tree | 8cb9303cd2ab5f669fcfee45293030b57ca8cabe /src/test | |
| parent | 4b0963653ef2479333d7b37843633fb5d5902f03 (diff) | |
| download | rust-1cc42ea6750affbef2bca699bde30ac321e15939.tar.gz rust-1cc42ea6750affbef2bca699bde30ac321e15939.zip | |
Add support for suggesting as_ref to Result accesses
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/suggestions/option-content-move.fixed | 18 | ||||
| -rw-r--r-- | src/test/ui/suggestions/option-content-move.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/suggestions/option-content-move.stderr | 11 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/test/ui/suggestions/option-content-move.fixed b/src/test/ui/suggestions/option-content-move.fixed index 7113de9f414..f163cd104ff 100644 --- a/src/test/ui/suggestions/option-content-move.fixed +++ b/src/test/ui/suggestions/option-content-move.fixed @@ -18,4 +18,22 @@ impl LipogramCorpora { } } +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() {} diff --git a/src/test/ui/suggestions/option-content-move.rs b/src/test/ui/suggestions/option-content-move.rs index 5a38376ffa6..350486a802d 100644 --- a/src/test/ui/suggestions/option-content-move.rs +++ b/src/test/ui/suggestions/option-content-move.rs @@ -18,4 +18,22 @@ impl LipogramCorpora { } } +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() {} diff --git a/src/test/ui/suggestions/option-content-move.stderr b/src/test/ui/suggestions/option-content-move.stderr index 7f019c3b5b9..0a325ac54ea 100644 --- a/src/test/ui/suggestions/option-content-move.stderr +++ b/src/test/ui/suggestions/option-content-move.stderr @@ -7,6 +7,15 @@ 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: aborting due to previous error +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`. |
