Auto merge of #125918 - oli-obk:const_block_ice, r=compiler-errors
Revert: create const block bodies in typeck via query feeding as per the discussion in https://github.com/rust-lang/rust/pull/125806#discussion_r1622563948 It was a mistake to try to shoehorn const blocks and some specific anon consts into the same box and feed them during typeck. It turned out not simplifying anything (my hope was that we could feed `type_of` to start avoiding the huge HIR matcher, but that didn't work out), but instead making a few things more fragile. reverts the const-block-specific parts of https://github.com/rust-lang/rust/pull/124650 `@bors` rollup=never had a small perf impact previously fixes https://github.com/rust-lang/rust/issues/125846 r? `@compiler-errors`
This commit is contained in:
@@ -907,9 +907,6 @@ pub struct OwnerNodes<'tcx> {
|
||||
pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
|
||||
/// Content of local bodies.
|
||||
pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
|
||||
/// Whether the body contains inline constants that are created for the query system during typeck
|
||||
/// of the body.
|
||||
pub has_inline_consts: bool,
|
||||
}
|
||||
|
||||
impl<'tcx> OwnerNodes<'tcx> {
|
||||
@@ -1626,6 +1623,14 @@ pub struct AnonConst {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
/// An inline constant expression `const { something }`.
|
||||
#[derive(Copy, Clone, Debug, HashStable_Generic)]
|
||||
pub struct ConstBlock {
|
||||
pub hir_id: HirId,
|
||||
pub def_id: LocalDefId,
|
||||
pub body: BodyId,
|
||||
}
|
||||
|
||||
/// An expression.
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub struct Expr<'hir> {
|
||||
@@ -1912,7 +1917,7 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub enum ExprKind<'hir> {
|
||||
/// Allow anonymous constants from an inline `const` block
|
||||
ConstBlock(&'hir Expr<'hir>),
|
||||
ConstBlock(ConstBlock),
|
||||
/// An array (e.g., `[a, b, c, d]`).
|
||||
Array(&'hir [Expr<'hir>]),
|
||||
/// A function call.
|
||||
@@ -3650,6 +3655,7 @@ pub enum Node<'hir> {
|
||||
Variant(&'hir Variant<'hir>),
|
||||
Field(&'hir FieldDef<'hir>),
|
||||
AnonConst(&'hir AnonConst),
|
||||
ConstBlock(&'hir ConstBlock),
|
||||
Expr(&'hir Expr<'hir>),
|
||||
ExprField(&'hir ExprField<'hir>),
|
||||
Stmt(&'hir Stmt<'hir>),
|
||||
@@ -3710,6 +3716,7 @@ impl<'hir> Node<'hir> {
|
||||
Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
|
||||
Node::Param(..)
|
||||
| Node::AnonConst(..)
|
||||
| Node::ConstBlock(..)
|
||||
| Node::Expr(..)
|
||||
| Node::Stmt(..)
|
||||
| Node::Block(..)
|
||||
@@ -3807,6 +3814,7 @@ impl<'hir> Node<'hir> {
|
||||
}
|
||||
|
||||
Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
|
||||
Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
|
||||
|
||||
_ => None,
|
||||
}
|
||||
@@ -3875,6 +3883,7 @@ impl<'hir> Node<'hir> {
|
||||
expect_variant, &'hir Variant<'hir>, Node::Variant(n), n;
|
||||
expect_field, &'hir FieldDef<'hir>, Node::Field(n), n;
|
||||
expect_anon_const, &'hir AnonConst, Node::AnonConst(n), n;
|
||||
expect_inline_const, &'hir ConstBlock, Node::ConstBlock(n), n;
|
||||
expect_expr, &'hir Expr<'hir>, Node::Expr(n), n;
|
||||
expect_expr_field, &'hir ExprField<'hir>, Node::ExprField(n), n;
|
||||
expect_stmt, &'hir Stmt<'hir>, Node::Stmt(n), n;
|
||||
|
||||
Reference in New Issue
Block a user