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 toolchain #473

Merged
merged 1 commit into from
Jun 29, 2023
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
3 changes: 2 additions & 1 deletion flux-driver/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc_errors::ErrorGuaranteed;
use rustc_hir::{def::DefKind, def_id::LocalDefId, OwnerId};
use rustc_interface::{interface::Compiler, Queries};
use rustc_middle::{query, ty::TyCtxt};
use rustc_session::config::OutputType;
use rustc_session::{config::OutputType, EarlyErrorHandler};

use crate::{
collector::{IgnoreKey, Ignores, SpecCollector, Specs},
Expand Down Expand Up @@ -45,6 +45,7 @@ impl Callbacks for FluxCallbacks {

fn after_analysis<'tcx>(
&mut self,
_handler: &EarlyErrorHandler,
compiler: &Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
Expand Down
20 changes: 10 additions & 10 deletions flux-middle/src/rty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use super::{
evars::EVarSol,
normalize::{Defns, Normalizer},
subst::EVarSubstFolder,
BaseTy, Binder, BoundVariableKind, Constraint, Expr, ExprKind, FnOutput, FnSig,
FnTraitPredicate, FuncSort, GenericArg, Index, Invariant, KVar, Name, Opaqueness, Predicate,
PredicateKind, PtrKind, Qualifier, ReLateBound, Region, Sort, Ty, TyKind,
BaseTy, Binder, BoundVariableKind, Clause, ClauseKind, Constraint, Expr, ExprKind, FnOutput,
FnSig, FnTraitPredicate, FuncSort, GenericArg, Index, Invariant, KVar, Name, Opaqueness,
PtrKind, Qualifier, ReLateBound, Region, Sort, Ty, TyKind,
};
use crate::{
intern::{Internable, List},
Expand Down Expand Up @@ -358,30 +358,30 @@ pub trait TypeSuperFoldable: TypeFoldable {
}
}

impl TypeVisitable for Predicate {
impl TypeVisitable for Clause {
fn visit_with<V: TypeVisitor>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
self.kind.visit_with(visitor)
}
}

impl TypeFoldable for Predicate {
impl TypeFoldable for Clause {
fn try_fold_with<F: FallibleTypeFolder>(&self, folder: &mut F) -> Result<Self, F::Error> {
Ok(Predicate { kind: self.kind.try_fold_with(folder)? })
Ok(Clause { kind: self.kind.try_fold_with(folder)? })
}
}

impl TypeVisitable for PredicateKind {
impl TypeVisitable for ClauseKind {
fn visit_with<V: TypeVisitor>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
match self {
PredicateKind::FnTrait(pred) => pred.visit_with(visitor),
ClauseKind::FnTrait(pred) => pred.visit_with(visitor),
}
}
}

impl TypeFoldable for PredicateKind {
impl TypeFoldable for ClauseKind {
fn try_fold_with<F: FallibleTypeFolder>(&self, folder: &mut F) -> Result<Self, F::Error> {
match self {
PredicateKind::FnTrait(pred) => Ok(PredicateKind::FnTrait(pred.try_fold_with(folder)?)),
ClauseKind::FnTrait(pred) => Ok(ClauseKind::FnTrait(pred.try_fold_with(folder)?)),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions flux-middle/src/rty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ pub enum GenericParamDefKind {
#[derive(Clone)]
pub struct GenericPredicates {
pub parent: Option<DefId>,
pub predicates: List<Predicate>,
pub predicates: List<Clause>,
}

#[derive(PartialEq, Eq, Hash)]
pub struct Predicate {
kind: Binder<PredicateKind>,
pub struct Clause {
kind: Binder<ClauseKind>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
pub enum PredicateKind {
pub enum ClauseKind {
FnTrait(FnTraitPredicate),
}

Expand Down Expand Up @@ -298,8 +298,8 @@ pub enum GenericArg {
Lifetime(Region),
}

impl Predicate {
pub fn kind(&self) -> Binder<PredicateKind> {
impl Clause {
pub fn kind(&self) -> Binder<ClauseKind> {
self.kind.clone()
}
}
Expand Down Expand Up @@ -612,7 +612,7 @@ impl<T: TypeFoldable> EarlyBinder<T> {
}

impl EarlyBinder<GenericPredicates> {
pub fn predicates(&self) -> EarlyBinder<List<Predicate>> {
pub fn predicates(&self) -> EarlyBinder<List<Clause>> {
EarlyBinder(self.0.predicates.clone())
}
}
Expand Down Expand Up @@ -1232,7 +1232,7 @@ impl_slice_internable!(
TupleTree<bool>,
Sort,
GenericParamDef,
Predicate,
Clause,
PolyVariant,
Invariant,
BoundVariableKind,
Expand Down
8 changes: 4 additions & 4 deletions flux-middle/src/rty/refining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ impl<'a, 'tcx> Refiner<'a, 'tcx> {
let predicates = generics
.predicates
.iter()
.map(|pred| -> QueryResult<rty::Predicate> {
.map(|pred| -> QueryResult<rty::Clause> {
let vars = refine_bound_variables(pred.kind.vars());
let kind = match pred.kind.as_ref().skip_binder() {
rustc::ty::PredicateKind::FnTrait { bounded_ty, tupled_args, output, kind } => {
rustc::ty::ClauseKind::FnTrait { bounded_ty, tupled_args, output, kind } => {
let pred = rty::FnTraitPredicate {
self_ty: self.refine_ty(bounded_ty)?,
tupled_args: self.refine_ty(tupled_args)?,
output: self.refine_ty(output)?,
kind: *kind,
};
rty::Binder::new(rty::PredicateKind::FnTrait(pred), vars)
rty::Binder::new(rty::ClauseKind::FnTrait(pred), vars)
}
};
Ok(rty::Predicate { kind })
Ok(rty::Clause { kind })
})
.try_collect()?;

Expand Down
33 changes: 17 additions & 16 deletions flux-middle/src/rustc/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use super::{
StatementKind, Terminator, TerminatorKind,
},
ty::{
AdtDef, AdtDefData, Binder, BoundRegion, BoundRegionKind, BoundVariableKind, Const,
FieldDef, FnSig, GenericArg, GenericParamDef, GenericParamDefKind, GenericPredicates,
Generics, PolyFnSig, Predicate, PredicateKind, Ty, VariantDef,
AdtDef, AdtDefData, Binder, BoundRegion, BoundRegionKind, BoundVariableKind, Clause,
ClauseKind, Const, FieldDef, FnSig, GenericArg, GenericParamDef, GenericParamDefKind,
GenericPredicates, Generics, PolyFnSig, Ty, VariantDef,
},
};
use crate::{
Expand Down Expand Up @@ -369,10 +369,8 @@ impl<'sess, 'tcx> LoweringCtxt<'_, 'sess, 'tcx> {
) -> Result<BorrowKind, UnsupportedReason> {
match bk {
rustc_mir::BorrowKind::Shared => Ok(BorrowKind::Shared),
rustc_mir::BorrowKind::Mut { allow_two_phase_borrow } => {
Ok(BorrowKind::Mut { allow_two_phase_borrow })
}
rustc_mir::BorrowKind::Shallow | rustc_mir::BorrowKind::Unique => {
rustc_mir::BorrowKind::Mut { kind } => Ok(BorrowKind::Mut { kind }),
rustc_mir::BorrowKind::Shallow => {
Err(UnsupportedReason::new(format!("unsupported borrow kind `{bk:?}`")))
}
}
Expand Down Expand Up @@ -431,7 +429,13 @@ impl<'sess, 'tcx> LoweringCtxt<'_, 'sess, 'tcx> {
rustc_mir::BinOp::BitOr => Ok(BinOp::BitOr),
rustc_mir::BinOp::Shl => Ok(BinOp::Shl),
rustc_mir::BinOp::Shr => Ok(BinOp::Shr),
rustc_mir::BinOp::BitXor | rustc_mir::BinOp::Offset => {
rustc_mir::BinOp::AddUnchecked
| rustc_mir::BinOp::SubUnchecked
| rustc_mir::BinOp::MulUnchecked
| rustc_mir::BinOp::ShlUnchecked
| rustc_mir::BinOp::ShrUnchecked
| rustc_mir::BinOp::BitXor
| rustc_mir::BinOp::Offset => {
Err(UnsupportedReason::new(format!("unsupported binary op `{bin_op:?}`")))
}
}
Expand Down Expand Up @@ -749,12 +753,9 @@ pub(crate) fn lower_generic_predicates<'tcx>(
for (predicate, span) in generics.predicates {
let bound_vars = predicate.kind().bound_vars();
let kind = predicate.kind().skip_binder();
let rustc_ty::PredicateKind::Clause(clause) = kind else {
continue;
};

match clause {
rustc_ty::Clause::Trait(trait_pred) => {
match kind {
rustc_ty::ClauseKind::Trait(trait_pred) => {
let trait_ref = trait_pred.trait_ref;
if let Some(closure_kind) = tcx.fn_trait_kind_from_def_id(trait_ref.def_id) {
let substs = rustc_ty::Binder::bind_with_vars(trait_ref.substs, bound_vars);
Expand All @@ -766,7 +767,7 @@ pub(crate) fn lower_generic_predicates<'tcx>(
}
}
}
rustc_ty::Clause::Projection(proj_pred) => {
rustc_ty::ClauseKind::Projection(proj_pred) => {
let proj_ty = proj_pred.projection_ty;
if proj_ty.def_id == tcx.lang_items().fn_once_output().unwrap() {
let substs = rustc_ty::Binder::bind_with_vars(proj_ty.substs, bound_vars);
Expand Down Expand Up @@ -802,8 +803,8 @@ pub(crate) fn lower_generic_predicates<'tcx>(
.map_err(|err| errors::UnsupportedGenericBound::new(span, err.descr))
.emit(sess)?;

let kind = PredicateKind::FnTrait { bounded_ty, tupled_args, output, kind };
predicates.push(Predicate::new(Binder::bind_with_vars(kind, vars)));
let kind = ClauseKind::FnTrait { bounded_ty, tupled_args, output, kind };
predicates.push(Clause::new(Binder::bind_with_vars(kind, vars)));
}
Ok(GenericPredicates { parent: generics.parent, predicates: List::from_vec(predicates) })
}
Expand Down
4 changes: 2 additions & 2 deletions flux-middle/src/rustc/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::IndexSlice;
use rustc_macros::{Decodable, Encodable};
use rustc_middle::{
mir,
mir::{self, MutBorrowKind},
ty::{subst::SubstsRef, FloatTy, IntTy, UintTy},
};
pub use rustc_middle::{
Expand Down Expand Up @@ -155,7 +155,7 @@ pub enum Rvalue {
}

pub enum BorrowKind {
Mut { allow_two_phase_borrow: bool },
Mut { kind: MutBorrowKind },
Shared,
}

Expand Down
16 changes: 8 additions & 8 deletions flux-middle/src/rustc/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ pub enum GenericParamDefKind {
#[derive(Debug)]
pub struct GenericPredicates {
pub parent: Option<DefId>,
pub predicates: List<Predicate>,
pub predicates: List<Clause>,
}

#[derive(PartialEq, Eq, Hash, Debug)]
pub struct Predicate {
pub kind: Binder<PredicateKind>,
pub struct Clause {
pub kind: Binder<ClauseKind>,
}

#[derive(PartialEq, Eq, Hash, Debug)]
pub enum PredicateKind {
pub enum ClauseKind {
FnTrait { bounded_ty: Ty, tupled_args: Ty, output: Ty, kind: ClosureKind },
}

Expand Down Expand Up @@ -220,9 +220,9 @@ pub struct BoundRegion {
pub kind: BoundRegionKind,
}

impl Predicate {
pub(crate) fn new(kind: Binder<PredicateKind>) -> Predicate {
Predicate { kind }
impl Clause {
pub(crate) fn new(kind: Binder<ClauseKind>) -> Clause {
Clause { kind }
}
}

Expand Down Expand Up @@ -472,7 +472,7 @@ impl Ty {
}

impl_internable!(TyS, AdtDefData);
impl_slice_internable!(Ty, GenericArg, GenericParamDef, BoundVariableKind, Predicate);
impl_slice_internable!(Ty, GenericArg, GenericParamDef, BoundVariableKind, Clause);

impl fmt::Debug for GenericArg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion flux-refineck/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl<'a, 'tcx, M: Mode> Checker<'a, 'tcx, M> {
) -> Result<(), CheckerError> {
for predicate in &obligs.predicates {
let fn_trait_pred = predicate.kind().map(|kind| {
let rty::PredicateKind::FnTrait(fn_trait_pred) = kind;
let rty::ClauseKind::FnTrait(fn_trait_pred) = kind;
fn_trait_pred
});
if let Some(BaseTy::Closure(def_id, tys)) = fn_trait_pred
Expand Down
6 changes: 3 additions & 3 deletions flux-refineck/src/constraint_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct ConstrGen<'a, 'tcx> {
}

pub(crate) struct Obligations {
pub(crate) predicates: List<rty::Predicate>,
pub(crate) predicates: List<rty::Clause>,
/// Snapshot of the refinement subtree where the obligations should be checked
pub(crate) snapshot: Snapshot,
}
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}

impl Obligations {
fn new(predicates: List<rty::Predicate>, snapshot: Snapshot) -> Self {
fn new(predicates: List<rty::Clause>, snapshot: Snapshot) -> Self {
Self { predicates, snapshot }
}
}
Expand All @@ -629,7 +629,7 @@ fn mk_obligations(
genv: &GlobalEnv<'_, '_>,
did: DefId,
substs: &[GenericArg],
) -> Result<List<rty::Predicate>, CheckerErrKind> {
) -> Result<List<rty::Clause>, CheckerErrKind> {
Ok(genv.predicates_of(did)?.predicates().subst_generics(substs))
}

Expand Down
2 changes: 1 addition & 1 deletion flux-refineck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![feature(
associated_type_defaults,
box_patterns,
drain_filter,
extract_if,
if_let_guard,
impl_trait_in_assoc_type,
lazy_cell,
Expand Down
13 changes: 8 additions & 5 deletions flux-refineck/src/refine_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,17 @@ impl Node {
NodeKind::True => {}
NodeKind::Guard(pred) => {
*pred = pred.simplify();
self.children.drain_filter(|child| {
matches!(child.borrow().kind, NodeKind::True)
|| matches!(&child.borrow().kind, NodeKind::Head(head, _) if head == pred)
});
self.children
.extract_if(|child| {
matches!(child.borrow().kind, NodeKind::True)
|| matches!(&child.borrow().kind, NodeKind::Head(head, _) if head == pred)
})
.for_each(drop);
}
NodeKind::Comment(_) | NodeKind::Conj | NodeKind::ForAll(..) => {
self.children
.drain_filter(|child| matches!(&child.borrow().kind, NodeKind::True));
.extract_if(|child| matches!(&child.borrow().kind, NodeKind::True))
.for_each(drop);
}
}
if !self.is_leaf() && self.children.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-06-12"
channel = "nightly-2023-06-29"
components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"]