mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Rollup merge of #78118 - spastorino:inline-const-followups, r=petrochenkov
Inline const followups r? @petrochenkov Follow ups of #77124
This commit is contained in:
commit
de24210ebf
@ -1138,9 +1138,7 @@ impl<'a> State<'a> {
|
||||
fn print_expr_anon_const(&mut self, anon_const: &hir::AnonConst) {
|
||||
self.ibox(INDENT_UNIT);
|
||||
self.s.word_space("const");
|
||||
self.s.word("{");
|
||||
self.print_anon_const(anon_const);
|
||||
self.s.word("}");
|
||||
self.end()
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,11 @@ impl<'a> Parser<'a> {
|
||||
|
||||
fn check_inline_const(&mut self) -> bool {
|
||||
self.check_keyword(kw::Const)
|
||||
&& self.look_ahead(1, |t| t == &token::OpenDelim(DelimToken::Brace))
|
||||
&& self.look_ahead(1, |t| match t.kind {
|
||||
token::Interpolated(ref nt) => matches!(**nt, token::NtBlock(..)),
|
||||
token::OpenDelim(DelimToken::Brace) => true,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
/// Checks to see if the next token is either `+` or `+=`.
|
||||
|
12
src/test/ui/inline-const/const-expr-macro.rs
Normal file
12
src/test/ui/inline-const/const-expr-macro.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(inline_const)]
|
||||
macro_rules! do_const_block{
|
||||
($val:block) => { const $val }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = do_const_block!({ 22 });
|
||||
assert_eq!(s, 22);
|
||||
}
|
Loading…
Reference in New Issue
Block a user