Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykril

feat: add preliminary support for `+ use<..>` `precise_capturing` syntax

## Summary

This PR adds basic support for the following syntax.

```rs
fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
//                                  ~~~~~~~~~~~~~~~~~~~~~~~
//                          This opaque type does not capture `'a`.

fn outlives<'o, T: 'o>(_: T) {}

fn caller<'o, 'a, 'b: 'o, T: 'o>() {
    //        ~~
    //        ^ Note that we don't need `'a: 'o`.
    outlives::<'o>(captures::<'a, 'b, T>());
}
```

Related to #17598
This commit is contained in:
bors 2024-07-25 11:10:56 +00:00
commit 0ba6f4eda0
9 changed files with 237 additions and 89 deletions

View file

@ -794,6 +794,8 @@ pub enum TypeBoundKind {
PathType(ast::PathType),
/// for<'a> ...
ForType(ast::ForType),
/// use
Use(ast::GenericParamList),
/// 'a
Lifetime(ast::Lifetime),
}
@ -804,6 +806,8 @@ impl ast::TypeBound {
TypeBoundKind::PathType(path_type)
} else if let Some(for_type) = support::children(self.syntax()).next() {
TypeBoundKind::ForType(for_type)
} else if let Some(generic_param_list) = self.generic_param_list() {
TypeBoundKind::Use(generic_param_list)
} else if let Some(lifetime) = self.lifetime() {
TypeBoundKind::Lifetime(lifetime)
} else {