Skip to content

Commit d7a968e

Browse files
committed
Fix ICE happening when unresolved imports are used in patterns
1 parent 7588653 commit d7a968e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/librustc_resolve/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ impl<'a> Resolver<'a> {
22742274
let resolution = if let Some(resolution) = self.resolve_possibly_assoc_item(pat_id,
22752275
qself, path, namespace) {
22762276
if resolution.depth == 0 {
2277-
if expected_fn(resolution.base_def) {
2277+
if expected_fn(resolution.base_def) || resolution.base_def == Def::Err {
22782278
resolution
22792279
} else {
22802280
resolve_error(
@@ -2345,7 +2345,7 @@ impl<'a> Resolver<'a> {
23452345
);
23462346
None
23472347
}
2348-
Def::Local(..) | Def::Upvar(..) | Def::Fn(..) => {
2348+
Def::Local(..) | Def::Upvar(..) | Def::Fn(..) | Def::Err => {
23492349
// These entities are explicitly allowed
23502350
// to be shadowed by fresh bindings.
23512351
None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that unresolved imports do not create additional errors and ICEs
12+
13+
mod m {
14+
pub use unresolved; //~ ERROR unresolved import `unresolved`
15+
16+
fn f() {
17+
let unresolved = 0; // OK
18+
}
19+
}
20+
21+
fn main() {
22+
match 0u8 {
23+
m::unresolved => {} // OK
24+
m::unresolved(..) => {} // OK
25+
m::unresolved{..} => {} // OK
26+
}
27+
}

0 commit comments

Comments
 (0)