forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#124386 - matthiaskrgr:rollup-0a6yr00, r=matth…
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#124313 (Detect borrow error involving sub-slices and suggest `split_at_mut`) - rust-lang#124374 (Don't ICE when `codegen_select_candidate` returns ambiguity in new solver) - rust-lang#124380 (`Range` iteration specialization: remove trivial bounds) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
9 changed files
with
264 additions
and
55 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
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 |
---|---|---|
@@ -1,8 +1,62 @@ | ||
fn main() { | ||
fn foo() { | ||
let mut foo = [1, 2, 3, 4]; | ||
let a = &mut foo[2]; | ||
let b = &mut foo[3]; //~ ERROR cannot borrow `foo[_]` as mutable more than once at a time | ||
*a = 5; | ||
*b = 6; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn bar() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &mut foo[..2]; | ||
let b = &mut foo[2..]; //~ ERROR cannot borrow `foo` as mutable more than once at a time | ||
a[0] = 5; | ||
b[0] = 6; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn baz() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &foo[..2]; | ||
let b = &mut foo[2..]; //~ ERROR cannot borrow `foo` as mutable because it is also borrowed as immutable | ||
b[0] = 6; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn qux() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &mut foo[..2]; | ||
let b = &foo[2..]; //~ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable | ||
a[0] = 5; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn bad() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &foo[1]; | ||
let b = &mut foo[2]; //~ ERROR cannot borrow `foo[_]` as mutable because it is also borrowed as immutable | ||
*b = 6; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn bat() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &mut foo[1]; | ||
let b = &foo[2]; //~ ERROR cannot borrow `foo[_]` as immutable because it is also borrowed as mutable | ||
*a = 5; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn ang() { | ||
let mut foo = [1,2,3,4]; | ||
let a = &mut foo[0..]; | ||
let b = &foo[0..]; //~ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable | ||
a[0] = 5; | ||
println!("{:?} {:?}", a, b); | ||
} | ||
|
||
fn main() { | ||
foo(); | ||
bar(); | ||
} |
Oops, something went wrong.