From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_const_eval/src/const_eval/error.rs | 13 +++++++------ compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 8 ++++---- compiler/rustc_const_eval/src/const_eval/fn_queries.rs | 2 +- compiler/rustc_const_eval/src/const_eval/machine.rs | 14 +++++++------- compiler/rustc_const_eval/src/const_eval/mod.rs | 2 +- compiler/rustc_const_eval/src/const_eval/valtrees.rs | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) (limited to 'compiler/rustc_const_eval/src/const_eval') diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 0579f7815..c591ff75a 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -3,7 +3,8 @@ use std::fmt; use rustc_errors::Diagnostic; use rustc_middle::mir::AssertKind; -use rustc_middle::ty::{layout::LayoutError, query::TyCtxtAt, ConstInt}; +use rustc_middle::query::TyCtxtAt; +use rustc_middle::ty::{layout::LayoutError, ConstInt}; use rustc_span::{Span, Symbol}; use super::InterpCx; @@ -104,13 +105,13 @@ impl<'tcx> ConstEvalErr<'tcx> { // Add spans for the stacktrace. Don't print a single-line backtrace though. if self.stacktrace.len() > 1 { // Helper closure to print duplicated lines. - let mut flush_last_line = |last_frame, times| { + let mut flush_last_line = |last_frame: Option<(String, _)>, times| { if let Some((line, span)) = last_frame { - err.span_note(span, &line); + err.span_note(span, line.clone()); // Don't print [... additional calls ...] if the number of lines is small if times < 3 { for _ in 0..times { - err.span_note(span, &line); + err.span_note(span, line.clone()); } } else { err.span_note( @@ -169,14 +170,14 @@ impl<'tcx> ConstEvalErr<'tcx> { // See . let mut err = struct_error(tcx, &self.error.to_string()); self.decorate(&mut err, decorate); - ErrorHandled::Reported(err.emit()) + ErrorHandled::Reported(err.emit().into()) } _ => { // Report as hard error. let mut err = struct_error(tcx, message); err.span_label(self.span, self.error.to_string()); self.decorate(&mut err, decorate); - ErrorHandled::Reported(err.emit()) + ErrorHandled::Reported(err.emit().into()) } } } diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 4bd6fe199..046d20529 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -296,12 +296,12 @@ pub fn eval_to_allocation_raw_provider<'tcx>( } let cid = key.value; - let def = cid.instance.def.with_opt_param(); - let is_static = tcx.is_static(def.did); + let def = cid.instance.def.def_id(); + let is_static = tcx.is_static(def); let mut ecx = InterpCx::new( tcx, - tcx.def_span(def.did), + tcx.def_span(def), key.param_env, // Statics (and promoteds inside statics) may access other statics, because unlike consts // they do not have to behave "as if" they were evaluated at runtime. @@ -368,7 +368,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>( if matches!(err.error, InterpError::UndefinedBehavior(_)) { diag.note(NOTE_ON_UNDEFINED_BEHAVIOR_ERROR); } - diag.note(&format!( + diag.note(format!( "the raw bytes of the constant ({}", display_allocation( *ecx.tcx, diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs index 088a824fd..fa8253d5e 100644 --- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs @@ -2,7 +2,7 @@ use rustc_attr as attr; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_middle::ty::query::Providers; +use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::Symbol; diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index a5dfd1072..58b5755af 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -375,18 +375,18 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, ) -> InterpResult<'tcx, &'tcx mir::Body<'tcx>> { match instance { ty::InstanceDef::Item(def) => { - if ecx.tcx.is_ctfe_mir_available(def.did) { - Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def)) - } else if ecx.tcx.def_kind(def.did) == DefKind::AssocConst { + if ecx.tcx.is_ctfe_mir_available(def) { + Ok(ecx.tcx.mir_for_ctfe(def)) + } else if ecx.tcx.def_kind(def) == DefKind::AssocConst { let guar = ecx.tcx.sess.delay_span_bug( rustc_span::DUMMY_SP, "This is likely a const item that is missing from its impl", ); - throw_inval!(AlreadyReported(guar)); + throw_inval!(AlreadyReported(guar.into())); } else { // `find_mir_or_eval_fn` checks that this is a const fn before even calling us, // so this should be unreachable. - let path = ecx.tcx.def_path_str(def.did); + let path = ecx.tcx.def_path_str(def); bug!("trying to call extern function `{path}` at compile-time"); } } @@ -410,9 +410,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, // Execution might have wandered off into other crates, so we cannot do a stability- // sensitive check here. But we can at least rule out functions that are not const // at all. - if !ecx.tcx.is_const_fn_raw(def.did) { + if !ecx.tcx.is_const_fn_raw(def) { // allow calling functions inside a trait marked with #[const_trait]. - if !ecx.tcx.is_const_default_method(def.did) { + if !ecx.tcx.is_const_default_method(def) { // We certainly do *not* want to actually call the fn // though, so be sure we return here. throw_unsup_format!("calling non-const function `{}`", instance) diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index 3cdf1e6e3..05be45fef 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -83,7 +83,7 @@ pub(crate) fn eval_to_valtree<'tcx>( Some(span) => { tcx.sess.create_err(MaxNumNodesInConstErr { span, global_const_id }) } - None => tcx.sess.struct_err(&msg), + None => tcx.sess.struct_err(msg), }; diag.emit(); diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 4d54c0183..b10f2e9f8 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -337,7 +337,7 @@ fn valtree_into_mplace<'tcx>( match ty.kind() { ty::FnDef(_, _) => { - ecx.write_immediate(Immediate::Uninit, &place.into()).unwrap(); + // Zero-sized type, nothing to do. } ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char => { let scalar_int = valtree.unwrap_leaf(); -- cgit v1.2.3