about summary refs log tree commit diff
path: root/src/librustc_interface
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-28 11:13:09 +0000
committerbors <bors@rust-lang.org>2020-03-28 11:13:09 +0000
commitb9d5ee567652cd342d9348c215009049551747b0 (patch)
tree820b045d697c1263c497f442274d1a9aac952189 /src/librustc_interface
parentb76238a3ee5ebffbad8a3aefd36012f3bceb7069 (diff)
parent42c5cfdfda24529f424a6175fa1a48e5542cb824 (diff)
Auto merge of #70261 - Centril:angle-args-partition, r=varkor
Move arg/constraint partition check to validation & improve recovery

- In the first commit, we move the check rejecting e.g., `<'a, Item = u8, String>` from the parser into AST validation.
- We then use this to improve the code for parsing generic arguments.
- And we add recovery for e.g., `<Item = >` (missing), `<Item = 42>` (constant), and `<Item = 'a>` (lifetime).

This is also preparatory work for supporting https://github.com/rust-lang/rust/issues/70256.

r? @varkor
Diffstat (limited to 'src/librustc_interface')
-rw-r--r--src/librustc_interface/util.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
index c6f2d1b82fc..eff7dacef79 100644
--- a/src/librustc_interface/util.rs
+++ b/src/librustc_interface/util.rs
@@ -634,17 +634,19 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
                         match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
                             None => false,
                             Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
-                                let types = data.args.iter().filter_map(|arg| match arg {
-                                    ast::GenericArg::Type(ty) => Some(ty),
-                                    _ => None,
-                                });
-                                any_involves_impl_trait(types)
-                                    || data.constraints.iter().any(|c| match c.kind {
+                                data.args.iter().any(|arg| match arg {
+                                    ast::AngleBracketedArg::Arg(arg) => match arg {
+                                        ast::GenericArg::Type(ty) => involves_impl_trait(ty),
+                                        ast::GenericArg::Lifetime(_)
+                                        | ast::GenericArg::Const(_) => false,
+                                    },
+                                    ast::AngleBracketedArg::Constraint(c) => match c.kind {
                                         ast::AssocTyConstraintKind::Bound { .. } => true,
                                         ast::AssocTyConstraintKind::Equality { ref ty } => {
                                             involves_impl_trait(ty)
                                         }
-                                    })
+                                    },
+                                })
                             }
                             Some(&ast::GenericArgs::Parenthesized(ref data)) => {
                                 any_involves_impl_trait(data.inputs.iter())