Skip to content

Commit

Permalink
Rollup merge of rust-lang#63582 - JohnTitor:fix-ice-63226, r=oli-obk
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril authored Aug 15, 2019
2 parents 77f2694 + 7adb20e commit 19d6178
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
}

match item.node {
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
return true;
}
hir::ItemKind::Impl(..) |
hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
Expand All @@ -52,6 +55,11 @@ fn method_might_be_inlined(
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
return true
}
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.node {
if method_sig.header.is_const() {
return true
}
}
if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_src) {
match tcx.hir().find(impl_hir_id) {
Some(Node::Item(item)) =>
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/consts/auxiliary/issue-63226.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub struct VTable{
state:extern fn(),
}

impl VTable{
pub const fn vtable()->&'static VTable{
Self::VTABLE
}

const VTABLE: &'static VTable =
&VTable{state};
}

extern fn state() {}
12 changes: 12 additions & 0 deletions src/test/ui/consts/issue-63226.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// aux-build:issue-63226.rs
// compile-flags:--extern issue_63226
// edition:2018
// build-pass
// A regression test for issue #63226.
// Checks if `const fn` is marked as reachable.

use issue_63226::VTable;

static ICE_ICE:&'static VTable=VTable::vtable();

fn main() {}

0 comments on commit 19d6178

Please sign in to comment.