Skip to content

Commit 4ba2c5b

Browse files
committed
Chalk update to simplified IR
1 parent da19027 commit 4ba2c5b

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

Cargo.lock

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_hir/src/ty/traits/chalk.rs

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,16 @@ pub(crate) fn trait_datum_query(
491491
},
492492
associated_ty_ids: Vec::new(),
493493
where_clauses: Vec::new(),
494-
flags: chalk_rust_ir::TraitFlags {
495-
non_enumerable: true,
496-
auto: false,
497-
marker: false,
498-
upstream: true,
499-
fundamental: false,
500-
},
501494
};
502-
return Arc::new(TraitDatum { binders: make_binders(trait_datum_bound, 1) });
495+
496+
let flags = chalk_rust_ir::TraitFlags {
497+
auto: false,
498+
marker: false,
499+
upstream: true,
500+
fundamental: false,
501+
non_enumerable: true,
502+
};
503+
return Arc::new(TraitDatum { binders: make_binders(trait_datum_bound, 1), flags });
503504
}
504505
let trait_: Trait = from_chalk(db, trait_id);
505506
debug!("trait {:?} = {:?}", trait_id, trait_.name(db));
@@ -525,8 +526,9 @@ pub(crate) fn trait_datum_query(
525526
.map(|type_alias| type_alias.to_chalk(db))
526527
.collect();
527528
let trait_datum_bound =
528-
chalk_rust_ir::TraitDatumBound { trait_ref, where_clauses, flags, associated_ty_ids };
529-
let trait_datum = TraitDatum { binders: make_binders(trait_datum_bound, bound_vars.len()) };
529+
chalk_rust_ir::TraitDatumBound { trait_ref, where_clauses, associated_ty_ids };
530+
let trait_datum =
531+
TraitDatum { binders: make_binders(trait_datum_bound, bound_vars.len()), flags };
530532
Arc::new(trait_datum)
531533
}
532534

@@ -632,18 +634,20 @@ fn impl_block_datum(
632634
})
633635
.collect();
634636

635-
let impl_datum_bound = chalk_rust_ir::ImplDatumBound {
636-
trait_ref: if negative {
637-
chalk_rust_ir::PolarizedTraitRef::Negative(trait_ref)
638-
} else {
639-
chalk_rust_ir::PolarizedTraitRef::Positive(trait_ref)
640-
},
641-
where_clauses,
642-
associated_ty_values,
643-
impl_type,
637+
let polarity = if negative {
638+
chalk_rust_ir::Polarity::Negative
639+
} else {
640+
chalk_rust_ir::Polarity::Positive
644641
};
642+
643+
let impl_datum_bound =
644+
chalk_rust_ir::ImplDatumBound { trait_ref, where_clauses, associated_ty_values };
645645
debug!("impl_datum: {:?}", impl_datum_bound);
646-
let impl_datum = ImplDatum { binders: make_binders(impl_datum_bound, bound_vars.len()) };
646+
let impl_datum = ImplDatum {
647+
binders: make_binders(impl_datum_bound, bound_vars.len()),
648+
impl_type,
649+
polarity,
650+
};
647651
Arc::new(impl_datum)
648652
}
649653

@@ -653,12 +657,15 @@ fn invalid_impl_datum() -> Arc<ImplDatum> {
653657
parameters: vec![chalk_ir::Ty::BoundVar(0).cast()],
654658
};
655659
let impl_datum_bound = chalk_rust_ir::ImplDatumBound {
656-
trait_ref: chalk_rust_ir::PolarizedTraitRef::Positive(trait_ref),
660+
trait_ref,
657661
where_clauses: Vec::new(),
658662
associated_ty_values: Vec::new(),
663+
};
664+
let impl_datum = ImplDatum {
665+
binders: make_binders(impl_datum_bound, 1),
659666
impl_type: chalk_rust_ir::ImplType::External,
667+
polarity: chalk_rust_ir::Polarity::Positive,
660668
};
661-
let impl_datum = ImplDatum { binders: make_binders(impl_datum_bound, 1) };
662669
Arc::new(impl_datum)
663670
}
664671

@@ -713,12 +720,15 @@ fn closure_fn_trait_impl_datum(
713720
let impl_type = chalk_rust_ir::ImplType::External;
714721

715722
let impl_datum_bound = chalk_rust_ir::ImplDatumBound {
716-
trait_ref: chalk_rust_ir::PolarizedTraitRef::Positive(trait_ref.to_chalk(db)),
723+
trait_ref: trait_ref.to_chalk(db),
717724
where_clauses: Vec::new(),
718725
associated_ty_values: vec![output_ty_value],
726+
};
727+
let impl_datum = ImplDatum {
728+
binders: make_binders(impl_datum_bound, num_args as usize + 1),
719729
impl_type,
730+
polarity: chalk_rust_ir::Polarity::Positive,
720731
};
721-
let impl_datum = ImplDatum { binders: make_binders(impl_datum_bound, num_args as usize + 1) };
722732
Some(Arc::new(impl_datum))
723733
}
724734

0 commit comments

Comments
 (0)