Skip to content

Commit 7d545ed

Browse files
authored
Rollup merge of rust-lang#74692 - Mark-Simulacrum:delay-bug, r=pnkfelix
delay_span_bug instead of silent ignore This is a follow-up to rust-lang#74557. r? @pnkfelix
2 parents bd22cc5 + 5a5846f commit 7d545ed

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/librustc_resolve/late.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -1506,18 +1506,24 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15061506
pat.walk(&mut |pat| {
15071507
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
15081508
match pat.kind {
1509-
// In tuple struct patterns ignore the invalid `ident @ ...`.
1510-
// It will be handled as an error by the AST lowering.
1511-
PatKind::Ident(bmode, ident, ref sub)
1512-
if !(is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some()) =>
1513-
{
1514-
// First try to resolve the identifier as some existing entity,
1515-
// then fall back to a fresh binding.
1516-
let has_sub = sub.is_some();
1517-
let res = self
1518-
.try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub)
1519-
.unwrap_or_else(|| self.fresh_binding(ident, pat.id, pat_src, bindings));
1520-
self.r.record_partial_res(pat.id, PartialRes::new(res));
1509+
PatKind::Ident(bmode, ident, ref sub) => {
1510+
if is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some() {
1511+
// In tuple struct patterns ignore the invalid `ident @ ...`.
1512+
// It will be handled as an error by the AST lowering.
1513+
self.r
1514+
.session
1515+
.delay_span_bug(ident.span, "ident in tuple pattern is invalid");
1516+
} else {
1517+
// First try to resolve the identifier as some existing entity,
1518+
// then fall back to a fresh binding.
1519+
let has_sub = sub.is_some();
1520+
let res = self
1521+
.try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub)
1522+
.unwrap_or_else(|| {
1523+
self.fresh_binding(ident, pat.id, pat_src, bindings)
1524+
});
1525+
self.r.record_partial_res(pat.id, PartialRes::new(res));
1526+
}
15211527
}
15221528
PatKind::TupleStruct(ref path, ..) => {
15231529
self.smart_resolve_path(pat.id, None, path, PathSource::TupleStruct(pat.span));

0 commit comments

Comments
 (0)