forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the root trait predicate to determine whether to remove references
Fix rust-lang#84837.
- Loading branch information
Showing
6 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// run-rustfix | ||
fn main() { | ||
let v = &mut Vec::<i32>::new(); | ||
for _ in v {} //~ ERROR E0277 | ||
|
||
let v = &mut [1u8]; | ||
for _ in v {} //~ ERROR E0277 | ||
} |
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,8 @@ | ||
// run-rustfix | ||
fn main() { | ||
let v = &mut &mut Vec::<i32>::new(); | ||
for _ in &mut &mut v {} //~ ERROR E0277 | ||
|
||
let v = &mut &mut [1u8]; | ||
for _ in &mut v {} //~ ERROR E0277 | ||
} |
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,37 @@ | ||
error[E0277]: `Vec<i32>` is not an iterator | ||
--> $DIR/suggest-remove-refs-5.rs:4:14 | ||
| | ||
LL | for _ in &mut &mut v {} | ||
| ^^^^^^^^^^^ `Vec<i32>` is not an iterator; try calling `.into_iter()` or `.iter()` | ||
| | ||
= help: the trait `Iterator` is not implemented for `Vec<i32>` | ||
= note: required for `&mut Vec<i32>` to implement `Iterator` | ||
= note: 3 redundant requirements hidden | ||
= note: required for `&mut &mut &mut &mut Vec<i32>` to implement `Iterator` | ||
= note: required for `&mut &mut &mut &mut Vec<i32>` to implement `IntoIterator` | ||
help: consider removing 3 leading `&`-references | ||
| | ||
LL ~ let v = &mut Vec::<i32>::new(); | ||
LL ~ for _ in v {} | ||
| | ||
|
||
error[E0277]: `[u8; 1]` is not an iterator | ||
--> $DIR/suggest-remove-refs-5.rs:7:14 | ||
| | ||
LL | for _ in &mut v {} | ||
| ^^^^^^ `[u8; 1]` is not an iterator; try calling `.into_iter()` or `.iter()` | ||
| | ||
= help: the trait `Iterator` is not implemented for `[u8; 1]` | ||
= note: required for `&mut [u8; 1]` to implement `Iterator` | ||
= note: 2 redundant requirements hidden | ||
= note: required for `&mut &mut &mut [u8; 1]` to implement `Iterator` | ||
= note: required for `&mut &mut &mut [u8; 1]` to implement `IntoIterator` | ||
help: consider removing 2 leading `&`-references | ||
| | ||
LL ~ let v = &mut [1u8]; | ||
LL ~ for _ in v {} | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |