diff options
| author | bors <bors@rust-lang.org> | 2021-11-01 17:18:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-01 17:18:57 +0000 |
| commit | db062de72b0a064f45b6f86894cbdc7c0ec68844 (patch) | |
| tree | 4a26e6f92abd1b7a399262eb7b04f7464e8ad015 /compiler/rustc_monomorphize/src | |
| parent | e9b0d992598d9a51fd7b1a4ae8f9cbafac5e593b (diff) | |
| parent | 4d619d92aea769d1646ff95dbd85d9f0b7655074 (diff) | |
| download | rust-db062de72b0a064f45b6f86894cbdc7c0ec68844.tar.gz rust-db062de72b0a064f45b6f86894cbdc7c0ec68844.zip | |
Auto merge of #90406 - nbdd0121:panic, r=cjgillot
Collect `panic/panic_bounds_check` during monomorphization This would prevent link time errors if these functions are `#[inline]` (e.g. when `panic_immediate_abort` is used). Fix #90405 Fix rust-lang/cargo#10019 `@rustbot` label: T-compiler A-codegen
Diffstat (limited to 'compiler/rustc_monomorphize/src')
| -rw-r--r-- | compiler/rustc_monomorphize/src/collector.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 5147408210e..59988e69b5d 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -806,13 +806,22 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { } } } + mir::TerminatorKind::Assert { ref msg, .. } => { + let lang_item = match msg { + mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck, + _ => LangItem::Panic, + }; + let instance = Instance::mono(tcx, tcx.require_lang_item(lang_item, Some(source))); + if should_codegen_locally(tcx, &instance) { + self.output.push(create_fn_mono_item(tcx, instance, source)); + } + } mir::TerminatorKind::Goto { .. } | mir::TerminatorKind::SwitchInt { .. } | mir::TerminatorKind::Resume | mir::TerminatorKind::Abort | mir::TerminatorKind::Return - | mir::TerminatorKind::Unreachable - | mir::TerminatorKind::Assert { .. } => {} + | mir::TerminatorKind::Unreachable => {} mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } | mir::TerminatorKind::FalseEdge { .. } |
