Check FnHeader not to cause ICE
This commit is contained in:
parent
082cf2f9d1
commit
5b88fbabeb
3 changed files with 38 additions and 3 deletions
|
@ -32,9 +32,15 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
|
|||
return true
|
||||
}
|
||||
|
||||
match item.node {
|
||||
hir::ItemKind::Impl(..) |
|
||||
hir::ItemKind::Fn(..) => {
|
||||
match item.node {
|
||||
hir::ItemKind::Fn(_, header, ..) => {
|
||||
if header.constness == hir::Constness::Const {
|
||||
return true;
|
||||
}
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
|
||||
generics.requires_monomorphization(tcx)
|
||||
}
|
||||
hir::ItemKind::Impl(..) => {
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
|
||||
generics.requires_monomorphization(tcx)
|
||||
}
|
||||
|
@ -52,6 +58,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.constness == hir::Constness::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)) =>
|
||||
|
|
14
src/test/ui/issues/auxiliary/issue-63226.rs
Normal file
14
src/test/ui/issues/auxiliary/issue-63226.rs
Normal file
|
@ -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() {}
|
10
src/test/ui/issues/issue-63226.rs
Normal file
10
src/test/ui/issues/issue-63226.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// aux-build:issue-63226.rs
|
||||
// compile-flags:--extern issue_63226
|
||||
// edition:2018
|
||||
// build-pass
|
||||
|
||||
use issue_63226::VTable;
|
||||
|
||||
static ICE_ICE:&'static VTable=VTable::vtable();
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Reference in a new issue