Skip to content

Commit ee3c9f7

Browse files
authored
Rollup merge of #103950 - nbdd0121:master, r=tmiasko
Fix ICE when negative impl is collected during eager mono ```rust trait Foo { fn foo() {} } impl !Foo for () {} ``` This code will currently cause an ICE when mono collection mode is "eager" (with `-C link-dead-code=y` or `-Z print-mono-items=eager`.
2 parents 9398676 + 1013ee8 commit ee3c9f7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compiler/rustc_monomorphize/src/collector.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,10 @@ fn create_mono_items_for_default_impls<'tcx>(
13361336
) {
13371337
match item.kind {
13381338
hir::ItemKind::Impl(ref impl_) => {
1339+
if matches!(impl_.polarity, hir::ImplPolarity::Negative(_)) {
1340+
return;
1341+
}
1342+
13391343
for param in impl_.generics.params {
13401344
match param.kind {
13411345
hir::GenericParamKind::Lifetime { .. } => {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// build-pass
2+
// compile-flags:-C link-dead-code=y
3+
4+
#![feature(negative_impls)]
5+
6+
trait Foo {
7+
fn foo() {}
8+
}
9+
10+
impl !Foo for () {}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)