mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
When checking for forbidden expr kind matches, account for rawness
An expression starting with `r#const` etc. should be accepted even in edition <=2021.
This commit is contained in:
parent
6dad8c5528
commit
5c06f047b9
2 changed files with 25 additions and 1 deletions
|
@ -1144,3 +1144,27 @@ mod any {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_18148() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m {
|
||||
( $e:expr ) => {};
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
m!(r#const);
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! m {
|
||||
( $e:expr ) => {};
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
;
|
||||
}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -780,7 +780,7 @@ fn match_meta_var(
|
|||
// [1]: https://github.com/rust-lang/rust/blob/f0c4da499/compiler/rustc_expand/src/mbe/macro_parser.rs#L576
|
||||
match input.peek_n(0) {
|
||||
Some(tt::TokenTree::Leaf(tt::Leaf::Ident(it))) => {
|
||||
let is_err = if matches!(expr, ExprKind::Expr2021) {
|
||||
let is_err = if it.is_raw.no() && matches!(expr, ExprKind::Expr2021) {
|
||||
it.sym == sym::underscore || it.sym == sym::let_ || it.sym == sym::const_
|
||||
} else {
|
||||
it.sym == sym::let_
|
||||
|
|
Loading…
Reference in a new issue