diff --git a/src/lib/lib.rs b/src/lib/lib.rs index df8e970..fb3d2c8 100644 --- a/src/lib/lib.rs +++ b/src/lib/lib.rs @@ -8,7 +8,6 @@ #![feature(deref_patterns)] #![feature(derive_const)] #![feature(gen_blocks)] -#![feature(generic_const_items)] #![feature(import_trait_associated_functions)] #![feature(macro_metavar_expr)] #![feature(mut_ref)] diff --git a/src/lib/parser/test/ty.rs b/src/lib/parser/test/ty.rs index 4acb37d..a5299cc 100644 --- a/src/lib/parser/test/ty.rs +++ b/src/lib/parser/test/ty.rs @@ -231,14 +231,18 @@ fn bare_trait_object_tys() { Ok(ast::Ty::DynTrait(ast::DynKind::Bare, [ast::Bound::Use(_)])) ); - // Indeed, even though you can't parenthesize precise-capturing lists - // in "normal" bounds, you can do so in bare trait object type bounds. - // If find it a bit janky. Might report upstream. + // Context: t!( parse_ty, Rust2015, "(use<>)+", - Ok(ast::Ty::DynTrait(ast::DynKind::Bare, [ast::Bound::Use(_)])) + Err([Error { + kind: ErrorKind::UnexpectedToken( + TokenKind::SinglePlus, + [Fragment::Token(TokenKind::EndOfInput)], + ), + .. + }]) ); // It's easy to accidentally accept the following code while trying to support the form above. diff --git a/src/lib/parser/ty.rs b/src/lib/parser/ty.rs index 61349b7..981a6da 100644 --- a/src/lib/parser/ty.rs +++ b/src/lib/parser/ty.rs @@ -302,31 +302,22 @@ impl<'src> super::Parser<'_, '_, 'src> { inner_ty: &mut ast::Ty<'src>, p_policy: PlusPolicy, ) -> Result>> { - const EMPTY<'src>: ast::Path<'src, ast::UnambiguousGenericArgs> = - ast::Path { segs: Vec::new() }; - - let bound = match inner_ty { + let mut bounds = vec![match inner_ty { ast::Ty::Path(ast::ExtPath { ext: None, path }) => { - ast::Bound::from(mem::replace(path, EMPTY)) - } - ast::Ty::DynTrait(ast::DynKind::Bare, [bound]) => { - match bound { - ast::Bound::Outlives(_) => return Ok(None), - // NOTE: I'm not happy about this since use-bounds can't be parenthesized "normally". - ast::Bound::Use(captures) => ast::Bound::Use(mem::take(captures)), - ast::Bound::Trait { bound_vars, modifiers, path } => ast::Bound::Trait { - bound_vars: mem::take(bound_vars), - modifiers: *modifiers, - path: mem::replace(path, EMPTY), - }, - } + ast::Bound::from(mem::replace(path, ast::Path { segs: Vec::new() })) } + ast::Ty::DynTrait( + ast::DynKind::Bare, + [ast::Bound::Trait { bound_vars, modifiers, path }], + ) => ast::Bound::Trait { + bound_vars: mem::take(bound_vars), + modifiers: *modifiers, + path: mem::replace(path, ast::Path { segs: Vec::new() }), + }, _ => return Ok(None), - }; + }]; self.parse_unchecked(TokenPrefix::Plus); - - let mut bounds = vec![bound]; self.parse_bounds_into(p_policy.maintain(), &mut bounds)?; Ok(Some(ast::Ty::DynTrait(ast::DynKind::Bare, bounds)))