diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-15 14:34:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-15 14:34:08 +0200 |
| commit | 19d6178b8f44a8bee56b45df07116a6d490eb7d1 (patch) | |
| tree | d23c56ca721e169fd0ba6026e01629482f49ed01 | |
| parent | 77f2694fdc7fb469511e0ca485c164b9ef66f64f (diff) | |
| parent | 7adb20e4cda94b9a726d99594afa506c6d40f453 (diff) | |
| download | rust-19d6178b8f44a8bee56b45df07116a6d490eb7d1.tar.gz rust-19d6178b8f44a8bee56b45df07116a6d490eb7d1.zip | |
Rollup merge of #63582 - JohnTitor:fix-ice-63226, r=oli-obk
Fix ICE #63226 Fixes #63226 r? @oli-obk
| -rw-r--r-- | src/librustc/middle/reachable.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/consts/auxiliary/issue-63226.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-63226.rs | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 76d8a6738f0..c2bcd462163 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -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)); @@ -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)) => diff --git a/src/test/ui/consts/auxiliary/issue-63226.rs b/src/test/ui/consts/auxiliary/issue-63226.rs new file mode 100644 index 00000000000..39cc01a415e --- /dev/null +++ b/src/test/ui/consts/auxiliary/issue-63226.rs @@ -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() {} diff --git a/src/test/ui/consts/issue-63226.rs b/src/test/ui/consts/issue-63226.rs new file mode 100644 index 00000000000..deec4499008 --- /dev/null +++ b/src/test/ui/consts/issue-63226.rs @@ -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() {} |
