diff options
| author | varkor <github@varkor.com> | 2020-11-18 12:49:39 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2020-11-18 13:16:35 +0000 |
| commit | efcbf1b00bb8997f1e1ee0740640f67fbe32c615 (patch) | |
| tree | cd16352437a70f8f9d66ff8ece04c211dedaaf56 /compiler/rustc_parse/src/parser/diagnostics.rs | |
| parent | c4f836ad1aceb83507810d9499f56988fd24578d (diff) | |
| download | rust-efcbf1b00bb8997f1e1ee0740640f67fbe32c615.tar.gz rust-efcbf1b00bb8997f1e1ee0740640f67fbe32c615.zip | |
Permit standalone generic parameters as const generic arguments in macros
Diffstat (limited to 'compiler/rustc_parse/src/parser/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index cd3b8db2303..350a372a684 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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| { |
