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.
Rollup merge of rust-lang#82789 - csmoe:issue-82772, r=estebank
Get with field index from pattern slice instead of directly indexing Closes rust-lang#82772 r? `@estebank` rust-lang#82789 (comment) > `@estebank` So the real cause is we only generate single pattern for Box here https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1130-L1132 But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds. https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1346
- Loading branch information
Showing
7 changed files
with
44 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// edition:2018 | ||
|
||
fn main() { | ||
use a::ModPrivateStruct; | ||
let Box { 0: _, .. }: Box<()>; //~ ERROR field `0` of | ||
let Box { 1: _, .. }: Box<()>; //~ ERROR field `1` of | ||
let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); //~ ERROR field `1` of | ||
} | ||
|
||
mod a { | ||
#[derive(Default)] | ||
pub struct ModPrivateStruct(u8, u8); | ||
} |
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[E0451]: field `0` of struct `Box` is private | ||
--> $DIR/issue-82772.rs:5:15 | ||
| | ||
LL | let Box { 0: _, .. }: Box<()>; | ||
| ^^^^ private field | ||
|
||
error[E0451]: field `1` of struct `Box` is private | ||
--> $DIR/issue-82772.rs:6:15 | ||
| | ||
LL | let Box { 1: _, .. }: Box<()>; | ||
| ^^^^ private field | ||
|
||
error[E0451]: field `1` of struct `ModPrivateStruct` is private | ||
--> $DIR/issue-82772.rs:7:28 | ||
| | ||
LL | let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); | ||
| ^^^^ private field | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0451`. |