Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,16 +1622,8 @@ impl<'a> Parser<'a> {
let first_expr = self.parse_expr()?;
if self.eat(exp!(Semi)) {
// Repeating array syntax: `[ 0; 512 ]`
let count = if self.eat_keyword(exp!(Const)) {
// While we could just disambiguate `Direct` from `AnonConst` by
// treating all const block exprs as `AnonConst`, that would
// complicate the DefCollector and likely all other visitors.
// So we strip the const blockiness and just store it as a block
// in the AST with the extra disambiguator on the AnonConst
self.parse_mgca_const_block(false)?
} else {
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?
};
let count =
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;
self.expect(close)?;
ExprKind::Repeat(first_expr, count)
} else if self.eat(exp!(Comma)) {
Expand Down
12 changes: 2 additions & 10 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,16 +658,8 @@ impl<'a> Parser<'a> {
};

let ty = if self.eat(exp!(Semi)) {
let mut length = if self.eat_keyword(exp!(Const)) {
// While we could just disambiguate `Direct` from `AnonConst` by
// treating all const block exprs as `AnonConst`, that would
// complicate the DefCollector and likely all other visitors.
// So we strip the const blockiness and just store it as a block
// in the AST with the extra disambiguator on the AnonConst
self.parse_mgca_const_block(false)?
} else {
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?
};
let mut length =
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;

if let Err(e) = self.expect(exp!(CloseBracket)) {
// Try to recover from `X<Y, ...>` when `X::<Y, ...>` works
Expand Down
7 changes: 7 additions & 0 deletions src/tools/rustfmt/tests/source/issue-6788.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn foo() {
let a = [(); const { let x = 1; x }];
}

fn foo() {
let x = [(); const { 1 }];
}
10 changes: 10 additions & 0 deletions src/tools/rustfmt/tests/target/issue-6788.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn foo() {
let a = [(); const {
let x = 1;
x
}];
}

fn foo() {
let x = [(); const { 1 }];
}
73 changes: 0 additions & 73 deletions tests/ui/const-generics/mgca/explicit_anon_consts.rs

This file was deleted.

80 changes: 0 additions & 80 deletions tests/ui/const-generics/mgca/explicit_anon_consts.stderr

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/const-generics/mgca/selftyalias-containing-param.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/ui/const-generics/mgca/selftyalias-containing-param.stderr

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ui/const-generics/mgca/selftyparam.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/const-generics/mgca/selftyparam.stderr

This file was deleted.

26 changes: 0 additions & 26 deletions tests/ui/const-generics/mgca/type_const-array-return.rs

This file was deleted.

Loading