diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2020-07-23 11:02:44 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2020-07-23 11:05:04 -0400 |
| commit | d01e1093baf4d5ebe08a067a2a8e720e7fa7eb22 (patch) | |
| tree | c059f7a21aec17f215858d12c62050a7a435b355 | |
| parent | 174b58287c66a6ad3eaa1897279d769611919960 (diff) | |
| download | rust-d01e1093baf4d5ebe08a067a2a8e720e7fa7eb22.tar.gz rust-d01e1093baf4d5ebe08a067a2a8e720e7fa7eb22.zip | |
delay_span_bug instead of silent ignore
| -rw-r--r-- | src/librustc_resolve/late.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 2d282c7464e..9577a21c743 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -1415,16 +1415,22 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { match pat.kind { // In tuple struct patterns ignore the invalid `ident @ ...`. // It will be handled as an error by the AST lowering. - PatKind::Ident(bmode, ident, ref sub) - if !(is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some()) => - { - // First try to resolve the identifier as some existing entity, - // then fall back to a fresh binding. - let has_sub = sub.is_some(); - let res = self - .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub) - .unwrap_or_else(|| self.fresh_binding(ident, pat.id, pat_src, bindings)); - self.r.record_partial_res(pat.id, PartialRes::new(res)); + PatKind::Ident(bmode, ident, ref sub) => { + if is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some() { + self.r + .session + .delay_span_bug(ident.span, "ident in tuple pattern is invalid"); + } else { + // First try to resolve the identifier as some existing entity, + // then fall back to a fresh binding. + let has_sub = sub.is_some(); + let res = self + .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub) + .unwrap_or_else(|| { + self.fresh_binding(ident, pat.id, pat_src, bindings) + }); + self.r.record_partial_res(pat.id, PartialRes::new(res)); + } } PatKind::TupleStruct(ref path, ..) => { self.smart_resolve_path(pat.id, None, path, PathSource::TupleStruct); |
