about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/path.rs
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2020-11-18 12:49:39 +0000
committervarkor <github@varkor.com>2020-11-18 13:16:35 +0000
commitefcbf1b00bb8997f1e1ee0740640f67fbe32c615 (patch)
treecd16352437a70f8f9d66ff8ece04c211dedaaf56 /compiler/rustc_parse/src/parser/path.rs
parentc4f836ad1aceb83507810d9499f56988fd24578d (diff)
downloadrust-efcbf1b00bb8997f1e1ee0740640f67fbe32c615.tar.gz
rust-efcbf1b00bb8997f1e1ee0740640f67fbe32c615.zip
Permit standalone generic parameters as const generic arguments in macros
Diffstat (limited to 'compiler/rustc_parse/src/parser/path.rs')
-rw-r--r--compiler/rustc_parse/src/parser/path.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 79e73749038..d64fd59b0a6 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -489,6 +489,7 @@ impl<'a> Parser<'a> {
     /// - An expression surrounded in `{}`.
     /// - A literal.
     /// - A numeric literal prefixed by `-`.
+    /// - A single-segment path.
     pub(super) fn expr_is_valid_const_arg(&self, expr: &P<rustc_ast::Expr>) -> bool {
         match &expr.kind {
             ast::ExprKind::Block(_, _) | ast::ExprKind::Lit(_) => true,
@@ -496,6 +497,13 @@ impl<'a> Parser<'a> {
                 ast::ExprKind::Lit(_) => true,
                 _ => false,
             },
+            // We can only resolve single-segment paths at the moment, because multi-segment paths
+            // require type-checking: see `visit_generic_arg` in `src/librustc_resolve/late.rs`.
+            ast::ExprKind::Path(None, path)
+                if path.segments.len() == 1 && path.segments[0].args.is_none() =>
+            {
+                true
+            }
             _ => false,
         }
     }