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

Separate projection bounds and predicates #73905

Merged
merged 34 commits into from
Oct 6, 2020
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0eb87ed
Rename projection_predicates to item_bounds
matthewjasper Jun 23, 2020
a7ead3b
Move item_bounds to typeck::collect
matthewjasper Jun 23, 2020
d297147
Split bounds from predicates
matthewjasper Jun 24, 2020
f958e6c
Separate bounds and predicates for associated/opaque types
matthewjasper Jun 27, 2020
87f2f42
Make projection wf check the predicates for the projection
matthewjasper Jun 28, 2020
b3057f4
Check projections are well-formed when using projection candidates
matthewjasper Jun 28, 2020
5b279c8
Check opaque types satisfy their bounds
matthewjasper Jun 28, 2020
1b07991
Check associated type bounds for object safety violations
matthewjasper Jun 28, 2020
d4d9e7f
Remove unused part of return value from `replace_bound_vars_with_plac…
matthewjasper Jun 28, 2020
0a76584
Move some code from rustc_typeck to rustc_trait_selection
matthewjasper Jun 28, 2020
2bdf723
Ensure that associated types for trait objects satisfy their bounds
matthewjasper Jun 28, 2020
042464f
Fix tests and bootstrap
matthewjasper Jun 29, 2020
0dda415
Fix tools
matthewjasper Jun 30, 2020
21eccbb
Fix ICE
matthewjasper Jul 1, 2020
8787090
Address review comments
matthewjasper Jul 2, 2020
582ccec
Remove predicates on associated types from traits
matthewjasper Jul 4, 2020
f52b2d8
Avoid cycle in nested obligations for object candidate
matthewjasper Jul 5, 2020
bc08b79
Fix bugs in evaluating WellFormed predicates
matthewjasper Jul 22, 2020
cfee495
Handle multiple applicable projection candidates
matthewjasper Jul 23, 2020
34e5a49
Normalize projection bounds when considering candidates
matthewjasper Jul 24, 2020
596d6c4
Avoid cycle with projections from object types
matthewjasper Jul 24, 2020
0dfa6ff
Avoid cycles from projection bounds
matthewjasper Jul 25, 2020
ed32482
Handle multiple trait-def projection candidates
matthewjasper Jul 25, 2020
6c4feb6
Fix bootstrap
matthewjasper Jul 25, 2020
e297652
Don't immediately error for recursive projections
matthewjasper Jul 25, 2020
d08ab94
Fix rebase
matthewjasper Aug 14, 2020
e674cf0
Normalize super trait bounds when confirming object candidates
matthewjasper Aug 14, 2020
e42c979
Don't require lifetime super-bounds on traits apply to trait objects …
matthewjasper Aug 15, 2020
852073a
Deduplicate item bounds after normalization
matthewjasper Aug 15, 2020
27534b3
Fix rebase
matthewjasper Sep 6, 2020
1db284e
Avoid creating useless projection predicate
matthewjasper Sep 7, 2020
022c148
Fix tests from rebase
matthewjasper Sep 7, 2020
c9eeb60
Deduplicate some code
matthewjasper Oct 5, 2020
69fc6d8
Fix NLL compare mode tests
matthewjasper Oct 6, 2020
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
Prev Previous commit
Next Next commit
Deduplicate some code
  • Loading branch information
matthewjasper committed Oct 6, 2020
commit c9eeb60b638fcb347c7c6ba066390144d8c7a24e
39 changes: 15 additions & 24 deletions compiler/rustc_traits/src/chalk/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ impl<'tcx> RustIrDatabase<'tcx> {
.map(|wc| wc.fold_with(&mut regions_substitutor))
.filter_map(|wc| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(wc, &self.interner)).collect()
}

fn bounds_for<T>(&self, def_id: DefId, bound_vars: SubstsRef<'tcx>) -> Vec<T>
where
ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>,
{
self.interner
.tcx
.explicit_item_bounds(def_id)
.iter()
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, &self.interner))
.collect()
}
}

impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'tcx> {
Expand All @@ -75,19 +88,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
let binders = binders_for(&self.interner, bound_vars);

let where_clauses = self.where_clauses_for(def_id, bound_vars);

let bounds = self
.interner
.tcx
.explicit_item_bounds(def_id)
.iter()
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
.filter_map(|bound| {
LowerInto::<
Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>>,
>::lower_into(bound, &self.interner)
})
.collect();
let bounds = self.bounds_for(def_id, bound_vars);

Arc::new(chalk_solve::rust_ir::AssociatedTyDatum {
trait_id: chalk_ir::TraitId(trait_def_id),
Expand Down Expand Up @@ -453,17 +454,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
let bound_vars = bound_vars_for_item(self.interner.tcx, opaque_ty_id.0);
let binders = binders_for(&self.interner, bound_vars);
let where_clauses = self.where_clauses_for(opaque_ty_id.0, bound_vars);

let bounds: Vec<_> = self
.interner
.tcx
.explicit_item_bounds(opaque_ty_id.0)
.iter()
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
.filter_map(|bound| {
LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(bound, &self.interner)
})
.collect();
let bounds = self.bounds_for(opaque_ty_id.0, bound_vars);

let value = chalk_solve::rust_ir::OpaqueTyDatumBound {
bounds: chalk_ir::Binders::new(binders.clone(), bounds),
Expand Down