diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-11-19 16:26:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-19 16:26:44 +0100 |
| commit | b5fffdc12be138ddf5fbd0f20d31026597d86d4e (patch) | |
| tree | d00a739e36f57744c29dc246dfbadce5ed44cf3a /compiler/rustc_parse/src/parser/path.rs | |
| parent | de622725480148f41e3c1cf0f52aeb230e5e1159 (diff) | |
| parent | 85bc9538920850e5bd7c1023c9ffbf5e8e69be6a (diff) | |
| download | rust-b5fffdc12be138ddf5fbd0f20d31026597d86d4e.tar.gz rust-b5fffdc12be138ddf5fbd0f20d31026597d86d4e.zip | |
Rollup merge of #79164 - varkor:unbraced-single-segment-const-arguments, r=petrochenkov
Permit standalone generic parameters as const generic arguments in macros Fixes https://github.com/rust-lang/rust/issues/79127. r? ```@petrochenkov```
Diffstat (limited to 'compiler/rustc_parse/src/parser/path.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 8 |
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, } } |
