Skip to content

Commit 7bfec85

Browse files
workingjubileeCryZe
andcommitted
compiler: do not write const _: () backwards
Co-authored-by: Christopher Serr <christopher.serr@gmail.com>
1 parent c55ed32 commit 7bfec85

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a> Parser<'a> {
8888
} else if self.parse_const_block(span, false).is_ok() {
8989
err.span_label(
9090
span,
91-
"if you meant to create an anonymous const, use `const (): _ = {};` instead"
91+
"if you meant to create an anonymous const, use `const _: () = {};` instead"
9292
);
9393
} else {
9494
err.span_label(span, "expected item")

tests/ui/inline-const/expr-in-item-context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const _: () = {};
88

99
const { assert!(size_of::<u32>() <= size_of::<usize>()) };
1010
//~^ expected item, found keyword
11-
//~| if you meant to create an anonymous const
11+
//~| if you meant to create an anonymous const, use `const _: () =
1212

1313
fn main() {
1414
const { assert!(size_of::<u32>() <= size_of::<usize>()) };

tests/ui/inline-const/expr-in-item-context.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected item, found keyword `const`
22
--> $DIR/expr-in-item-context.rs:9:1
33
|
44
LL | const { assert!(size_of::<u32>() <= size_of::<usize>()) };
5-
| ^^^^^ if you meant to create an anonymous const, use `const (): _ = {};` instead
5+
| ^^^^^ if you meant to create an anonymous const, use `const _: () = {};` instead
66

77
error: aborting due to 1 previous error
88

0 commit comments

Comments
 (0)