Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/thir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ pub enum ExprKind<'tcx> {
/// expression. This is inserted in some places where an operation would
/// otherwise be erased completely (e.g. some no-op casts), but we still
/// need to ensure that its operand is treated as a value and not a place.
Use {
ValueExpr {
source: ExprId,
},
/// A coercion from `!` to any type.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/thir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
}
Unary { arg, op: _ } => visitor.visit_expr(&visitor.thir()[arg]),
Cast { source } => visitor.visit_expr(&visitor.thir()[source]),
Use { source } => visitor.visit_expr(&visitor.thir()[source]),
ValueExpr { source } => visitor.visit_expr(&visitor.thir()[source]),
NeverToAny { source } => visitor.visit_expr(&visitor.thir()[source]),
PointerCoercion { source, cast: _, is_from_as_cast: _ } => {
visitor.visit_expr(&visitor.thir()[source])
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/abstract_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use crate::ty::{
#[derive(Hash, Debug, Clone, Copy, Ord, PartialOrd, PartialEq, Eq)]
#[derive(TyDecodable, TyEncodable, StableHash, TypeVisitable, TypeFoldable)]
pub enum CastKind {
/// thir::ExprKind::As
/// `thir::ExprKind::As`
As,
/// thir::ExprKind::Use
/// `thir::ExprKind::ValueExpr`
Use,
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/builder/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl CoverageInfoBuilder {
self.visit_with_not_info(thir, arg, not_info);
}
ExprKind::Scope { value, .. } => self.visit_with_not_info(thir, value, not_info),
ExprKind::Use { source } => self.visit_with_not_info(thir, source, not_info),
ExprKind::ValueExpr { source } => self.visit_with_not_info(thir, source, not_info),
// All other expressions (including `&&` and `||`) don't need any
// special handling of their contents, so stop visiting.
_ => {}
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'tcx> Builder<'_, 'tcx> {
};

// Remove any wrappers, so that we can inspect the real underlying expression.
while let ExprKind::Use { source: inner } | ExprKind::Scope { value: inner, .. } =
while let ExprKind::ValueExpr { source: inner } | ExprKind::Scope { value: inner, .. } =
self.thir[expr_id].kind
{
expr_id = inner;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Binary { .. }
| ExprKind::LogicalOp { .. }
| ExprKind::Cast { .. }
| ExprKind::Use { .. }
| ExprKind::ValueExpr { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::PointerCoercion { .. }
| ExprKind::Repeat { .. }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Match { .. }
| ExprKind::If { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::ValueExpr { .. }
| ExprKind::Borrow { .. }
| ExprKind::RawBorrow { .. }
| ExprKind::Adt { .. }
Expand Down Expand Up @@ -600,7 +600,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
debug!(?kind, "check_constness");
match kind {
&ExprKind::ValueTypeAscription { source: eid, user_ty: _, user_ty_span: _ }
| &ExprKind::Use { source: eid }
| &ExprKind::ValueExpr { source: eid }
| &ExprKind::PointerCoercion {
cast: PointerCoercion::Unsize,
source: eid,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Category {
| ExprKind::If { .. }
| ExprKind::Let { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::ValueExpr { .. }
| ExprKind::Adt { .. }
| ExprKind::Borrow { .. }
| ExprKind::RawBorrow { .. }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.unit()
}
}
ExprKind::Use { source } => this.expr_into_dest(destination, block, source),
ExprKind::ValueExpr { source } => this.expr_into_dest(destination, block, source),
ExprKind::Borrow { arg, borrow_kind } => {
// We don't do this in `as_rvalue` because we use `as_place`
// for borrow expressions, so we cannot create an `RValue` that
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/builder/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.lower_if_condition(block, value, args)
})
}
ExprKind::Use { source } => this.lower_if_condition(block, source, args),
ExprKind::ValueExpr { source } => this.lower_if_condition(block, source, args),
ExprKind::Let { expr, ref pat } => this.lower_let_expr(
block,
expr,
Expand Down Expand Up @@ -749,7 +749,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind::Scope { value, .. } => {
self.declare_guard_bindings(value, scope_span, visibility_scope);
}
ExprKind::Use { source } => {
ExprKind::ValueExpr { source } => {
self.declare_guard_bindings(source, scope_span, visibility_scope);
}
ExprKind::LogicalOp { op: LogicalOp::And, lhs, rhs } => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
| ExprKind::If { .. }
| ExprKind::InlineAsm { .. }
| ExprKind::LogicalOp { .. }
| ExprKind::Use { .. }
| ExprKind::ValueExpr { .. }
| ExprKind::Reborrow { .. } => {
// We don't need to save the old value and restore it
// because all the place expressions can't have more
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
// using a coercion (or is a no-op).
if self.typeck_results.is_coercion_cast(source.hir_id) {
// Convert the lexpr to a vexpr.
ExprKind::Use { source: self.mirror_expr(source) }
ExprKind::ValueExpr { source: self.mirror_expr(source) }
} else if self.typeck_results.expr_ty(source).is_ref() {
// Special cased so that we can type check that the element
// type of the source matches the pointed to type of the
Expand Down Expand Up @@ -1178,7 +1178,9 @@ impl<'tcx> ThirBuildCx<'tcx> {
ExprKind::WrapUnsafeBinder { source: mirrored }
}

hir::ExprKind::DropTemps(source) => ExprKind::Use { source: self.mirror_expr(source) },
hir::ExprKind::DropTemps(source) => {
ExprKind::ValueExpr { source: self.mirror_expr(source) }
}
hir::ExprKind::Array(fields) => ExprKind::Array { fields: self.mirror_exprs(fields) },
hir::ExprKind::Tup(fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) },

Expand Down Expand Up @@ -1605,7 +1607,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
name: field,
},
HirProjectionKind::OpaqueCast => {
ExprKind::Use { source: self.thir.exprs.push(captured_place_expr) }
ExprKind::ValueExpr { source: self.thir.exprs.push(captured_place_expr) }
}
HirProjectionKind::UnwrapUnsafeBinder => ExprKind::PlaceUnwrapUnsafeBinder {
source: self.thir.exprs.push(captured_place_expr),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
// Casts don't cause a load.
NeverToAny { source }
| Cast { source }
| Use { source }
| ValueExpr { source }
| PointerCoercion { source, .. }
| PlaceTypeAscription { source, .. }
| ValueTypeAscription { source, .. }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/thir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
self.print_expr(*source, depth_lvl + 2);
print_indented!(self, "}", depth_lvl);
}
Use { source } => {
print_indented!(self, "Use {", depth_lvl);
ValueExpr { source } => {
print_indented!(self, "ValueExpr {", depth_lvl);
print_indented!(self, "source:", depth_lvl + 1);
self.print_expr(*source, depth_lvl + 2);
print_indented!(self, "}", depth_lvl);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ty_utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ fn recurse_build<'tcx>(
maybe_supported_error(GenericConstantTooComplexSub::BlockNotSupported(node.span))?
}
}
// `ExprKind::Use` happens when a `hir::ExprKind::Cast` is a
// `ExprKind::ValueExpr` happens when a `hir::ExprKind::Cast` is a
// "coercion cast" i.e. using a coercion or is a no-op.
// This is important so that `N as usize as usize` doesn't unify with `N as usize`. (untested)
&ExprKind::Use { source } => {
&ExprKind::ValueExpr { source } => {
let value_ty = body.exprs[source].ty;
let value = recurse_build(tcx, body, source, root_span)?;
ty::Const::new_expr(tcx, Expr::new_cast(tcx, CastKind::Use, value_ty, value, node.ty))
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
| thir::ExprKind::LogicalOp { .. }
| thir::ExprKind::Unary { .. }
| thir::ExprKind::Cast { .. }
| thir::ExprKind::Use { .. }
| thir::ExprKind::ValueExpr { .. }
| thir::ExprKind::NeverToAny { .. }
| thir::ExprKind::PointerCoercion { .. }
| thir::ExprKind::Loop { .. }
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/thir-print/thir-tree-match-for.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ body:
temp_scope_id: 44
span: $DIR/thir-tree-match-for.rs:16:3: 18:4 (#7)
kind:
Use {
ValueExpr {
source:
Expr {
ty: ()
Expand Down
Loading