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:
commit
089e8c03bc
48 changed files with 709 additions and 343 deletions
|
@ -2007,7 +2007,7 @@ impl ExplicitOutlivesRequirements {
|
|||
inferred_outlives: &[ty::Region<'tcx>],
|
||||
predicate_span: Span,
|
||||
) -> Vec<(usize, Span)> {
|
||||
use rustc_middle::middle::resolve_lifetime::Region;
|
||||
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
|
||||
|
||||
bounds
|
||||
.iter()
|
||||
|
@ -2017,8 +2017,8 @@ impl ExplicitOutlivesRequirements {
|
|||
return None;
|
||||
};
|
||||
|
||||
let is_inferred = match tcx.named_region(lifetime.hir_id) {
|
||||
Some(Region::EarlyBound(def_id)) => inferred_outlives
|
||||
let is_inferred = match tcx.named_bound_var(lifetime.hir_id) {
|
||||
Some(ResolvedArg::EarlyBound(def_id)) => inferred_outlives
|
||||
.iter()
|
||||
.any(|r| matches!(**r, ty::ReEarlyBound(ebr) if { ebr.def_id == def_id })),
|
||||
_ => false,
|
||||
|
@ -2097,7 +2097,7 @@ impl ExplicitOutlivesRequirements {
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||
use rustc_middle::middle::resolve_lifetime::Region;
|
||||
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
|
||||
|
||||
let def_id = item.owner_id.def_id;
|
||||
if let hir::ItemKind::Struct(_, hir_generics)
|
||||
|
@ -2120,8 +2120,8 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
|
|||
let (relevant_lifetimes, bounds, predicate_span, in_where_clause) =
|
||||
match where_predicate {
|
||||
hir::WherePredicate::RegionPredicate(predicate) => {
|
||||
if let Some(Region::EarlyBound(region_def_id)) =
|
||||
cx.tcx.named_region(predicate.lifetime.hir_id)
|
||||
if let Some(ResolvedArg::EarlyBound(region_def_id)) =
|
||||
cx.tcx.named_bound_var(predicate.lifetime.hir_id)
|
||||
{
|
||||
(
|
||||
Self::lifetimes_outliving_lifetime(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue