From cde0f94a5272a1c00ebe04fc44e19e9e687c3fda Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Mon, 30 May 2016 14:54:22 +0200 Subject: [PATCH] librustc_resolve: make sure pattern def gets recorded if `resolve_path` returns `Err(true)` In 1a374b8, (pr #33046) fixed the error reporting of a specific case, but the change that was introduced did not make sure that `record_def` was called in all cases, which lead to an ICE in [1]. This change restores the original `else` case, but keeps the changes that were committed in 1a374b8. This commit fixes issue #33293. [1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_` --- src/librustc_resolve/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2444f6acced24..36053d3c4ffa7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2422,13 +2422,16 @@ impl<'a> Resolver<'a> { } } } - } else if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) { - resolve_error( - self, - path.span, - ResolutionError::UnresolvedEnumVariantStructOrConst( - &path.segments.last().unwrap().identifier.name.as_str()) - ); + } else { + if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) { + // No error has been reported, so we need to do this ourselves. + resolve_error( + self, + path.span, + ResolutionError::UnresolvedEnumVariantStructOrConst( + &path.segments.last().unwrap().identifier.name.as_str()) + ); + } self.record_def(pattern.id, err_path_resolution()); } visit::walk_path(self, path);