Skip to content

Commit

Permalink
prevent eta expansion in rty checking
Browse files Browse the repository at this point in the history
  • Loading branch information
vrindisbacher committed Jan 13, 2025
1 parent 5f3c207 commit 52ea405
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/flux-infer/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'a, E: LocEnv> Sub<'a, E> {
let vars = a
.vars()
.iter()
.map(|kind| infcx.define_vars(kind.expect_sort()))
.map(|kind| Expr::fvar(infcx.define_var(kind.expect_sort())))
.collect_vec();
let body_a = a.apply(&vars);
let body_b = b.apply(&vars);
Expand Down
2 changes: 1 addition & 1 deletion crates/flux-infer/src/refine_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ pub struct Unpacker<'a, 'b> {

impl HoisterDelegate for Unpacker<'_, '_> {
fn hoist_exists(&mut self, ty_ctor: &TyCtor) -> Ty {
let ty = ty_ctor.replace_bound_refts_with(|sort, _, _| self.cursor.define_vars(sort));
let ty = ty_ctor.replace_bound_refts_with(|sort, _, _| Expr::fvar(self.cursor.define_var(sort)));
if let AssumeInvariants::Yes { check_overflow } = self.assume_invariants {
self.cursor.assume_invariants(&ty, check_overflow);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/flux-refineck/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fn check_fn_subtyping(
let tcx = infcx.genv.tcx();

let super_sig = super_sig
.replace_bound_vars(|_| rty::ReErased, |sort, _| infcx.define_vars(sort))
.replace_bound_vars(|_| rty::ReErased, |sort, _| Expr::fvar(infcx.define_var(sort)))
.normalize_projections(&mut infcx)?;

// 1. Unpack `T_g` input types
Expand Down Expand Up @@ -275,7 +275,7 @@ fn check_fn_subtyping(

let output = infcx
.fully_resolve_evars(&output)
.replace_bound_refts_with(|sort, _, _| infcx.define_vars(sort));
.replace_bound_refts_with(|sort, _, _| Expr::fvar(infcx.define_var(sort)));

// 4. OUTPUT subtyping (f_out <: g_out)
infcx.ensure_resolved_evars(|infcx| {
Expand Down Expand Up @@ -422,7 +422,7 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {
let body = genv.mir(def_id).with_span(span)?;

let fn_sig = poly_sig
.replace_bound_vars(|_| rty::ReErased, |sort, _| infcx.define_vars(sort))
.replace_bound_vars(|_| rty::ReErased, |sort, _| Expr::fvar(infcx.define_var(sort)))
.normalize_projections(&mut infcx)
.with_span(span)?;

Expand Down Expand Up @@ -804,7 +804,7 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {

let output = infcx
.fully_resolve_evars(&fn_sig.output)
.replace_bound_refts_with(|sort, _, _| infcx.define_vars(sort));
.replace_bound_refts_with(|sort, _, _| Expr::fvar(infcx.define_var(sort)));

env.assume_ensures(infcx, &output.ensures);
fold_local_ptrs(infcx, env, span).with_span(span)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/flux-refineck/src/type_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ impl BasicBlockEnv {
) -> TypeEnv<'a> {
let data = self
.data
.replace_bound_refts_with(|sort, _, _| infcx.define_vars(sort));
.replace_bound_refts_with(|sort, _, _| Expr::fvar(infcx.define_var(sort)));
for constr in &data.constrs {
infcx.assume_pred(constr);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/flux-refineck/src/type_env/place_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ fn downcast_enum(
.variant_sig(adt.did(), variant_idx)?
.expect("enums cannot be opaque")
.instantiate(tcx, args, &[])
.replace_bound_refts_with(|sort, _, _| infcx.define_vars(sort))
.replace_bound_refts_with(|sort, _, _| Expr::fvar(infcx.define_var(sort)))
.normalize_projections(infcx)?;

// FIXME(nilehmann) We could assert idx1 == variant_def.idx directly, but for aggregate sorts there
Expand Down

0 comments on commit 52ea405

Please sign in to comment.