diff --git a/src/ty.rs b/src/ty.rs index 09ed8a91ca..1fe0796068 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -825,15 +825,28 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypePath { fn parse(input: ParseStream) -> Result { - let (qself, mut path) = path::parsing::qpath(input, false)?; + let expr_style = false; + let (qself, mut path) = path::parsing::qpath(input, expr_style)?; if path.segments.last().unwrap().arguments.is_empty() && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) { input.parse::>()?; let args: ParenthesizedGenericArguments = input.parse()?; + let allow_associated_type = cfg!(feature = "full") + && match &args.output { + ReturnType::Default => true, + ReturnType::Type(_, ty) => match **ty { + // TODO: probably some of the other kinds allow this too. + Type::Paren(_) => true, + _ => false, + }, + }; let parenthesized = PathArguments::Parenthesized(args); path.segments.last_mut().unwrap().arguments = parenthesized; + if allow_associated_type { + Path::parse_rest(input, &mut path, expr_style)?; + } } Ok(TypePath { qself, path }) diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 494c63e113..5c29015865 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -14,9 +14,6 @@ const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba"; #[rustfmt::skip] static EXCLUDE_FILES: &[&str] = &[ - // TODO: associated type of a path with parenthesized generic arguments - "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0202_typepathfn_with_coloncolon.rs", - // TODO: trailing comma after variadic in extern fn signature "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0063_variadic_fun.rs",