diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 68cc76b3dfaa2..d2d5facbbdc83 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -21,7 +21,7 @@ use rustc_const_eval::util; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::steal::Steal; use rustc_hir as hir; -use rustc_hir::def::DefKind; +use rustc_hir::def::{CtorKind, DefKind}; use rustc_hir::def_id::LocalDefId; use rustc_index::IndexVec; use rustc_middle::mir::{ @@ -322,7 +322,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet { for item in tcx.hir_crate_items(()).free_items() { if let DefKind::Struct | DefKind::Enum = tcx.def_kind(item.owner_id) { for variant in tcx.adt_def(item.owner_id).variants() { - if let Some((_, ctor_def_id)) = variant.ctor { + if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor { set.insert(ctor_def_id.expect_local()); } } diff --git a/tests/crashes/132985.rs b/tests/crashes/132985.rs new file mode 100644 index 0000000000000..2735074f44d12 --- /dev/null +++ b/tests/crashes/132985.rs @@ -0,0 +1,17 @@ +//@ known-bug: #132985 +//@ aux-build:aux132985.rs + +#![allow(incomplete_features)] +#![feature(min_generic_const_args)] +#![feature(adt_const_params)] + +extern crate aux132985; +use aux132985::Foo; + +fn bar() {} + +fn baz() { + bar::<{ Foo }>(); +} + +fn main() {} diff --git a/tests/crashes/auxiliary/aux132985.rs b/tests/crashes/auxiliary/aux132985.rs new file mode 100644 index 0000000000000..7ae5567bdc59d --- /dev/null +++ b/tests/crashes/auxiliary/aux132985.rs @@ -0,0 +1,6 @@ +#![feature(adt_const_params)] + +use std::marker::ConstParamTy; + +#[derive(Eq, PartialEq, ConstParamTy)] +pub struct Foo;