1
Fork 0

Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillot

Implement partial support for non-lifetime binders

This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed.

Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged.

Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`)

cc rust-lang/types-team#81

r? `@ghost`
This commit is contained in:
Matthias Krüger 2023-02-17 00:19:34 +01:00 committed by GitHub
commit 089e8c03bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 709 additions and 343 deletions

View file

@ -396,7 +396,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// still be provided by a manual implementation for
// this trait and type.
}
ty::Param(..) | ty::Alias(ty::Projection, ..) => {
ty::Param(..)
| ty::Alias(ty::Projection, ..)
| ty::Placeholder(..)
| ty::Bound(..) => {
// In these cases, we don't know what the actual
// type is. Therefore, we cannot break it down
// into its constituent types. So we don't
@ -448,6 +451,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
);
self.infcx.probe(|_snapshot| {
if obligation.has_non_region_late_bound() {
return;
}
// The code below doesn't care about regions, and the
// self-ty here doesn't escape this probe, so just erase
// any LBR.