1
Fork 0

Permit standalone generic parameters as const generic arguments in macros

This commit is contained in:
varkor 2020-11-18 12:49:39 +00:00
parent c4f836ad1a
commit efcbf1b00b
5 changed files with 18 additions and 28 deletions

View file

@ -1808,9 +1808,13 @@ impl<'a> Parser<'a> {
return Ok(false); // Don't continue.
}
/// Handle a generic const argument that had not been enclosed in braces, and suggest enclosing
/// it braces. In this situation, unlike in `handle_ambiguous_unbraced_const_arg`, this is
/// almost certainly a const argument, so we always offer a suggestion.
/// Attempt to parse a generic const argument that has not been enclosed in braces.
/// There are a limited number of expressions that are permitted without being encoded
/// in braces:
/// - Literals.
/// - Single-segment paths (i.e. standalone generic const parameters).
/// All other expressions that can be parsed will emit an error suggesting the expression be
/// wrapped in braces.
pub fn handle_unambiguous_unbraced_const_arg(&mut self) -> PResult<'a, P<Expr>> {
let start = self.token.span;
let expr = self.parse_expr_res(Restrictions::CONST_EXPR, None).map_err(|mut err| {