mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
fix: Fix parsing of dyn T in generic arg on 2015 edition
This commit is contained in:
parent
2fd06545a6
commit
a049941c1a
7 changed files with 68 additions and 3 deletions
|
@ -45,7 +45,7 @@ pub(crate) const GENERIC_ARG_FIRST: TokenSet = TokenSet::new(&[
|
|||
const GENERIC_ARG_RECOVERY_SET: TokenSet = TokenSet::new(&[T![>], T![,]]);
|
||||
|
||||
// test generic_arg
|
||||
// type T = S<i32>;
|
||||
// type T = S<i32, dyn T, fn()>;
|
||||
pub(crate) fn generic_arg(p: &mut Parser<'_>) -> bool {
|
||||
match p.current() {
|
||||
LIFETIME_IDENT if !p.nth_at(1, T![+]) => lifetime_arg(p),
|
||||
|
@ -57,6 +57,9 @@ pub(crate) fn generic_arg(p: &mut Parser<'_>) -> bool {
|
|||
// type ParenthesizedArgs = Foo<Item(T), Item::(T), Item(T): Bound, Item::(T): Bound, Item(T) = Item, Item::(T) = Item>;
|
||||
// type RTN = Foo<Item(..), Item(..), Item(..): Bound, Item(..): Bound, Item(..) = Item, Item(..) = Item>;
|
||||
|
||||
// test edition_2015_dyn_prefix_inside_generic_arg 2015
|
||||
// type A = Foo<dyn T>;
|
||||
T![ident] if !p.edition().at_least_2018() && types::is_dyn_weak(p) => type_arg(p),
|
||||
// test macro_inside_generic_arg
|
||||
// type A = Foo<syn::Token![_]>;
|
||||
k if PATH_NAME_REF_KINDS.contains(k) => {
|
||||
|
|
|
@ -58,7 +58,7 @@ fn type_with_bounds_cond(p: &mut Parser<'_>, allow_bounds: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_dyn_weak(p: &Parser<'_>) -> bool {
|
||||
pub(crate) fn is_dyn_weak(p: &Parser<'_>) -> bool {
|
||||
const WEAK_DYN_PATH_FIRST: TokenSet = TokenSet::new(&[
|
||||
IDENT,
|
||||
T![self],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue