From 6f143e2fcc0b77f59cba29420893aecaf5acd7a3 Mon Sep 17 00:00:00 2001 From: fpoli Date: Wed, 1 Nov 2023 07:03:19 +0000 Subject: [PATCH 1/3] Update dependencies (rustc nightly-2023-11-01, viper v-2023-09-27-0729) --- rust-toolchain | 2 +- viper-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 4439ba166b4..cfc684df940 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2023-09-15" +channel = "nightly-2023-11-01" components = [ "rustc-dev", "llvm-tools-preview", "rust-std", "rustfmt", "clippy" ] profile = "minimal" diff --git a/viper-toolchain b/viper-toolchain index ced0143ddf2..56fc2002030 100644 --- a/viper-toolchain +++ b/viper-toolchain @@ -1 +1 @@ -v-2023-08-26-2125 +v-2023-09-27-0729 From 43b4f7449ad792db9fc5b995f44bcce3086911a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Fiala?= Date: Mon, 13 Nov 2023 17:23:45 +0100 Subject: [PATCH 2/3] Fix some issues --- analysis/src/bin/analysis-driver.rs | 7 ++-- analysis/src/bin/gen-accessibility-driver.rs | 7 ++-- .../domains/definitely_accessible/state.rs | 6 ++-- analysis/src/mir_utils.rs | 8 +++-- prusti-interface/src/environment/body.rs | 2 +- .../src/environment/borrowck/regions.rs | 1 + .../src/environment/debug_utils/to_text.rs | 2 +- prusti-interface/src/environment/loops.rs | 11 ++++--- .../src/environment/mir_body/graphviz.rs | 2 +- .../environment/mir_body/patch/compiler.rs | 12 ++++--- .../src/environment/mir_utils/all_places.rs | 2 +- .../src/environment/mir_utils/real_edges.rs | 2 +- .../mir_utils/split_aggregate_assignment.rs | 2 +- prusti-launch/src/bin/cargo-prusti.rs | 4 ++- prusti-viper/src/encoder/encoder.rs | 10 +++--- .../src/encoder/mir/constants/interface.rs | 8 ++--- .../src/encoder/mir/contracts/borrows.rs | 4 +-- .../encoder/elaborate_drops/mir_dataflow.rs | 10 +++--- .../encoder/elaborate_drops/mir_transform.rs | 18 +++-------- .../encoder/mir/procedures/encoder/ghost.rs | 4 +-- .../mir/procedures/encoder/initialisation.rs | 11 +------ .../src/encoder/mir/procedures/encoder/mod.rs | 14 ++++---- .../mir/pure/interpreter/interpreter_high.rs | 12 +++---- .../mir/pure/interpreter/interpreter_poly.rs | 8 ++--- .../mir/pure/pure_functions/encoder_poly.rs | 2 +- .../mir/pure/pure_functions/interface.rs | 4 +-- .../src/encoder/mir/sequences/encoder.rs | 4 +-- .../src/encoder/mir/types/const_parameters.rs | 5 ++- prusti-viper/src/encoder/mir/types/encoder.rs | 5 ++- .../src/encoder/mir/types/interface.rs | 2 +- .../src/encoder/mir/types/lifetimes.rs | 5 ++- prusti-viper/src/encoder/mir_encoder/mod.rs | 10 +++--- prusti-viper/src/encoder/procedure_encoder.rs | 32 +++++++++---------- .../src/encoder/snapshot/interface.rs | 6 ++-- prusti-viper/src/utils/mod.rs | 4 +-- 35 files changed, 112 insertions(+), 134 deletions(-) diff --git a/analysis/src/bin/analysis-driver.rs b/analysis/src/bin/analysis-driver.rs index 75f27dd4a33..8eb9e461596 100644 --- a/analysis/src/bin/analysis-driver.rs +++ b/analysis/src/bin/analysis-driver.rs @@ -19,10 +19,7 @@ use prusti_rustc_interface::{ errors, hir::def_id::{DefId, LocalDefId}, interface::{interface, Config, Queries}, - middle::{ - query::{queries::mir_borrowck::ProvidedValue, ExternProviders, Providers}, - ty, - }, + middle::{query::queries::mir_borrowck::ProvidedValue, ty, util::Providers}, polonius_engine::{Algorithm, Output}, session::{self, Attribute, EarlyErrorHandler, Session}, }; @@ -134,7 +131,7 @@ fn mir_borrowck<'tcx>(tcx: ty::TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValu original_mir_borrowck(tcx, def_id) } -fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) { +fn override_queries(_session: &Session, local: &mut Providers) { local.mir_borrowck = mir_borrowck; } diff --git a/analysis/src/bin/gen-accessibility-driver.rs b/analysis/src/bin/gen-accessibility-driver.rs index 832d0f421e1..ecc68f290a5 100644 --- a/analysis/src/bin/gen-accessibility-driver.rs +++ b/analysis/src/bin/gen-accessibility-driver.rs @@ -12,10 +12,7 @@ use prusti_rustc_interface::{ errors, hir, hir::def_id::LocalDefId, interface::{interface, Config, Queries}, - middle::{ - query::{queries::mir_borrowck::ProvidedValue, ExternProviders, Providers}, - ty, - }, + middle::{query::queries::mir_borrowck::ProvidedValue, ty, util::Providers}, polonius_engine::{Algorithm, Output}, session::{self, EarlyErrorHandler, Session}, span::FileName, @@ -86,7 +83,7 @@ fn mir_borrowck<'tcx>(tcx: ty::TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValu original_mir_borrowck(tcx, def_id) } -fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) { +fn override_queries(_session: &Session, local: &mut Providers) { local.mir_borrowck = mir_borrowck; } diff --git a/analysis/src/domains/definitely_accessible/state.rs b/analysis/src/domains/definitely_accessible/state.rs index f27680c876b..b5a0740bbed 100644 --- a/analysis/src/domains/definitely_accessible/state.rs +++ b/analysis/src/domains/definitely_accessible/state.rs @@ -10,11 +10,10 @@ use crate::{ }; use log::info; use prusti_rustc_interface::{ - abi::FieldIdx, data_structures::fx::{FxHashMap, FxHashSet}, middle::{mir, ty, ty::TyCtxt}, span::source_map::SourceMap, - target::abi::VariantIdx, + target::abi::{FieldIdx, VariantIdx}, }; use serde::{ser::SerializeMap, Serialize, Serializer}; use std::fmt; @@ -228,6 +227,7 @@ fn pretty_print_place<'tcx>( // It's not possible to move-out or borrow an individual element. unreachable!() } + mir::ProjectionElem::Subtype(_) => todo!(), } } @@ -262,7 +262,7 @@ fn describe_field_from_ty( ty::TyKind::Array(ty, _) | ty::TyKind::Slice(ty) => { describe_field_from_ty(tcx, ty, field, variant_index) } - ty::TyKind::Closure(..) | ty::TyKind::Generator(..) => { + ty::TyKind::Closure(..) | ty::TyKind::Coroutine(..) => { // Supporting these cases is complex None } diff --git a/analysis/src/mir_utils.rs b/analysis/src/mir_utils.rs index 24980c4916d..9111a11ef0e 100644 --- a/analysis/src/mir_utils.rs +++ b/analysis/src/mir_utils.rs @@ -8,13 +8,13 @@ //! copied from prusti-interface/utils use prusti_rustc_interface::{ - abi::FieldIdx, data_structures::fx::FxHashSet, infer::infer::TyCtxtInferExt, middle::{ mir, ty::{self, TyCtxt}, }, + target::abi::FieldIdx, trait_selection::infer::InferCtxtExt, }; use std::mem; @@ -165,8 +165,8 @@ pub fn expand_struct_place<'tcx, P: PlaceImpl<'tcx> + std::marker::Copy>( } } } - ty::Generator(_, substs, _) => { - for (index, subst_ty) in substs.as_generator().upvar_tys().iter().enumerate() { + ty::Coroutine(_, substs, _) => { + for (index, subst_ty) in substs.as_coroutine().upvar_tys().iter().enumerate() { if Some(index) != without_field { let field = FieldIdx::from_usize(index); let field_place = tcx.mk_place_field(place.to_mir_place(), field, subst_ty); @@ -209,6 +209,7 @@ pub fn expand_one_level<'tcx>( | mir::ProjectionElem::Subslice { .. } | mir::ProjectionElem::Downcast(..) | mir::ProjectionElem::OpaqueCast(..) => vec![], + mir::ProjectionElem::Subtype(_) => todo!(), }; (new_current_place, other_places) } @@ -338,6 +339,7 @@ pub fn get_blocked_place<'tcx>(tcx: TyCtxt<'tcx>, borrowed: Place<'tcx>) -> Plac | mir::ProjectionElem::OpaqueCast(..) => { // Continue } + mir::ProjectionElem::Subtype(_) => todo!(), } } borrowed diff --git a/prusti-interface/src/environment/body.rs b/prusti-interface/src/environment/body.rs index 90c7229d2d3..c5320063a5a 100644 --- a/prusti-interface/src/environment/body.rs +++ b/prusti-interface/src/environment/body.rs @@ -174,7 +174,7 @@ impl<'tcx> EnvBody<'tcx> { { let monomorphised = if let Some(caller_def_id) = caller_def_id { let param_env = self.tcx.param_env(caller_def_id); - self.tcx.subst_and_normalize_erasing_regions( + self.tcx.instantiate_and_normalize_erasing_regions( substs, param_env, ty::EarlyBinder::bind(body.0), diff --git a/prusti-interface/src/environment/borrowck/regions.rs b/prusti-interface/src/environment/borrowck/regions.rs index a22f6426003..a9822401244 100644 --- a/prusti-interface/src/environment/borrowck/regions.rs +++ b/prusti-interface/src/environment/borrowck/regions.rs @@ -80,6 +80,7 @@ impl PlaceRegions { not supported" .to_string(), )), + mir::ProjectionElem::Subtype(_) => todo!(), }) .collect::>()?; Ok((place.local, indices)) diff --git a/prusti-interface/src/environment/debug_utils/to_text.rs b/prusti-interface/src/environment/debug_utils/to_text.rs index 88f8d1aa440..66ed84f4175 100644 --- a/prusti-interface/src/environment/debug_utils/to_text.rs +++ b/prusti-interface/src/environment/debug_utils/to_text.rs @@ -67,7 +67,7 @@ impl ToText impl ToText for prusti_rustc_interface::middle::ty::BoundRegionKind { fn to_text(&self) -> String { match self { - prusti_rustc_interface::middle::ty::BoundRegionKind::BrAnon(_) => { + prusti_rustc_interface::middle::ty::BoundRegionKind::BrAnon => { "lft_br_anon".to_string() } prusti_rustc_interface::middle::ty::BoundRegionKind::BrNamed(_, name) => { diff --git a/prusti-interface/src/environment/loops.rs b/prusti-interface/src/environment/loops.rs index 52f8532fde7..91bf26bf055 100644 --- a/prusti-interface/src/environment/loops.rs +++ b/prusti-interface/src/environment/loops.rs @@ -377,10 +377,13 @@ impl ProcedureLoops { } for &(back_edge_source, loop_head) in back_edges.iter() { let blocks = nonconditional_loop_blocks.get_mut(&loop_head).unwrap(); - *blocks = blocks - .intersection(&dominators.dominators(back_edge_source).collect()) - .copied() - .collect(); + let mut doms: FxHashSet<_> = [back_edge_source].into_iter().collect(); + let mut curr = back_edge_source; + while let Some(dom) = dominators.immediate_dominator(curr) { + doms.insert(dom); + curr = dom; + } + *blocks = blocks.intersection(&doms).copied().collect(); } debug!( "nonconditional_loop_blocks: {:?}", diff --git a/prusti-interface/src/environment/mir_body/graphviz.rs b/prusti-interface/src/environment/mir_body/graphviz.rs index 695d6299d6d..9fbf426b808 100644 --- a/prusti-interface/src/environment/mir_body/graphviz.rs +++ b/prusti-interface/src/environment/mir_body/graphviz.rs @@ -208,7 +208,7 @@ fn visit_terminator(graph: &mut Graph, bb: mir::BasicBlock, terminator: &mir::Te TerminatorKind::Yield { .. } => { graph.add_exit_edge(bb.to_text(), "yield".to_text()); } - TerminatorKind::GeneratorDrop => { + TerminatorKind::CoroutineDrop => { graph.add_exit_edge(bb.to_text(), "generator_drop".to_text()); } TerminatorKind::FalseEdge { diff --git a/prusti-interface/src/environment/mir_body/patch/compiler.rs b/prusti-interface/src/environment/mir_body/patch/compiler.rs index fc61b278ad3..2963ca53e2b 100644 --- a/prusti-interface/src/environment/mir_body/patch/compiler.rs +++ b/prusti-interface/src/environment/mir_body/patch/compiler.rs @@ -50,7 +50,9 @@ impl<'tcx> MirPatch<'tcx> { for (bb, block) in body.basic_blocks.iter_enumerated() { // Check if we already have a resume block - if let TerminatorKind::UnwindResume = block.terminator().kind && block.statements.is_empty() { + if let TerminatorKind::UnwindResume = block.terminator().kind + && block.statements.is_empty() + { result.resume_block = Some(bb); continue; } @@ -65,7 +67,9 @@ impl<'tcx> MirPatch<'tcx> { } // Check if we already have a terminate block - if let TerminatorKind::UnwindTerminate(..) = block.terminator().kind && block.statements.is_empty() { + if let TerminatorKind::UnwindTerminate(..) = block.terminator().kind + && block.statements.is_empty() + { result.terminate_block = Some(bb); continue; } @@ -148,7 +152,7 @@ impl<'tcx> MirPatch<'tcx> { ) -> Local { let index = self.next_local; self.next_local += 1; - let mut new_decl = LocalDecl::new(ty, span).internal(); + let mut new_decl = LocalDecl::new(ty, span); **new_decl.local_info.as_mut().assert_crate_local() = local_info; self.new_locals.push(new_decl); Local::new(index) @@ -164,7 +168,7 @@ impl<'tcx> MirPatch<'tcx> { pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local { let index = self.next_local; self.next_local += 1; - self.new_locals.push(LocalDecl::new(ty, span).internal()); + self.new_locals.push(LocalDecl::new(ty, span)); Local::new(index) } diff --git a/prusti-interface/src/environment/mir_utils/all_places.rs b/prusti-interface/src/environment/mir_utils/all_places.rs index 24daedecbab..1e0d850f019 100644 --- a/prusti-interface/src/environment/mir_utils/all_places.rs +++ b/prusti-interface/src/environment/mir_utils/all_places.rs @@ -1,6 +1,6 @@ use prusti_rustc_interface::{ - abi::FieldIdx, middle::{mir, ty}, + target::abi::FieldIdx, }; pub trait AllPlaces<'tcx> { diff --git a/prusti-interface/src/environment/mir_utils/real_edges.rs b/prusti-interface/src/environment/mir_utils/real_edges.rs index 9ce8ca3b58e..8cf724c80d7 100644 --- a/prusti-interface/src/environment/mir_utils/real_edges.rs +++ b/prusti-interface/src/environment/mir_utils/real_edges.rs @@ -55,7 +55,7 @@ fn real_targets(terminator: &mir::Terminator) -> Vec { TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(..) | TerminatorKind::Return - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Unreachable => vec![], TerminatorKind::Drop { ref target, .. } => vec![*target], diff --git a/prusti-interface/src/environment/mir_utils/split_aggregate_assignment.rs b/prusti-interface/src/environment/mir_utils/split_aggregate_assignment.rs index 723a5f9a737..15b6f77aaf5 100644 --- a/prusti-interface/src/environment/mir_utils/split_aggregate_assignment.rs +++ b/prusti-interface/src/environment/mir_utils/split_aggregate_assignment.rs @@ -1,7 +1,7 @@ use super::{SliceOrArrayRef, TupleItemsForTy}; use prusti_rustc_interface::{ - abi::FieldIdx, middle::{mir, ty}, + target::abi::FieldIdx, }; pub trait SplitAggregateAssignment<'tcx> { diff --git a/prusti-launch/src/bin/cargo-prusti.rs b/prusti-launch/src/bin/cargo-prusti.rs index d3ebce4ea57..83153d1fb08 100644 --- a/prusti-launch/src/bin/cargo-prusti.rs +++ b/prusti-launch/src/bin/cargo-prusti.rs @@ -84,7 +84,9 @@ fn copy_exported_specs(cargo_target: PathBuf) -> io::Result<()> { if build_dir.is_dir() && deps_dir.is_dir() { for entry in fs::read_dir(deps_dir)? { let entry = entry?.path(); - if let Some(ext) = entry.extension() && ext == "specs" { + if let Some(ext) = entry.extension() + && ext == "specs" + { if let Some(fname) = entry.file_name() { let pkg_name = fname.to_string_lossy(); if let Some(pkg_name) = pkg_name.split('-').next() { diff --git a/prusti-viper/src/encoder/encoder.rs b/prusti-viper/src/encoder/encoder.rs index 5a1407f86c7..52e303a3e98 100644 --- a/prusti-viper/src/encoder/encoder.rs +++ b/prusti-viper/src/encoder/encoder.rs @@ -341,10 +341,10 @@ impl<'v, 'tcx> Encoder<'v, 'tcx> { /// Extract scalar value, invoking const evaluation if necessary. pub fn const_eval_intlike( &self, - value: mir::ConstantKind<'tcx>, + value: mir::Const<'tcx>, ) -> EncodingResult { let opt_scalar_value = match value { - mir::ConstantKind::Ty(value) => match value.kind() { + mir::Const::Ty(value) => match value.kind() { ty::ConstKind::Value(ref const_value) => const_value.try_to_scalar(), ty::ConstKind::Unevaluated(ct) => { let mir_ct = mir::UnevaluatedConst::new(ct.def, ct.args); @@ -352,8 +352,8 @@ impl<'v, 'tcx> Encoder<'v, 'tcx> { } _ => error_unsupported!("unsupported const kind: {:?}", value), }, - mir::ConstantKind::Val(val, _) => val.try_to_scalar(), - mir::ConstantKind::Unevaluated(ct, _) => self.uneval_eval_intlike(ct), + mir::Const::Val(val, _) => val.try_to_scalar(), + mir::Const::Unevaluated(ct, _) => self.uneval_eval_intlike(ct), }; opt_scalar_value.ok_or_else(|| { EncodingError::unsupported(format!("unsupported constant value: {value:?}")) @@ -669,7 +669,7 @@ impl<'v, 'tcx> Encoder<'v, 'tcx> { pub fn encode_const_expr( &self, ty: ty::Ty<'tcx>, - value: mir::ConstantKind<'tcx>, + value: mir::Const<'tcx>, ) -> EncodingResult { let scalar_value = self.const_eval_intlike(value)?; diff --git a/prusti-viper/src/encoder/mir/constants/interface.rs b/prusti-viper/src/encoder/mir/constants/interface.rs index 41b3dd1e814..014c68e67b7 100644 --- a/prusti-viper/src/encoder/mir/constants/interface.rs +++ b/prusti-viper/src/encoder/mir/constants/interface.rs @@ -9,7 +9,7 @@ use crate::{ pub(crate) trait ConstantsEncoderInterface<'tcx> { fn encode_constant_high( &self, - constant: &mir::Constant<'tcx>, + constant: &mir::ConstOperand<'tcx>, ) -> EncodingResult; fn compute_array_len(&self, size: ty::Const<'tcx>) -> EncodingResult; @@ -19,12 +19,12 @@ impl<'v, 'tcx: 'v> ConstantsEncoderInterface<'tcx> for super::super::super::Enco #[tracing::instrument(level = "debug", skip(self), ret)] fn encode_constant_high( &self, - constant: &mir::Constant<'tcx>, + constant: &mir::ConstOperand<'tcx>, ) -> EncodingResult { let mir_type = constant.ty(); let _ = self.encode_type_high(mir_type)?; // Trigger encoding of the type. // FIXME: encode_snapshot_constant also handled non literal constants - let scalar_value = || self.const_eval_intlike(constant.literal); + let scalar_value = || self.const_eval_intlike(constant.const_); let expr = match mir_type.kind() { ty::TyKind::Bool => scalar_value()?.to_bool().unwrap().into(), @@ -74,7 +74,7 @@ impl<'v, 'tcx: 'v> ConstantsEncoderInterface<'tcx> for super::super::super::Enco } fn compute_array_len(&self, size: ty::Const<'tcx>) -> EncodingResult { - self.const_eval_intlike(mir::ConstantKind::Ty(size)) + self.const_eval_intlike(mir::Const::Ty(size)) .map(|s| s.to_u64().unwrap()) } } diff --git a/prusti-viper/src/encoder/mir/contracts/borrows.rs b/prusti-viper/src/encoder/mir/contracts/borrows.rs index 8bea77c393c..ceac94a3b8b 100644 --- a/prusti-viper/src/encoder/mir/contracts/borrows.rs +++ b/prusti-viper/src/encoder/mir/contracts/borrows.rs @@ -9,12 +9,12 @@ use crate::{ utils::type_visitor::{self, TypeVisitor}, }; use prusti_rustc_interface::{ - abi::FieldIdx, hir::{self as hir, Mutability}, middle::{ mir, ty::{self, Ty, TyCtxt, TyKind}, }, + target::abi::FieldIdx, }; use std::fmt; @@ -44,7 +44,7 @@ impl fmt::Display for BorrowInfo

{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let lifetime = match self.region { None => "static".to_string(), - Some(ty::BoundRegionKind::BrAnon(_)) => "anon".to_string(), + Some(ty::BoundRegionKind::BrAnon) => "anon".to_string(), Some(ty::BoundRegionKind::BrNamed(_, name)) => name.to_string(), _ => unimplemented!(), }; diff --git a/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_dataflow.rs b/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_dataflow.rs index dba6aed929e..8dd85db807b 100644 --- a/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_dataflow.rs +++ b/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_dataflow.rs @@ -14,7 +14,6 @@ use log::debug; use prusti_interface::environment::mir_body::patch::MirPatch; use prusti_rustc_interface::{ - abi::{FieldIdx, VariantIdx, FIRST_VARIANT}, dataflow::elaborate_drops::{DropFlagMode, DropStyle, Unwind}, hir, hir::lang_items::LangItem, @@ -24,6 +23,7 @@ use prusti_rustc_interface::{ traits::Reveal, ty::{self, util::IntTypeExt, GenericArgsRef, Ty, TyCtxt}, }, + target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}, }; use std::{fmt, iter}; use tracing::instrument; @@ -852,8 +852,8 @@ where // This should only happen for the self argument on the resume function. // It effectively only contains upvars until the generator transformation runs. // See librustc_body/transform/generator.rs for more details. - ty::Generator(_, args, _) => { - let tys: Vec<_> = args.as_generator().upvar_tys().iter().collect(); + ty::Coroutine(_, args, _) => { + let tys: Vec<_> = args.as_coroutine().upvar_tys().iter().collect(); self.open_drop_for_tuple(&tys) } ty::Tuple(fields) => self.open_drop_for_tuple(fields), @@ -968,10 +968,10 @@ where } fn constant_usize(&self, val: u16) -> Operand<'tcx> { - Operand::Constant(Box::new(Constant { + Operand::Constant(Box::new(ConstOperand { span: self.source_info.span, user_ty: None, - literal: ConstantKind::from_usize(self.tcx(), val.into()), + const_: Const::from_usize(self.tcx(), val.into()), })) } diff --git a/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_transform.rs b/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_transform.rs index e80f60df5e7..ff536c342a3 100644 --- a/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_transform.rs +++ b/prusti-viper/src/encoder/mir/procedures/encoder/elaborate_drops/mir_transform.rs @@ -14,7 +14,6 @@ use super::mir_dataflow::{elaborate_drop, DropElaborator}; use log::debug; use prusti_interface::environment::mir_body::patch::MirPatch; use prusti_rustc_interface::{ - abi::FieldIdx, dataflow::{ elaborate_drops::{DropFlagMode, DropFlagState, DropStyle, Unwind}, impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces}, @@ -28,7 +27,7 @@ use prusti_rustc_interface::{ ty::{self, TyCtxt}, }, span::Span, - target::abi::VariantIdx, + target::abi::{FieldIdx, VariantIdx}, }; use std::fmt; @@ -65,16 +64,7 @@ pub(in super::super) fn run_pass<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) let def_id = body.source.def_id(); let param_env = tcx.param_env_reveal_all_normalized(def_id); - let move_data = match MoveData::gather_moves(body, tcx, param_env) { - Ok(move_data) => move_data, - Err((move_data, _)) => { - tcx.sess.delay_span_bug( - body.span, - "No `move_errors` should be allowed in MIR borrowck", - ); - move_data - } - }; + let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true); let elaborate_patch = { let env = MoveDataParamEnv { move_data, @@ -494,10 +484,10 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { } fn constant_bool(&self, span: Span, val: bool) -> Rvalue<'tcx> { - Rvalue::Use(Operand::Constant(Box::new(Constant { + Rvalue::Use(Operand::Constant(Box::new(ConstOperand { span, user_ty: None, - literal: ConstantKind::from_bool(self.tcx, val), + const_: Const::from_bool(self.tcx, val), }))) } diff --git a/prusti-viper/src/encoder/mir/procedures/encoder/ghost.rs b/prusti-viper/src/encoder/mir/procedures/encoder/ghost.rs index a76476ac167..39a184792c8 100644 --- a/prusti-viper/src/encoder/mir/procedures/encoder/ghost.rs +++ b/prusti-viper/src/encoder/mir/procedures/encoder/ghost.rs @@ -100,10 +100,10 @@ impl<'a, 'p, 'v, 'tcx> Visitor<'tcx> for GhostChecker<'a, 'p, 'v, 'tcx> { if self.is_ghost_place(location) { match &term.kind { mir::TerminatorKind::Call { - func: mir::Operand::Constant(box mir::Constant { literal, .. }), + func: mir::Operand::Constant(box mir::ConstOperand { const_, .. }), .. } => { - if let ty::TyKind::FnDef(def_id, _call_substs) = literal.ty().kind() { + if let ty::TyKind::FnDef(def_id, _call_substs) = const_.ty().kind() { if !self.p.encoder.is_pure(*def_id, None) { self.violations.push(SpannedEncodingError::incorrect( "Only pure function calls are allowed in ghost blocks.", diff --git a/prusti-viper/src/encoder/mir/procedures/encoder/initialisation.rs b/prusti-viper/src/encoder/mir/procedures/encoder/initialisation.rs index 351a190f746..c325e4eea0d 100644 --- a/prusti-viper/src/encoder/mir/procedures/encoder/initialisation.rs +++ b/prusti-viper/src/encoder/mir/procedures/encoder/initialisation.rs @@ -47,16 +47,7 @@ pub(super) fn create_move_data_param_env_and_un_derefer<'tcx>( ) -> MoveDataParamEnv<'tcx> { let def_id = body.source.def_id(); let param_env = tcx.param_env_reveal_all_normalized(def_id); - let move_data = match MoveData::gather_moves(body, tcx, param_env) { - Ok(move_data) => move_data, - Err((move_data, _)) => { - tcx.sess.delay_span_bug( - body.span, - "No `move_errors` should be allowed in MIR borrowck", - ); - move_data - } - }; + let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true); MoveDataParamEnv { move_data, diff --git a/prusti-viper/src/encoder/mir/procedures/encoder/mod.rs b/prusti-viper/src/encoder/mir/procedures/encoder/mod.rs index 7a552096133..1be1c45450f 100644 --- a/prusti-viper/src/encoder/mir/procedures/encoder/mod.rs +++ b/prusti-viper/src/encoder/mir/procedures/encoder/mod.rs @@ -34,12 +34,12 @@ use prusti_interface::environment::{ Procedure, }; use prusti_rustc_interface::{ - abi::FieldIdx, data_structures::graph::WithStartNode, hir::def_id::DefId, index::IndexSlice, middle::{mir, ty, ty::GenericArgsRef}, span::Span, + target::abi::FieldIdx, }; use rustc_hash::FxHashSet; use std::collections::{BTreeMap, BTreeSet}; @@ -866,7 +866,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { ty } mir::AggregateKind::Closure(_, _) => unimplemented!(), - mir::AggregateKind::Generator(_, _, _) => unimplemented!(), + mir::AggregateKind::Coroutine(_, _, _) => unimplemented!(), }; let base_lifetimes = ty.get_lifetimes(); let lifetime_replacement_map = self @@ -1225,7 +1225,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { *unwind, )?, TerminatorKind::Call { - func: mir::Operand::Constant(box mir::Constant { literal, .. }), + func: mir::Operand::Constant(box mir::ConstOperand { const_, .. }), args, destination, target, @@ -1237,7 +1237,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { block_builder, location, span, - literal.ty(), + const_.ty(), args, *destination, target, @@ -1265,7 +1265,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { // TerminatorKind::Yield { .. } => { // graph.add_exit_edge(bb, "yield"); // } - // TerminatorKind::GeneratorDrop => { + // TerminatorKind::CoroutineDrop => { // graph.add_exit_edge(bb, "generator_drop"); // } TerminatorKind::FalseEdge { @@ -2087,7 +2087,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { let span = self.encoder.get_mir_terminator_span(block.terminator()); match &block.terminator().kind { mir::TerminatorKind::Call { - func: mir::Operand::Constant(box mir::Constant { literal, .. }), + func: mir::Operand::Constant(box mir::ConstOperand { const_, .. }), args, destination: _, target: _, @@ -2095,7 +2095,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { fn_span: _, call_source: _, } => { - if let ty::TyKind::FnDef(def_id, _substs) = literal.ty().kind() { + if let ty::TyKind::FnDef(def_id, _substs) = const_.ty().kind() { let full_called_function_name = self.encoder.env().name.get_absolute_item_name(*def_id); match full_called_function_name.as_ref() { diff --git a/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_high.rs b/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_high.rs index 5730657c396..2dbde2c4ebf 100644 --- a/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_high.rs +++ b/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_high.rs @@ -31,11 +31,11 @@ use log::{debug, trace}; use prusti_common::vir_high_local; use prusti_interface::environment::mir_utils::SliceOrArrayRef; use prusti_rustc_interface::{ - abi::FieldIdx, hir::def_id::DefId, index::IndexSlice, middle::{mir, ty, ty::GenericArgsRef}, span::Span, + target::abi::FieldIdx, }; use rustc_hash::FxHashMap; use vir_crate::{ @@ -145,7 +145,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ExpressionBackwardInterpreter<'p, 'v, 'tcx> { let rhs = vir_high::Expression::constructor_no_pos(ty_with_variant, arguments); state.substitute_value(lhs, rhs); } - mir::AggregateKind::Generator(_def_id, _subst, _) => { + mir::AggregateKind::Coroutine(_def_id, _subst, _) => { return Err(SpannedEncodingError::unsupported( format!("Unsupported aggregate type: {aggregate:?}"), span, @@ -319,7 +319,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ExpressionBackwardInterpreter<'p, 'v, 'tcx> { let encoded_operand = self.encode_operand(operand, span)?; let len: usize = self .encoder - .const_eval_intlike(mir::ConstantKind::Ty(*times)) + .const_eval_intlike(mir::Const::Ty(*times)) .with_span(span)? .to_u64() .unwrap() @@ -951,10 +951,10 @@ impl<'p, 'v: 'p, 'tcx: 'v> BackwardMirInterpreter<'tcx> args, destination, target, - func: mir::Operand::Constant(box mir::Constant { literal, .. }), + func: mir::Operand::Constant(box mir::ConstOperand { const_, .. }), .. } => { - self.apply_call_terminator(args, *destination, target, literal.ty(), states, span)? + self.apply_call_terminator(args, *destination, target, const_.ty(), states, span)? } TerminatorKind::Call { .. } => { @@ -1026,7 +1026,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> BackwardMirInterpreter<'tcx> } TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::InlineAsm { .. } => { return Err(SpannedEncodingError::unsupported( format!( diff --git a/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_poly.rs b/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_poly.rs index 8d20ad75dbb..4f01460e6ab 100644 --- a/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_poly.rs +++ b/prusti-viper/src/encoder/mir/pure/interpreter/interpreter_poly.rs @@ -134,8 +134,8 @@ impl<'p, 'v: 'p, 'tcx: 'v> PureFunctionBackwardInterpreter<'p, 'v, 'tcx> { &mir::Operand::Move(place) | &mir::Operand::Copy(place) => { Ok((self.encode_place(place)?.0, false)) } - mir::Operand::Constant(constant) => match constant.literal { - mir::ConstantKind::Unevaluated(c, _cty) => { + mir::Operand::Constant(constant) => match constant.const_ { + mir::Const::Unevaluated(c, _cty) => { Ok((self.encoder.encode_uneval_const(c)?, true)) } _ => Ok((self.encoder.encode_snapshot_constant(constant)?, true)), @@ -786,7 +786,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> BackwardMirInterpreter<'tcx> } TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::InlineAsm { .. } => { return Err(SpannedEncodingError::internal( format!("unimplemented encoding of terminator '{:?}'", term.kind), @@ -1249,7 +1249,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> BackwardMirInterpreter<'tcx> mir::Rvalue::Repeat(ref operand, times) => { let (encoded_operand, _) = self.encode_operand(operand).with_span(span)?; - let len: usize = self.encoder.const_eval_intlike(mir::ConstantKind::Ty(*times)).with_span(span)? + let len: usize = self.encoder.const_eval_intlike(mir::Const::Ty(*times)).with_span(span)? .to_u64().unwrap().try_into().unwrap(); let elem_ty = operand.ty(self.mir, self.encoder.env().tcx()); let encoded_elem_ty = self.encoder.encode_snapshot_type(elem_ty) diff --git a/prusti-viper/src/encoder/mir/pure/pure_functions/encoder_poly.rs b/prusti-viper/src/encoder/mir/pure/pure_functions/encoder_poly.rs index 7de3b1fdc2e..3d653c6c73b 100644 --- a/prusti-viper/src/encoder/mir/pure/pure_functions/encoder_poly.rs +++ b/prusti-viper/src/encoder/mir/pure/pure_functions/encoder_poly.rs @@ -88,7 +88,7 @@ pub(super) fn encode_promoted<'p, 'v: 'p, 'tcx: 'v>( let tcx = encoder.env().tcx(); let promoted_bodies = tcx.promoted_mir(proc_def_id); let param_env = tcx.param_env(parent_def_id); - let mir = tcx.subst_and_normalize_erasing_regions( + let mir = tcx.instantiate_and_normalize_erasing_regions( substs, param_env, ty::EarlyBinder::bind(promoted_bodies[promoted_id].clone()), diff --git a/prusti-viper/src/encoder/mir/pure/pure_functions/interface.rs b/prusti-viper/src/encoder/mir/pure/pure_functions/interface.rs index 49e44c76b25..bf29c8793f8 100644 --- a/prusti-viper/src/encoder/mir/pure/pure_functions/interface.rs +++ b/prusti-viper/src/encoder/mir/pure/pure_functions/interface.rs @@ -50,8 +50,8 @@ fn compute_key<'v, 'tcx: 'v>( tcx.fn_sig(proc_def_id) }; let param_env = tcx.param_env(caller_def_id); - let sig = tcx.subst_and_normalize_erasing_regions(substs, param_env, sig); - let substs = tcx.subst_and_normalize_erasing_regions( + let sig = tcx.instantiate_and_normalize_erasing_regions(substs, param_env, sig); + let substs = tcx.instantiate_and_normalize_erasing_regions( substs, param_env, encoder.env().identity_substs(proc_def_id), diff --git a/prusti-viper/src/encoder/mir/sequences/encoder.rs b/prusti-viper/src/encoder/mir/sequences/encoder.rs index d81e3d9baa9..22a2887f774 100644 --- a/prusti-viper/src/encoder/mir/sequences/encoder.rs +++ b/prusti-viper/src/encoder/mir/sequences/encoder.rs @@ -12,9 +12,7 @@ pub(super) fn encode_sequence_types<'p, 'v: 'p, 'tcx: 'v>( let (elem_ty_rs, sequence_len) = match sequence_ty_rs.kind() { ty::TyKind::Array(elem_ty, array_len) => { let len = encoder - .const_eval_intlike(prusti_rustc_interface::middle::mir::ConstantKind::Ty( - *array_len, - ))? + .const_eval_intlike(prusti_rustc_interface::middle::mir::Const::Ty(*array_len))? .to_u64() .unwrap() .try_into() diff --git a/prusti-viper/src/encoder/mir/types/const_parameters.rs b/prusti-viper/src/encoder/mir/types/const_parameters.rs index 3fa4827918b..6cfec0e5c14 100644 --- a/prusti-viper/src/encoder/mir/types/const_parameters.rs +++ b/prusti-viper/src/encoder/mir/types/const_parameters.rs @@ -82,9 +82,8 @@ pub(super) fn extract_const_parameters_from_type<'tcx>( ty::TyKind::Bound(_, _) | ty::TyKind::Placeholder(_) | ty::TyKind::Infer(_) - | ty::TyKind::Generator(..) - | ty::TyKind::GeneratorWitness(_) - | ty::TyKind::GeneratorWitnessMIR(..) => { + | ty::TyKind::Coroutine(..) + | ty::TyKind::CoroutineWitness(..) => { return Err(SpannedEncodingError::unsupported( format!( "unsupported type to extract const_parameters: {:?}", diff --git a/prusti-viper/src/encoder/mir/types/encoder.rs b/prusti-viper/src/encoder/mir/types/encoder.rs index 6442b52ff4e..91a4e75fa08 100644 --- a/prusti-viper/src/encoder/mir/types/encoder.rs +++ b/prusti-viper/src/encoder/mir/types/encoder.rs @@ -268,8 +268,7 @@ impl<'p, 'v, 'r: 'v, 'tcx: 'v> TypeEncoder<'p, 'v, 'tcx> { | ty::TyKind::Ref(_, _, _) | ty::TyKind::FnPtr(_) | ty::TyKind::Dynamic(..) - | ty::TyKind::GeneratorWitness(..) - | ty::TyKind::GeneratorWitnessMIR(..) + | ty::TyKind::CoroutineWitness(..) | ty::TyKind::Never | ty::TyKind::Tuple(_) | ty::TyKind::Param(_) @@ -281,7 +280,7 @@ impl<'p, 'v, 'r: 'v, 'tcx: 'v> TypeEncoder<'p, 'v, 'tcx> { ty::TyKind::Foreign(did) | ty::TyKind::FnDef(did, _) | ty::TyKind::Closure(did, _) - | ty::TyKind::Generator(did, _, _) + | ty::TyKind::Coroutine(did, _, _) | ty::TyKind::Alias(_, ty::AliasTy { def_id: did, .. }) => { self.encoder.env().query.get_def_span(did).into() } diff --git a/prusti-viper/src/encoder/mir/types/interface.rs b/prusti-viper/src/encoder/mir/types/interface.rs index 72a4f2cbacf..c4f62d24255 100644 --- a/prusti-viper/src/encoder/mir/types/interface.rs +++ b/prusti-viper/src/encoder/mir/types/interface.rs @@ -5,10 +5,10 @@ use crate::encoder::{ mir::types::interface::ty::GenericArgsRef, }; use prusti_rustc_interface::{ - abi::FieldIdx, errors::MultiSpan, middle::{mir, ty}, span::Span, + target::abi::FieldIdx, }; use rustc_hash::FxHashMap; use std::cell::RefCell; diff --git a/prusti-viper/src/encoder/mir/types/lifetimes.rs b/prusti-viper/src/encoder/mir/types/lifetimes.rs index c3b176c8288..963f8e07e85 100644 --- a/prusti-viper/src/encoder/mir/types/lifetimes.rs +++ b/prusti-viper/src/encoder/mir/types/lifetimes.rs @@ -93,9 +93,8 @@ pub(super) fn extract_lifetimes_from_type<'tcx>( ty::TyKind::Bound(_, _) | ty::TyKind::Placeholder(_) | ty::TyKind::Infer(_) - | ty::TyKind::Generator(..) - | ty::TyKind::GeneratorWitness(_) - | ty::TyKind::GeneratorWitnessMIR(..) => { + | ty::TyKind::Coroutine(..) + | ty::TyKind::CoroutineWitness(..) => { return Err(SpannedEncodingError::unsupported( format!("unsupported type to extract lifetimes: {:?}", ty.kind()), type_encoder.get_type_definition_span(ty), diff --git a/prusti-viper/src/encoder/mir_encoder/mod.rs b/prusti-viper/src/encoder/mir_encoder/mod.rs index 8712faff6e1..82e51cdcc1c 100644 --- a/prusti-viper/src/encoder/mir_encoder/mod.rs +++ b/prusti-viper/src/encoder/mir_encoder/mod.rs @@ -172,7 +172,7 @@ pub trait PlaceEncoder<'v, 'tcx: 'v> { (encoded_projection, field_ty, None) } - ty::TyKind::Generator(..) => { + ty::TyKind::Coroutine(..) => { error_unsupported!("generator fields are not supported"); } @@ -395,7 +395,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> MirEncoder<'p, 'v, 'tcx> { pub fn encode_operand_expr(&self, operand: &mir::Operand<'tcx>) -> EncodingResult { Ok(match operand { mir::Operand::Constant(expr) => { - self.encoder.encode_const_expr(expr.ty(), expr.literal)? + self.encoder.encode_const_expr(expr.ty(), expr.const_)? } &mir::Operand::Copy(place) | &mir::Operand::Move(place) => { // let val_place = self.eval_place(&place)?; @@ -410,7 +410,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> MirEncoder<'p, 'v, 'tcx> { place_ty, )? } // FIXME: Check whether the commented out code is necessary. - // &mir::Operand::Constant(box mir::Constant { + // &mir::Operand::Constant(box mir::ConstOperand { // ty, // literal: mir::Literal::Promoted { .. }, // .. @@ -441,7 +441,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> MirEncoder<'p, 'v, 'tcx> { // let (_, ty, _) = self.encode_place(place); // ty // } - // &mir::Operand::Constant(box mir::Constant { ty, .. }) => ty, + // &mir::Operand::Constant(box mir::ConstOperand { ty, .. }) => ty, // } operand.ty(self.mir, self.encoder.env().tcx()) } @@ -453,7 +453,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> MirEncoder<'p, 'v, 'tcx> { operand: &mir::Operand<'tcx>, ) -> EncodingResult { // match operand { - // &mir::Operand::Constant(box mir::Constant { ty, .. }) => { + // &mir::Operand::Constant(box mir::ConstOperand { ty, .. }) => { // let ty = self.encoder.resolve_typaram(ty); // self.encoder.encode_value_type(ty) // } diff --git a/prusti-viper/src/encoder/procedure_encoder.rs b/prusti-viper/src/encoder/procedure_encoder.rs index d76a13f40cc..2151e691ad9 100644 --- a/prusti-viper/src/encoder/procedure_encoder.rs +++ b/prusti-viper/src/encoder/procedure_encoder.rs @@ -1867,7 +1867,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { } else { Some( self.encoder - .encode_const_expr(expr.ty(), expr.literal) + .encode_const_expr(expr.ty(), expr.const_) .with_span(span)?, ) }; @@ -2406,17 +2406,15 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { { let real_target = all_targets[(spec + 1) % 2]; let spec_target = all_targets[spec]; - if let Some(statements) = self.specification_block_encoding.remove(&spec_target) && !statements.is_empty() + if let Some(statements) = + self.specification_block_encoding.remove(&spec_target) + && !statements.is_empty() { - stmts.push( - vir::Stmt::comment( - format!("Specification from block: {spec_target:?}") - ) - ); - stmts.extend(statements); - return Ok((stmts, MirSuccessor::Goto( - real_target + stmts.push(vir::Stmt::comment(format!( + "Specification from block: {spec_target:?}" ))); + stmts.extend(statements); + return Ok((stmts, MirSuccessor::Goto(real_target))); } } } @@ -2561,11 +2559,11 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { ref args, destination, target, - func: mir::Operand::Constant(box mir::Constant { literal, .. }), + func: mir::Operand::Constant(box mir::ConstOperand { const_, .. }), .. } => { - let ty = literal.ty(); - let func_const_val = literal.try_to_scalar_int(); + let ty = const_.ty(); + let func_const_val = const_.try_to_scalar_int(); if let ty::TyKind::FnDef(called_def_id, call_substs) = ty.kind() { let called_def_id = *called_def_id; debug!( @@ -2876,7 +2874,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { TerminatorKind::UnwindResume | TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::InlineAsm { .. } => unimplemented!("{:?}", term.kind), }; Ok(result) @@ -6098,7 +6096,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { // Initialize the constant let const_val = self .encoder - .encode_const_expr(ty, expr.literal) + .encode_const_expr(ty, expr.const_) .with_span(span)?; // Initialize value of lhs stmts.push(vir::Stmt::Assign(vir::Assign { @@ -6636,7 +6634,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { .with_span(span)?; let len: usize = self .encoder - .const_eval_intlike(mir::ConstantKind::Ty(times)) + .const_eval_intlike(mir::Const::Ty(times)) .with_span(span)? .to_u64() .unwrap() @@ -7032,7 +7030,7 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> { } } - mir::AggregateKind::Generator(..) => { + mir::AggregateKind::Coroutine(..) => { return Err(SpannedEncodingError::unsupported( "construction of generators is not supported", span, diff --git a/prusti-viper/src/encoder/snapshot/interface.rs b/prusti-viper/src/encoder/snapshot/interface.rs index bf2fe3d6967..49a3aa0bb51 100644 --- a/prusti-viper/src/encoder/snapshot/interface.rs +++ b/prusti-viper/src/encoder/snapshot/interface.rs @@ -33,7 +33,7 @@ pub(crate) trait SnapshotEncoderInterface<'tcx> { fn encode_snapshot_type(&self, ty: ty::Ty<'tcx>) -> EncodingResult; fn encode_snapshot_constant( &self, - expr: &mir::Constant<'tcx>, + expr: &mir::ConstOperand<'tcx>, ) -> EncodingResult; fn encode_snapshot( &self, @@ -146,12 +146,12 @@ impl<'v, 'tcx: 'v> SnapshotEncoderInterface<'tcx> for super::super::Encoder<'v, /// The result is not necessarily a domain; it could be a primitive type. fn encode_snapshot_constant( &self, - expr: &mir::Constant<'tcx>, + expr: &mir::ConstOperand<'tcx>, ) -> EncodingResult { let args = match expr.ty().kind() { ty::TyKind::Tuple(substs) if substs.is_empty() => vec![], _ => { - vec![self.encode_const_expr(expr.ty(), expr.literal)?] + vec![self.encode_const_expr(expr.ty(), expr.const_)?] } }; self.encode_snapshot(expr.ty(), None, args) diff --git a/prusti-viper/src/utils/mod.rs b/prusti-viper/src/utils/mod.rs index 2c43bdced29..cc85d201ec6 100644 --- a/prusti-viper/src/utils/mod.rs +++ b/prusti-viper/src/utils/mod.rs @@ -27,9 +27,7 @@ pub fn ty_to_string(typ: &ty::TyKind) -> String { &ty::TyKind::FnPtr(_) => "function pointer", &ty::TyKind::Dynamic(..) => "trait object", &ty::TyKind::Closure(_, _) => "closures", - &ty::TyKind::Generator(..) - | &ty::TyKind::GeneratorWitness(..) - | &ty::TyKind::GeneratorWitnessMIR(..) => "generator", + &ty::TyKind::Coroutine(..) | &ty::TyKind::CoroutineWitness(..) => "coroutine", &ty::TyKind::Never => "never type", &ty::TyKind::Tuple(_) => "tuple", &ty::TyKind::Alias(ty::AliasKind::Projection, _) => "projection", From b18ae942bd9f35841f65499081f16cc5820378d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Fiala?= Date: Mon, 13 Nov 2023 17:23:55 +0100 Subject: [PATCH 3/3] Fix clippy issue --- analysis/tests/utils.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/analysis/tests/utils.rs b/analysis/tests/utils.rs index 397f53aeaa6..b9ef0a0cdd9 100644 --- a/analysis/tests/utils.rs +++ b/analysis/tests/utils.rs @@ -31,12 +31,16 @@ pub fn find_compiled_executable(name: &str) -> PathBuf { } pub fn find_sysroot() -> String { - // Taken from https://github.com/Manishearth/rust-clippy/pull/911. - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); + // Taken from https://github.com/rust-lang/rust-clippy/commit/f5db351a1d502cb65f8807ec2c84f44756099ef3. + let home = std::env::var("RUSTUP_HOME") + .or_else(|_| std::env::var("MULTIRUST_HOME")) + .ok(); + let toolchain = std::env::var("RUSTUP_TOOLCHAIN") + .or_else(|_| std::env::var("MULTIRUST_TOOLCHAIN")) + .ok(); match (home, toolchain) { (Some(home), Some(toolchain)) => format!("{home}/toolchains/{toolchain}"), - _ => option_env!("RUST_SYSROOT") + _ => std::env::var("RUST_SYSROOT") .expect("need to specify RUST_SYSROOT env var or use rustup or multirust") .to_owned(), }