Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies (rustc nightly-2023-11-01, viper v-2023-09-27-0729) #1470

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 deletions analysis/src/bin/analysis-driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 2 additions & 5 deletions analysis/src/bin/gen-accessibility-driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions analysis/src/domains/definitely_accessible/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!(),
}
}

Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions analysis/src/mir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions analysis/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions prusti-interface/src/environment/borrowck/regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl PlaceRegions {
not supported"
.to_string(),
)),
mir::ProjectionElem::Subtype(_) => todo!(),
})
.collect::<Result<_, _>>()?;
Ok((place.local, indices))
Expand Down
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/debug_utils/to_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
11 changes: 7 additions & 4 deletions prusti-interface/src/environment/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/mir_body/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions prusti-interface/src/environment/mir_body/patch/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/mir_utils/all_places.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use prusti_rustc_interface::{
abi::FieldIdx,
middle::{mir, ty},
target::abi::FieldIdx,
};

pub trait AllPlaces<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/mir_utils/real_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn real_targets(terminator: &mir::Terminator) -> Vec<mir::BasicBlock> {
TerminatorKind::UnwindResume
| TerminatorKind::UnwindTerminate(..)
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Unreachable => vec![],

TerminatorKind::Drop { ref target, .. } => vec![*target],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{SliceOrArrayRef, TupleItemsForTy};
use prusti_rustc_interface::{
abi::FieldIdx,
middle::{mir, ty},
target::abi::FieldIdx,
};

pub trait SplitAggregateAssignment<'tcx> {
Expand Down
4 changes: 3 additions & 1 deletion prusti-launch/src/bin/cargo-prusti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions prusti-viper/src/encoder/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,19 @@ 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<mir::interpret::Scalar> {
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);
self.uneval_eval_intlike(mir_ct)
}
_ => 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:?}"))
Expand Down Expand Up @@ -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<vir::Expr> {
let scalar_value = self.const_eval_intlike(value)?;

Expand Down
8 changes: 4 additions & 4 deletions prusti-viper/src/encoder/mir/constants/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<vir_high::Expression>;

fn compute_array_len(&self, size: ty::Const<'tcx>) -> EncodingResult<u64>;
Expand All @@ -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<vir_high::Expression> {
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(),
Expand Down Expand Up @@ -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<u64> {
self.const_eval_intlike(mir::ConstantKind::Ty(size))
self.const_eval_intlike(mir::Const::Ty(size))
.map(|s| s.to_u64().unwrap())
}
}
4 changes: 2 additions & 2 deletions prusti-viper/src/encoder/mir/contracts/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -44,7 +44,7 @@ impl<P: fmt::Debug> fmt::Display for BorrowInfo<P> {
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!(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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()),
}))
}

Expand Down
Loading
Loading