Rollup merge of #113320 - oli-obk:eval_obligation_query, r=petrochenkov,BoxyUwU
Add some extra information to opaque type cycle errors Plus a bunch of cleanups. This should help users debug query cycles due to auto trait checking. We'll probably want to fix cycle errors in most (or all?) cases by looking at the current item's hidden types (new solver does this), and by delaying the auto trait checks to after typeck.
This commit is contained in:
commit
0334b64cbb
18 changed files with 443 additions and 55 deletions
|
@ -2271,8 +2271,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
fn constituent_types_for_ty(
|
||||
&self,
|
||||
t: ty::Binder<'tcx, Ty<'tcx>>,
|
||||
) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
|
||||
match *t.skip_binder().kind() {
|
||||
) -> Result<ty::Binder<'tcx, Vec<Ty<'tcx>>>, SelectionError<'tcx>> {
|
||||
Ok(match *t.skip_binder().kind() {
|
||||
ty::Uint(_)
|
||||
| ty::Int(_)
|
||||
| ty::Bool
|
||||
|
@ -2336,12 +2336,16 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
}
|
||||
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
||||
let ty = self.tcx().type_of(def_id);
|
||||
if ty.skip_binder().references_error() {
|
||||
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
|
||||
}
|
||||
// We can resolve the `impl Trait` to its concrete type,
|
||||
// which enforces a DAG between the functions requiring
|
||||
// the auto trait bounds in question.
|
||||
t.rebind(vec![self.tcx().type_of(def_id).subst(self.tcx(), substs)])
|
||||
t.rebind(vec![ty.subst(self.tcx(), substs)])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn collect_predicates_for_types(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue