Skip to content

Commit 4aa1f59

Browse files
committed
Auto merge of #29515 - Manishearth:ice-itembody, r=eddyb
r? @eddyb or @nrc
2 parents c143ae7 + 6468292 commit 4aa1f59

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/librustc/middle/mem_categorization.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,18 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
11951195

11961196
(*op)(self, cmt.clone(), pat);
11971197

1198-
let opt_def = self.tcx().def_map.borrow().get(&pat.id).map(|d| d.full_def());
1198+
let opt_def = if let Some(path_res) = self.tcx().def_map.borrow().get(&pat.id) {
1199+
if path_res.depth != 0 {
1200+
// Since patterns can be associated constants
1201+
// which are resolved during typeck, we might have
1202+
// some unresolved patterns reaching this stage
1203+
// without aborting
1204+
return Err(());
1205+
}
1206+
Some(path_res.full_def())
1207+
} else {
1208+
None
1209+
};
11991210

12001211
// Note: This goes up here (rather than within the PatEnum arm
12011212
// alone) because struct patterns can refer to struct types or

src/test/compile-fail/issue-28971.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2012-2015 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+
// This should not cause an ICE
12+
13+
enum Foo {
14+
Bar(u8)
15+
}
16+
fn main(){
17+
foo(|| {
18+
match Foo::Bar(1) {
19+
Foo::Baz(..) => (), //~ ERROR no associated
20+
_ => (),
21+
}
22+
});
23+
}
24+
25+
fn foo<F>(f: F) where F: FnMut() {
26+
f();
27+
}

0 commit comments

Comments
 (0)