mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
fix: Stop wrapping ConstParam's default values in ConstArg
This was causing ConstParam::default_val to always return None for block expressions. CONST_ARG@24..29 BLOCK_EXPR@24..29 ...
This commit is contained in:
parent
224a255c5a
commit
972f50da2d
8 changed files with 82 additions and 50 deletions
|
@ -72,28 +72,24 @@ fn lifetime_arg(p: &mut Parser) {
|
|||
m.complete(p, LIFETIME_ARG);
|
||||
}
|
||||
|
||||
// test const_arg
|
||||
// type T = S<92>;
|
||||
pub(super) fn const_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
pub(super) fn const_arg_content(p: &mut Parser) {
|
||||
// The tests in here are really for `const_arg`, which wraps the content
|
||||
// CONST_ARG.
|
||||
match p.current() {
|
||||
// test const_arg_block
|
||||
// type T = S<{90 + 2}>;
|
||||
T!['{'] => {
|
||||
expressions::block_expr(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
// test const_arg_literal
|
||||
// type T = S<"hello", 0xdeadbeef>;
|
||||
k if k.is_literal() => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
// test const_arg_bool_literal
|
||||
// type T = S<true>;
|
||||
T![true] | T![false] => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
// test const_arg_negative_number
|
||||
// type T = S<-92>;
|
||||
|
@ -102,19 +98,25 @@ pub(super) fn const_arg(p: &mut Parser) {
|
|||
p.bump(T![-]);
|
||||
expressions::literal(p);
|
||||
lm.complete(p, PREFIX_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
// test const_arg_path
|
||||
// struct S<const N: u32 = u32::MAX>;
|
||||
// type T = S<u32::MAX>;
|
||||
_ => {
|
||||
let lm = p.start();
|
||||
paths::use_path(p);
|
||||
lm.complete(p, PATH_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test const_arg
|
||||
// type T = S<92>;
|
||||
pub(super) fn const_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
const_arg_content(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
|
||||
fn type_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
types::type_(p);
|
||||
|
|
|
@ -79,10 +79,13 @@ fn const_param(p: &mut Parser, m: Marker) {
|
|||
}
|
||||
|
||||
if p.at(T![=]) {
|
||||
// test const_param_defaults
|
||||
// test const_param_default_literal
|
||||
// struct A<const N: i32 = -1>;
|
||||
p.bump(T![=]);
|
||||
generic_args::const_arg(p);
|
||||
|
||||
// test const_param_default_expression
|
||||
// struct A<const N: i32 = { 1 }>;
|
||||
generic_args::const_arg_content(p);
|
||||
}
|
||||
|
||||
m.complete(p, CONST_PARAM);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue