Skip to content

Commit de24210

Browse files
authored
Rollup merge of rust-lang#78118 - spastorino:inline-const-followups, r=petrochenkov
Inline const followups r? @petrochenkov Follow ups of rust-lang#77124
2 parents 83f126b + dcd2d91 commit de24210

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Diff for: compiler/rustc_hir_pretty/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,7 @@ impl<'a> State<'a> {
11381138
fn print_expr_anon_const(&mut self, anon_const: &hir::AnonConst) {
11391139
self.ibox(INDENT_UNIT);
11401140
self.s.word_space("const");
1141-
self.s.word("{");
11421141
self.print_anon_const(anon_const);
1143-
self.s.word("}");
11441142
self.end()
11451143
}
11461144

Diff for: compiler/rustc_parse/src/parser/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@ impl<'a> Parser<'a> {
548548

549549
fn check_inline_const(&mut self) -> bool {
550550
self.check_keyword(kw::Const)
551-
&& self.look_ahead(1, |t| t == &token::OpenDelim(DelimToken::Brace))
551+
&& self.look_ahead(1, |t| match t.kind {
552+
token::Interpolated(ref nt) => matches!(**nt, token::NtBlock(..)),
553+
token::OpenDelim(DelimToken::Brace) => true,
554+
_ => false,
555+
})
552556
}
553557

554558
/// Checks to see if the next token is either `+` or `+=`.

Diff for: src/test/ui/inline-const/const-expr-macro.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(inline_const)]
5+
macro_rules! do_const_block{
6+
($val:block) => { const $val }
7+
}
8+
9+
fn main() {
10+
let s = do_const_block!({ 22 });
11+
assert_eq!(s, 22);
12+
}

0 commit comments

Comments
 (0)