From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_mir_build/src/build/expr/as_constant.rs | 8 ++++---- compiler/rustc_mir_build/src/build/expr/as_operand.rs | 4 ++-- compiler/rustc_mir_build/src/build/expr/as_place.rs | 4 ++-- compiler/rustc_mir_build/src/build/expr/as_rvalue.rs | 2 +- compiler/rustc_mir_build/src/build/expr/into.rs | 2 +- compiler/rustc_mir_build/src/build/expr/stmt.rs | 18 ++++++++---------- 6 files changed, 18 insertions(+), 20 deletions(-) (limited to 'compiler/rustc_mir_build/src/build/expr') diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index 717c62315..1d96893c7 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -66,14 +66,14 @@ pub fn as_constant_inner<'tcx>( let literal = ConstantKind::Val(ConstValue::Scalar(Scalar::Int(lit)), ty); - Constant { span, user_ty: user_ty, literal } + Constant { span, user_ty, literal } } ExprKind::ZstLiteral { ref user_ty } => { let user_ty = user_ty.as_ref().map(push_cuta).flatten(); let literal = ConstantKind::Val(ConstValue::ZeroSized, ty); - Constant { span, user_ty: user_ty, literal } + Constant { span, user_ty, literal } } ExprKind::NamedConst { def_id, substs, ref user_ty } => { let user_ty = user_ty.as_ref().map(push_cuta).flatten(); @@ -135,14 +135,14 @@ pub(crate) fn lit_to_mir_constant<'tcx>( let allocation = tcx.intern_const_alloc(allocation); ConstValue::Slice { data: allocation, start: 0, end: s.len() } } - (ast::LitKind::ByteStr(data), ty::Ref(_, inner_ty, _)) + (ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Slice(_)) => { let allocation = Allocation::from_bytes_byte_aligned_immutable(data as &[u8]); let allocation = tcx.intern_const_alloc(allocation); ConstValue::Slice { data: allocation, start: 0, end: data.len() } } - (ast::LitKind::ByteStr(data), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => { + (ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => { let id = tcx.allocate_bytes(data); ConstValue::Scalar(Scalar::from_pointer(id.into(), &tcx)) } diff --git a/compiler/rustc_mir_build/src/build/expr/as_operand.rs b/compiler/rustc_mir_build/src/build/expr/as_operand.rs index c8610af70..c621efb3b 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_operand.rs @@ -27,7 +27,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// suitable also to be passed as function arguments. /// /// The operand returned from this function will *not be valid* after an ExprKind::Scope is - /// passed, so please do *not* return it from functions to avoid bad miscompiles. Returns an + /// passed, so please do *not* return it from functions to avoid bad miscompiles. Returns an /// operand suitable for use as a call argument. This is almost always equivalent to /// `as_operand`, except for the particular case of passing values of (potentially) unsized /// types "by value" (see details below). @@ -72,7 +72,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// will actually provide a pointer to the interior of the box, and not move the `dyn Debug` /// value to the stack. /// - /// See #68034 for more details. + /// See #68304 for more details. pub(crate) fn as_local_call_operand( &mut self, block: BasicBlock, diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index edd527286..e22fa6365 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -81,8 +81,8 @@ pub(in crate::build) struct PlaceBuilder<'tcx> { /// ProjectionElems `Downcast`, `ConstantIndex`, `Index`, or `Subslice` because those will never be /// part of a path that is captured by a closure. We stop applying projections once we see the first /// projection that isn't captured by a closure. -fn convert_to_hir_projections_and_truncate_for_capture<'tcx>( - mir_projections: &[PlaceElem<'tcx>], +fn convert_to_hir_projections_and_truncate_for_capture( + mir_projections: &[PlaceElem<'_>], ) -> Vec { let mut hir_projections = Vec::new(); let mut variant = None; diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 0814793f2..c7b3eb44d 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -142,7 +142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let exchange_malloc = Operand::function_handle( tcx, tcx.require_lang_item(LangItem::ExchangeMalloc, Some(expr_span)), - ty::List::empty(), + [], expr_span, ); let storage = this.temp(tcx.mk_mut_ptr(tcx.types.u8), expr_span); diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 218a26e62..38b1fa91d 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -183,7 +183,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { LogicalOp::And => (else_block, shortcircuit_block), LogicalOp::Or => (shortcircuit_block, else_block), }; - let term = TerminatorKind::if_(this.tcx, lhs, blocks.0, blocks.1); + let term = TerminatorKind::if_(lhs, blocks.0, blocks.1); this.cfg.terminate(block, source_info, term); this.cfg.push_assign_constant( diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs index 00dbcaeb0..780836851 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs @@ -6,10 +6,8 @@ use rustc_middle::thir::*; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds a block of MIR statements to evaluate the THIR `expr`. - /// If the original expression was an AST statement, - /// (e.g., `some().code(&here());`) then `opt_stmt_span` is the - /// span of that statement (including its semicolon, if any). - /// The scope is used if a statement temporary must be dropped. + /// + /// The `statement_scope` is used if a statement temporary must be dropped. pub(crate) fn stmt_expr( &mut self, mut block: BasicBlock, @@ -59,7 +57,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // question raised here -- should we "freeze" the // value of the lhs here? I'm inclined to think not, // since it seems closer to the semantics of the - // overloaded version, which takes `&mut self`. This + // overloaded version, which takes `&mut self`. This // only affects weird things like `x += {x += 1; x}` // -- is that equal to `x + (x + 1)` or `2*(x+1)`? @@ -115,7 +113,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // // it is usually better to focus on `the_value` rather // than the entirety of block(s) surrounding it. - let adjusted_span = (|| { + let adjusted_span = if let ExprKind::Block { block } = expr.kind && let Some(tail_ex) = this.thir[block].expr { @@ -137,10 +135,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { tail_result_is_ignored: true, span: expr.span, }); - return Some(expr.span); - } - None - })(); + Some(expr.span) + } else { + None + }; let temp = unpack!(block = this.as_temp(block, statement_scope, expr, Mutability::Not)); -- cgit v1.2.3