mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Skip lifetime elision on fn pointers and fn trait types
This commit is contained in:
parent
506895fa2f
commit
b996a54cd8
5 changed files with 105 additions and 70 deletions
|
@ -173,7 +173,8 @@ pub fn walk_pat(pat: &ast::Pat, cb: &mut dyn FnMut(ast::Pat)) {
|
|||
}
|
||||
|
||||
/// Preorder walk all the type's sub types.
|
||||
pub fn walk_ty(ty: &ast::Type, cb: &mut dyn FnMut(ast::Type)) {
|
||||
// FIXME: Make the control flow more proper
|
||||
pub fn walk_ty(ty: &ast::Type, cb: &mut dyn FnMut(ast::Type) -> bool) {
|
||||
let mut preorder = ty.syntax().preorder();
|
||||
while let Some(event) = preorder.next() {
|
||||
let node = match event {
|
||||
|
@ -184,10 +185,12 @@ pub fn walk_ty(ty: &ast::Type, cb: &mut dyn FnMut(ast::Type)) {
|
|||
match ast::Type::cast(node) {
|
||||
Some(ty @ ast::Type::MacroType(_)) => {
|
||||
preorder.skip_subtree();
|
||||
cb(ty)
|
||||
cb(ty);
|
||||
}
|
||||
Some(ty) => {
|
||||
cb(ty);
|
||||
if cb(ty) {
|
||||
preorder.skip_subtree();
|
||||
}
|
||||
}
|
||||
// skip const args
|
||||
None if ast::ConstArg::can_cast(kind) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue