From bf37eb4abc93f726572fdef7ee0702e3a16d5692 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 13 Nov 2024 00:49:41 -0500 Subject: [PATCH] Revert "Encode const constructor MIR in crate metadata" This reverts commit 2010e0af96a043edf2ca3b4157ebbd4e66b24150. For now, we'll let this ICE and deal with it later since it's feature-gated anyway. Also add known-bug test for it. --- compiler/rustc_mir_transform/src/lib.rs | 4 ++-- tests/crashes/132985.rs | 17 +++++++++++++++++ tests/crashes/auxiliary/aux132985.rs | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/crashes/132985.rs create mode 100644 tests/crashes/auxiliary/aux132985.rs 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;