forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#105476 - estebank:moves-n-borrows, r=compil…
…er-errors Change pattern borrowing suggestions to be verbose and remove invalid suggestion Synthesize a more accurate span and use verbose suggestion output to make the message clearer. Do not suggest borrowing binding in pattern in let else. Fix rust-lang#104838.
- Loading branch information
Showing
73 changed files
with
1,842 additions
and
816 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
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
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,12 @@ | ||
// run-rustfix | ||
fn main() { | ||
|
||
let x: Option<Box<_>> = Some(Box::new(1)); | ||
|
||
match x { | ||
Some(ref y) => { | ||
let _b = y; //~ ERROR cannot move out | ||
} | ||
_ => {} | ||
} | ||
} |
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,3 +1,4 @@ | ||
// run-rustfix | ||
fn main() { | ||
|
||
let x: Option<Box<_>> = Some(Box::new(1)); | ||
|
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,56 @@ | ||
// run-rustfix | ||
#![allow(unused)] | ||
enum Foo { | ||
Foo1(Box<u32>, Box<u32>), | ||
Foo2(Box<u32>), | ||
Foo3, | ||
} | ||
|
||
|
||
|
||
fn blah() { | ||
let f = &Foo::Foo1(Box::new(1), Box::new(2)); | ||
match f { //~ ERROR cannot move out of | ||
Foo::Foo1(num1, | ||
num2) => (), | ||
Foo::Foo2(num) => (), | ||
Foo::Foo3 => () | ||
} | ||
} | ||
|
||
struct S { | ||
f: String, | ||
g: String | ||
} | ||
impl Drop for S { | ||
fn drop(&mut self) { println!("{}", self.f); } | ||
} | ||
|
||
fn move_in_match() { | ||
match (S {f: "foo".to_string(), g: "bar".to_string()}) { | ||
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait | ||
S { | ||
f: ref _s, | ||
g: ref _t | ||
} => {} | ||
} | ||
} | ||
|
||
// from issue-8064 | ||
struct A { | ||
a: Box<isize>, | ||
} | ||
|
||
fn free<T>(_: T) {} | ||
|
||
fn blah2() { | ||
let a = &A { a: Box::new(1) }; | ||
match &a.a { //~ ERROR cannot move out of | ||
n => { | ||
free(n) | ||
} | ||
} | ||
free(a) | ||
} | ||
|
||
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// run-rustfix | ||
#![allow(unused)] | ||
enum Foo { | ||
Foo1(Box<u32>, Box<u32>), | ||
Foo2(Box<u32>), | ||
|
Oops, something went wrong.