Skip to content

Commit

Permalink
Rollup merge of rust-lang#74692 - Mark-Simulacrum:delay-bug, r=pnkfelix
Browse files Browse the repository at this point in the history
delay_span_bug instead of silent ignore

This is a follow-up to rust-lang#74557.

r? @pnkfelix
  • Loading branch information
Dylan-DPC authored Jul 24, 2020
2 parents bd22cc5 + 5a5846f commit 7d545ed
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,18 +1506,24 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
pat.walk(&mut |pat| {
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
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() {
// In tuple struct patterns ignore the invalid `ident @ ...`.
// It will be handled as an error by the AST lowering.
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(pat.span));
Expand Down

0 comments on commit 7d545ed

Please sign in to comment.