Skip to content

Commit

Permalink
Fix ICE when negative impl is collected during eager mono
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Nov 4, 2022
1 parent 215e3cd commit 1013ee8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ fn create_mono_items_for_default_impls<'tcx>(
) {
match item.kind {
hir::ItemKind::Impl(ref impl_) => {
if matches!(impl_.polarity, hir::ImplPolarity::Negative(_)) {
return;
}

for param in impl_.generics.params {
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {}
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/traits/negative-impls/eager-mono.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// build-pass
// compile-flags:-C link-dead-code=y

#![feature(negative_impls)]

trait Foo {
fn foo() {}
}

impl !Foo for () {}

fn main() {}

0 comments on commit 1013ee8

Please sign in to comment.