mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Auto merge of #18371 - Veykril:veykril/push-kwttrusywysp, r=Veykril
fix: Fix incorrect parsing of use bounds Fixes https://github.com/rust-lang/rust-analyzer/issues/18357
This commit is contained in:
commit
c58427ff94
11 changed files with 184 additions and 25 deletions
|
@ -144,10 +144,31 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
|
|||
LIFETIME_IDENT => lifetime(p),
|
||||
T![for] => types::for_type(p, false),
|
||||
// test precise_capturing
|
||||
// fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
|
||||
// fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T, Self> {}
|
||||
T![use] if p.nth_at(1, T![<]) => {
|
||||
p.bump_any();
|
||||
generic_param_list(p)
|
||||
let m = p.start();
|
||||
delimited(
|
||||
p,
|
||||
T![<],
|
||||
T![>],
|
||||
T![,],
|
||||
|| "expected identifier or lifetime".into(),
|
||||
TokenSet::new(&[T![Self], IDENT, LIFETIME_IDENT]),
|
||||
|p| {
|
||||
if p.at(T![Self]) {
|
||||
let m = p.start();
|
||||
p.bump(T![Self]);
|
||||
m.complete(p, NAME_REF);
|
||||
} else if p.at(LIFETIME_IDENT) {
|
||||
lifetime(p);
|
||||
} else {
|
||||
name_ref(p);
|
||||
}
|
||||
true
|
||||
},
|
||||
);
|
||||
m.complete(p, USE_BOUND_GENERIC_ARGS);
|
||||
}
|
||||
T![?] if p.nth_at(1, T![for]) => {
|
||||
// test question_for_type_trait_bound
|
||||
|
|
|
@ -312,6 +312,8 @@ pub enum SyntaxKind {
|
|||
UNDERSCORE_EXPR,
|
||||
UNION,
|
||||
USE,
|
||||
USE_BOUND_GENERIC_ARG,
|
||||
USE_BOUND_GENERIC_ARGS,
|
||||
USE_TREE,
|
||||
USE_TREE_LIST,
|
||||
VARIANT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue