mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
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:
commit
0ba6f4eda0
9 changed files with 237 additions and 89 deletions
|
@ -1788,6 +1788,8 @@ pub struct TypeBound {
|
|||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl TypeBound {
|
||||
#[inline]
|
||||
pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
|
@ -1799,6 +1801,8 @@ impl TypeBound {
|
|||
#[inline]
|
||||
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
|
||||
#[inline]
|
||||
pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
|
||||
#[inline]
|
||||
pub fn tilde_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![~]) }
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue