Skip to content

Commit 3815c5d

Browse files
authored
Rollup merge of rust-lang#63582 - JohnTitor:fix-ice-63226, r=oli-obk
Fix ICE rust-lang#63226 Fixes rust-lang#63226 r? @oli-obk
2 parents 8576227 + 7adb20e commit 3815c5d

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/librustc/middle/reachable.rs

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
3333
}
3434

3535
match item.node {
36+
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
37+
return true;
38+
}
3639
hir::ItemKind::Impl(..) |
3740
hir::ItemKind::Fn(..) => {
3841
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
@@ -52,6 +55,11 @@ fn method_might_be_inlined(
5255
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
5356
return true
5457
}
58+
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.node {
59+
if method_sig.header.is_const() {
60+
return true
61+
}
62+
}
5563
if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_src) {
5664
match tcx.hir().find(impl_hir_id) {
5765
Some(Node::Item(item)) =>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub struct VTable{
2+
state:extern fn(),
3+
}
4+
5+
impl VTable{
6+
pub const fn vtable()->&'static VTable{
7+
Self::VTABLE
8+
}
9+
10+
const VTABLE: &'static VTable =
11+
&VTable{state};
12+
}
13+
14+
extern fn state() {}

src/test/ui/consts/issue-63226.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// aux-build:issue-63226.rs
2+
// compile-flags:--extern issue_63226
3+
// edition:2018
4+
// build-pass
5+
// A regression test for issue #63226.
6+
// Checks if `const fn` is marked as reachable.
7+
8+
use issue_63226::VTable;
9+
10+
static ICE_ICE:&'static VTable=VTable::vtable();
11+
12+
fn main() {}

0 commit comments

Comments
 (0)