mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-29 19:17:12 +00:00 
			
		
		
		
	Remove unnecessary parameters in inlay-hint computation
This commit is contained in:
		
							parent
							
								
									25808c1ba1
								
							
						
					
					
						commit
						d2164fe08b
					
				
					 10 changed files with 41 additions and 58 deletions
				
			
		|  | @ -6,7 +6,7 @@ use std::{ | ||||||
| use either::Either; | use either::Either; | ||||||
| use hir::{ | use hir::{ | ||||||
|     ClosureStyle, DisplayTarget, EditionedFileId, HasVisibility, HirDisplay, HirDisplayError, |     ClosureStyle, DisplayTarget, EditionedFileId, HasVisibility, HirDisplay, HirDisplayError, | ||||||
|     HirWrite, ModuleDef, ModuleDefId, Semantics, sym, |     HirWrite, InRealFile, ModuleDef, ModuleDefId, Semantics, sym, | ||||||
| }; | }; | ||||||
| use ide_db::{FileRange, RootDatabase, famous_defs::FamousDefs, text_edit::TextEditBuilder}; | use ide_db::{FileRange, RootDatabase, famous_defs::FamousDefs, text_edit::TextEditBuilder}; | ||||||
| use ide_db::{FxHashSet, text_edit::TextEdit}; | use ide_db::{FxHashSet, text_edit::TextEdit}; | ||||||
|  | @ -95,16 +95,16 @@ pub(crate) fn inlay_hints( | ||||||
|         return acc; |         return acc; | ||||||
|     }; |     }; | ||||||
|     let famous_defs = FamousDefs(&sema, scope.krate()); |     let famous_defs = FamousDefs(&sema, scope.krate()); | ||||||
|  |     let display_target = famous_defs.1.to_display_target(sema.db); | ||||||
| 
 | 
 | ||||||
|     let ctx = &mut InlayHintCtx::default(); |     let ctx = &mut InlayHintCtx::default(); | ||||||
|     let mut hints = |event| { |     let mut hints = |event| { | ||||||
|         if let Some(node) = handle_event(ctx, event) { |         if let Some(node) = handle_event(ctx, event) { | ||||||
|             hints(&mut acc, ctx, &famous_defs, config, file_id, node); |             hints(&mut acc, ctx, &famous_defs, config, file_id, display_target, node); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|     let mut preorder = file.preorder(); |     let mut preorder = file.preorder(); | ||||||
|     while let Some(event) = preorder.next() { |     while let Some(event) = preorder.next() { | ||||||
|         // FIXME: This can miss some hints that require the parent of the range to calculate
 |  | ||||||
|         if matches!((&event, range_limit), (WalkEvent::Enter(node), Some(range)) if range.intersect(node.text_range()).is_none()) |         if matches!((&event, range_limit), (WalkEvent::Enter(node), Some(range)) if range.intersect(node.text_range()).is_none()) | ||||||
|         { |         { | ||||||
|             preorder.skip_subtree(); |             preorder.skip_subtree(); | ||||||
|  | @ -144,10 +144,12 @@ pub(crate) fn inlay_hints_resolve( | ||||||
|     let famous_defs = FamousDefs(&sema, scope.krate()); |     let famous_defs = FamousDefs(&sema, scope.krate()); | ||||||
|     let mut acc = Vec::new(); |     let mut acc = Vec::new(); | ||||||
| 
 | 
 | ||||||
|  |     let display_target = famous_defs.1.to_display_target(sema.db); | ||||||
|  | 
 | ||||||
|     let ctx = &mut InlayHintCtx::default(); |     let ctx = &mut InlayHintCtx::default(); | ||||||
|     let mut hints = |event| { |     let mut hints = |event| { | ||||||
|         if let Some(node) = handle_event(ctx, event) { |         if let Some(node) = handle_event(ctx, event) { | ||||||
|             hints(&mut acc, ctx, &famous_defs, config, file_id, node); |             hints(&mut acc, ctx, &famous_defs, config, file_id, display_target, node); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -202,17 +204,19 @@ fn handle_event(ctx: &mut InlayHintCtx, node: WalkEvent<SyntaxNode>) -> Option<S | ||||||
| fn hints( | fn hints( | ||||||
|     hints: &mut Vec<InlayHint>, |     hints: &mut Vec<InlayHint>, | ||||||
|     ctx: &mut InlayHintCtx, |     ctx: &mut InlayHintCtx, | ||||||
|     famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>, |     famous_defs @ FamousDefs(sema, _krate): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |     file_id: EditionedFileId, | ||||||
|  |     display_target: DisplayTarget, | ||||||
|     node: SyntaxNode, |     node: SyntaxNode, | ||||||
| ) { | ) { | ||||||
|     let file_id = file_id.editioned_file_id(sema.db); |     closing_brace::hints( | ||||||
|     let Some(krate) = sema.first_crate(file_id.file_id()) else { |         hints, | ||||||
|         return; |         sema, | ||||||
|     }; |         config, | ||||||
|     let display_target = krate.to_display_target(sema.db); |         display_target, | ||||||
|     closing_brace::hints(hints, sema, config, file_id, display_target, node.clone()); |         InRealFile { file_id, value: node.clone() }, | ||||||
|  |     ); | ||||||
|     if let Some(any_has_generic_args) = ast::AnyHasGenericArgs::cast(node.clone()) { |     if let Some(any_has_generic_args) = ast::AnyHasGenericArgs::cast(node.clone()) { | ||||||
|         generic_param::hints(hints, famous_defs, config, any_has_generic_args); |         generic_param::hints(hints, famous_defs, config, any_has_generic_args); | ||||||
|     } |     } | ||||||
|  | @ -231,18 +235,18 @@ fn hints( | ||||||
|                         closure_captures::hints(hints, famous_defs, config, it.clone()); |                         closure_captures::hints(hints, famous_defs, config, it.clone()); | ||||||
|                         closure_ret::hints(hints, famous_defs, config, display_target, it) |                         closure_ret::hints(hints, famous_defs, config, display_target, it) | ||||||
|                     }, |                     }, | ||||||
|                     ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, famous_defs, config, file_id,  it), |                     ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, famous_defs, config, it), | ||||||
|                     _ => Some(()), |                     _ => Some(()), | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|             ast::Pat(it) => { |             ast::Pat(it) => { | ||||||
|                 binding_mode::hints(hints, famous_defs, config, file_id,  &it); |                 binding_mode::hints(hints, famous_defs, config, &it); | ||||||
|                 match it { |                 match it { | ||||||
|                     ast::Pat::IdentPat(it) => { |                     ast::Pat::IdentPat(it) => { | ||||||
|                         bind_pat::hints(hints, famous_defs, config, display_target, &it); |                         bind_pat::hints(hints, famous_defs, config, display_target, &it); | ||||||
|                     } |                     } | ||||||
|                     ast::Pat::RangePat(it) => { |                     ast::Pat::RangePat(it) => { | ||||||
|                         range_exclusive::hints(hints, famous_defs, config, file_id, it); |                         range_exclusive::hints(hints, famous_defs, config, it); | ||||||
|                     } |                     } | ||||||
|                     _ => {} |                     _ => {} | ||||||
|                 } |                 } | ||||||
|  | @ -250,30 +254,33 @@ fn hints( | ||||||
|             }, |             }, | ||||||
|             ast::Item(it) => match it { |             ast::Item(it) => match it { | ||||||
|                 ast::Item::Fn(it) => { |                 ast::Item::Fn(it) => { | ||||||
|                     implicit_drop::hints(hints, famous_defs, config, file_id, &it); |                     implicit_drop::hints(hints, famous_defs, config, display_target, &it); | ||||||
|                     if let Some(extern_block) = &ctx.extern_block_parent { |                     if let Some(extern_block) = &ctx.extern_block_parent { | ||||||
|                         extern_block::fn_hints(hints, famous_defs, config, file_id, &it, extern_block); |                         extern_block::fn_hints(hints, famous_defs, config, &it, extern_block); | ||||||
|                     } |                     } | ||||||
|                     lifetime::fn_hints(hints, ctx, famous_defs, config, file_id, it) |                     lifetime::fn_hints(hints, ctx, famous_defs, config,  it) | ||||||
|                 }, |                 }, | ||||||
|                 ast::Item::Static(it) => { |                 ast::Item::Static(it) => { | ||||||
|                     if let Some(extern_block) = &ctx.extern_block_parent { |                     if let Some(extern_block) = &ctx.extern_block_parent { | ||||||
|                         extern_block::static_hints(hints, famous_defs, config, file_id, &it, extern_block); |                         extern_block::static_hints(hints, famous_defs, config, &it, extern_block); | ||||||
|                     } |                     } | ||||||
|                     implicit_static::hints(hints, famous_defs, config, file_id, Either::Left(it)) |                     implicit_static::hints(hints, famous_defs, config,  Either::Left(it)) | ||||||
|                 }, |                 }, | ||||||
|                 ast::Item::Const(it) => implicit_static::hints(hints, famous_defs, config, file_id, Either::Right(it)), |                 ast::Item::Const(it) => implicit_static::hints(hints, famous_defs, config, Either::Right(it)), | ||||||
|                 ast::Item::Enum(it) => discriminant::enum_hints(hints, famous_defs, config, file_id, it), |                 ast::Item::Enum(it) => discriminant::enum_hints(hints, famous_defs, config, it), | ||||||
|                 ast::Item::ExternBlock(it) => extern_block::extern_block_hints(hints, famous_defs, config, file_id, it), |                 ast::Item::ExternBlock(it) => extern_block::extern_block_hints(hints, famous_defs, config, it), | ||||||
|                 _ => None, |                 _ => None, | ||||||
|             }, |             }, | ||||||
|             // FIXME: trait object type elisions
 |             // FIXME: trait object type elisions
 | ||||||
|             ast::Type(ty) => match ty { |             ast::Type(ty) => match ty { | ||||||
|                 ast::Type::FnPtrType(ptr) => lifetime::fn_ptr_hints(hints, ctx, famous_defs, config, file_id, ptr), |                 ast::Type::FnPtrType(ptr) => lifetime::fn_ptr_hints(hints, ctx, famous_defs, config,  ptr), | ||||||
|                 ast::Type::PathType(path) => lifetime::fn_path_hints(hints, ctx, famous_defs, config, file_id, path), |                 ast::Type::PathType(path) => { | ||||||
|  |                     lifetime::fn_path_hints(hints, ctx, famous_defs, config,  path); | ||||||
|  |                     Some(()) | ||||||
|  |                 }, | ||||||
|                 _ => Some(()), |                 _ => Some(()), | ||||||
|             }, |             }, | ||||||
|             ast::GenericParamList(it) => bounds::hints(hints, famous_defs, config, file_id, it), |             ast::GenericParamList(it) => bounds::hints(hints, famous_defs, config,  it), | ||||||
|             _ => Some(()), |             _ => Some(()), | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ use hir::Mutability; | ||||||
| use ide_db::famous_defs::FamousDefs; | use ide_db::famous_defs::FamousDefs; | ||||||
| 
 | 
 | ||||||
| use ide_db::text_edit::TextEditBuilder; | use ide_db::text_edit::TextEditBuilder; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::ast::{self, AstNode}; | use syntax::ast::{self, AstNode}; | ||||||
| 
 | 
 | ||||||
| use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind}; | use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind}; | ||||||
|  | @ -17,7 +16,6 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     pat: &ast::Pat, |     pat: &ast::Pat, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if !config.binding_mode_hints { |     if !config.binding_mode_hints { | ||||||
|  |  | ||||||
|  | @ -3,7 +3,6 @@ | ||||||
| //! Currently this renders the implied `Sized` bound.
 | //! Currently this renders the implied `Sized` bound.
 | ||||||
| use ide_db::{FileRange, famous_defs::FamousDefs}; | use ide_db::{FileRange, famous_defs::FamousDefs}; | ||||||
| 
 | 
 | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::ast::{self, AstNode, HasTypeBounds}; | use syntax::ast::{self, AstNode, HasTypeBounds}; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|  | @ -15,7 +14,6 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>, |     famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     params: ast::GenericParamList, |     params: ast::GenericParamList, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if !config.sized_bound { |     if !config.sized_bound { | ||||||
|  |  | ||||||
|  | @ -3,9 +3,8 @@ | ||||||
| //! fn g() {
 | //! fn g() {
 | ||||||
| //! } /* fn g */
 | //! } /* fn g */
 | ||||||
| //! ```
 | //! ```
 | ||||||
| use hir::{DisplayTarget, HirDisplay, Semantics}; | use hir::{DisplayTarget, HirDisplay, InRealFile, Semantics}; | ||||||
| use ide_db::{FileRange, RootDatabase}; | use ide_db::{FileRange, RootDatabase}; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{ | use syntax::{ | ||||||
|     SyntaxKind, SyntaxNode, T, |     SyntaxKind, SyntaxNode, T, | ||||||
|     ast::{self, AstNode, HasLoopBody, HasName}, |     ast::{self, AstNode, HasLoopBody, HasName}, | ||||||
|  | @ -21,15 +20,14 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     sema: &Semantics<'_, RootDatabase>, |     sema: &Semantics<'_, RootDatabase>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |  | ||||||
|     display_target: DisplayTarget, |     display_target: DisplayTarget, | ||||||
|     original_node: SyntaxNode, |     InRealFile { file_id, value: node }: InRealFile<SyntaxNode>, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     let min_lines = config.closing_brace_hints_min_lines?; |     let min_lines = config.closing_brace_hints_min_lines?; | ||||||
| 
 | 
 | ||||||
|     let name = |it: ast::Name| it.syntax().text_range(); |     let name = |it: ast::Name| it.syntax().text_range(); | ||||||
| 
 | 
 | ||||||
|     let mut node = original_node.clone(); |     let mut node = node.clone(); | ||||||
|     let mut closing_token; |     let mut closing_token; | ||||||
|     let (label, name_range) = if let Some(item_list) = ast::AssocItemList::cast(node.clone()) { |     let (label, name_range) = if let Some(item_list) = ast::AssocItemList::cast(node.clone()) { | ||||||
|         closing_token = item_list.r_curly_token()?; |         closing_token = item_list.r_curly_token()?; | ||||||
|  | @ -44,7 +42,7 @@ pub(super) fn hints( | ||||||
|                     let hint_text = match trait_ { |                     let hint_text = match trait_ { | ||||||
|                         Some(tr) => format!( |                         Some(tr) => format!( | ||||||
|                             "impl {} for {}", |                             "impl {} for {}", | ||||||
|                             tr.name(sema.db).display(sema.db, file_id.edition()), |                             tr.name(sema.db).display(sema.db, display_target.edition), | ||||||
|                             ty.display_truncated(sema.db, config.max_length, display_target, |                             ty.display_truncated(sema.db, config.max_length, display_target, | ||||||
|                         )), |                         )), | ||||||
|                         None => format!("impl {}", ty.display_truncated(sema.db, config.max_length, display_target)), |                         None => format!("impl {}", ty.display_truncated(sema.db, config.max_length, display_target)), | ||||||
|  | @ -142,7 +140,8 @@ pub(super) fn hints( | ||||||
|         return None; |         return None; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     let linked_location = name_range.map(|range| FileRange { file_id: file_id.into(), range }); |     let linked_location = | ||||||
|  |         name_range.map(|range| FileRange { file_id: file_id.file_id(sema.db), range }); | ||||||
|     acc.push(InlayHint { |     acc.push(InlayHint { | ||||||
|         range: closing_token.text_range(), |         range: closing_token.text_range(), | ||||||
|         kind: InlayKind::ClosingBrace, |         kind: InlayKind::ClosingBrace, | ||||||
|  | @ -151,7 +150,7 @@ pub(super) fn hints( | ||||||
|         position: InlayHintPosition::After, |         position: InlayHintPosition::After, | ||||||
|         pad_left: true, |         pad_left: true, | ||||||
|         pad_right: false, |         pad_right: false, | ||||||
|         resolve_parent: Some(original_node.text_range()), |         resolve_parent: Some(node.text_range()), | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     None |     None | ||||||
|  |  | ||||||
|  | @ -7,7 +7,6 @@ | ||||||
| use hir::Semantics; | use hir::Semantics; | ||||||
| use ide_db::text_edit::TextEdit; | use ide_db::text_edit::TextEdit; | ||||||
| use ide_db::{RootDatabase, famous_defs::FamousDefs}; | use ide_db::{RootDatabase, famous_defs::FamousDefs}; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::ast::{self, AstNode, HasName}; | use syntax::ast::{self, AstNode, HasName}; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|  | @ -19,7 +18,6 @@ pub(super) fn enum_hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _: EditionedFileId, |  | ||||||
|     enum_: ast::Enum, |     enum_: ast::Enum, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if let DiscriminantHints::Never = config.discriminant_hints { |     if let DiscriminantHints::Never = config.discriminant_hints { | ||||||
|  |  | ||||||
|  | @ -1,6 +1,5 @@ | ||||||
| //! Extern block hints
 | //! Extern block hints
 | ||||||
| use ide_db::{famous_defs::FamousDefs, text_edit::TextEdit}; | use ide_db::{famous_defs::FamousDefs, text_edit::TextEdit}; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{AstNode, SyntaxToken, ast}; | use syntax::{AstNode, SyntaxToken, ast}; | ||||||
| 
 | 
 | ||||||
| use crate::{InlayHint, InlayHintsConfig}; | use crate::{InlayHint, InlayHintsConfig}; | ||||||
|  | @ -9,7 +8,6 @@ pub(super) fn extern_block_hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     extern_block: ast::ExternBlock, |     extern_block: ast::ExternBlock, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if extern_block.unsafe_token().is_some() { |     if extern_block.unsafe_token().is_some() { | ||||||
|  | @ -36,7 +34,6 @@ pub(super) fn fn_hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     fn_: &ast::Fn, |     fn_: &ast::Fn, | ||||||
|     extern_block: &ast::ExternBlock, |     extern_block: &ast::ExternBlock, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|  | @ -55,7 +52,6 @@ pub(super) fn static_hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     static_: &ast::Static, |     static_: &ast::Static, | ||||||
|     extern_block: &ast::ExternBlock, |     extern_block: &ast::ExternBlock, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|  |  | ||||||
|  | @ -12,7 +12,6 @@ use hir::{ | ||||||
| }; | }; | ||||||
| use ide_db::{FileRange, famous_defs::FamousDefs}; | use ide_db::{FileRange, famous_defs::FamousDefs}; | ||||||
| 
 | 
 | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{ | use syntax::{ | ||||||
|     ToSmolStr, |     ToSmolStr, | ||||||
|     ast::{self, AstNode}, |     ast::{self, AstNode}, | ||||||
|  | @ -25,7 +24,7 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(sema, _): &FamousDefs<'_, '_>, |     FamousDefs(sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |     display_target: hir::DisplayTarget, | ||||||
|     node: &ast::Fn, |     node: &ast::Fn, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if !config.implicit_drop_hints { |     if !config.implicit_drop_hints { | ||||||
|  | @ -94,7 +93,7 @@ pub(super) fn hints( | ||||||
|                 MirSpan::Unknown => continue, |                 MirSpan::Unknown => continue, | ||||||
|             }; |             }; | ||||||
|             let binding = &hir.bindings[binding_idx]; |             let binding = &hir.bindings[binding_idx]; | ||||||
|             let name = binding.name.display_no_db(file_id.edition()).to_smolstr(); |             let name = binding.name.display_no_db(display_target.edition).to_smolstr(); | ||||||
|             if name.starts_with("<ra@") { |             if name.starts_with("<ra@") { | ||||||
|                 continue; // Ignore desugared variables
 |                 continue; // Ignore desugared variables
 | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | @ -5,7 +5,6 @@ | ||||||
| use either::Either; | use either::Either; | ||||||
| use ide_db::famous_defs::FamousDefs; | use ide_db::famous_defs::FamousDefs; | ||||||
| use ide_db::text_edit::TextEdit; | use ide_db::text_edit::TextEdit; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{ | use syntax::{ | ||||||
|     SyntaxKind, |     SyntaxKind, | ||||||
|     ast::{self, AstNode}, |     ast::{self, AstNode}, | ||||||
|  | @ -17,7 +16,6 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(_sema, _): &FamousDefs<'_, '_>, |     FamousDefs(_sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     statik_or_const: Either<ast::Static, ast::Const>, |     statik_or_const: Either<ast::Static, ast::Const>, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if config.lifetime_elision_hints != LifetimeElisionHints::Always { |     if config.lifetime_elision_hints != LifetimeElisionHints::Always { | ||||||
|  |  | ||||||
|  | @ -6,7 +6,6 @@ use std::iter; | ||||||
| 
 | 
 | ||||||
| use ide_db::{FxHashMap, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty}; | use ide_db::{FxHashMap, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty}; | ||||||
| use itertools::Itertools; | use itertools::Itertools; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{SmolStr, format_smolstr}; | use syntax::{SmolStr, format_smolstr}; | ||||||
| use syntax::{ | use syntax::{ | ||||||
|     SyntaxKind, SyntaxToken, |     SyntaxKind, SyntaxToken, | ||||||
|  | @ -23,7 +22,6 @@ pub(super) fn fn_hints( | ||||||
|     ctx: &mut InlayHintCtx, |     ctx: &mut InlayHintCtx, | ||||||
|     fd: &FamousDefs<'_, '_>, |     fd: &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |  | ||||||
|     func: ast::Fn, |     func: ast::Fn, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if config.lifetime_elision_hints == LifetimeElisionHints::Never { |     if config.lifetime_elision_hints == LifetimeElisionHints::Never { | ||||||
|  | @ -40,7 +38,6 @@ pub(super) fn fn_hints( | ||||||
|         ctx, |         ctx, | ||||||
|         fd, |         fd, | ||||||
|         config, |         config, | ||||||
|         file_id, |  | ||||||
|         param_list.params().filter_map(|it| { |         param_list.params().filter_map(|it| { | ||||||
|             Some(( |             Some(( | ||||||
|                 it.pat().and_then(|it| match it { |                 it.pat().and_then(|it| match it { | ||||||
|  | @ -74,7 +71,6 @@ pub(super) fn fn_ptr_hints( | ||||||
|     ctx: &mut InlayHintCtx, |     ctx: &mut InlayHintCtx, | ||||||
|     fd: &FamousDefs<'_, '_>, |     fd: &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |  | ||||||
|     func: ast::FnPtrType, |     func: ast::FnPtrType, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if config.lifetime_elision_hints == LifetimeElisionHints::Never { |     if config.lifetime_elision_hints == LifetimeElisionHints::Never { | ||||||
|  | @ -97,7 +93,6 @@ pub(super) fn fn_ptr_hints( | ||||||
|         ctx, |         ctx, | ||||||
|         fd, |         fd, | ||||||
|         config, |         config, | ||||||
|         file_id, |  | ||||||
|         param_list.params().filter_map(|it| { |         param_list.params().filter_map(|it| { | ||||||
|             Some(( |             Some(( | ||||||
|                 it.pat().and_then(|it| match it { |                 it.pat().and_then(|it| match it { | ||||||
|  | @ -140,7 +135,6 @@ pub(super) fn fn_path_hints( | ||||||
|     ctx: &mut InlayHintCtx, |     ctx: &mut InlayHintCtx, | ||||||
|     fd: &FamousDefs<'_, '_>, |     fd: &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     file_id: EditionedFileId, |  | ||||||
|     func: ast::PathType, |     func: ast::PathType, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     if config.lifetime_elision_hints == LifetimeElisionHints::Never { |     if config.lifetime_elision_hints == LifetimeElisionHints::Never { | ||||||
|  | @ -163,7 +157,6 @@ pub(super) fn fn_path_hints( | ||||||
|         ctx, |         ctx, | ||||||
|         fd, |         fd, | ||||||
|         config, |         config, | ||||||
|         file_id, |  | ||||||
|         param_list.type_args().filter_map(|it| Some((None, it.ty()?))), |         param_list.type_args().filter_map(|it| Some((None, it.ty()?))), | ||||||
|         generic_param_list, |         generic_param_list, | ||||||
|         ret_type, |         ret_type, | ||||||
|  | @ -202,7 +195,6 @@ fn hints_( | ||||||
|     ctx: &mut InlayHintCtx, |     ctx: &mut InlayHintCtx, | ||||||
|     FamousDefs(_, _): &FamousDefs<'_, '_>, |     FamousDefs(_, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     params: impl Iterator<Item = (Option<ast::Name>, ast::Type)>, |     params: impl Iterator<Item = (Option<ast::Name>, ast::Type)>, | ||||||
|     generic_param_list: Option<ast::GenericParamList>, |     generic_param_list: Option<ast::GenericParamList>, | ||||||
|     ret_type: Option<ast::RetType>, |     ret_type: Option<ast::RetType>, | ||||||
|  |  | ||||||
|  | @ -4,7 +4,6 @@ | ||||||
| //! if let ../* < */100 = 50 {}
 | //! if let ../* < */100 = 50 {}
 | ||||||
| //! ```
 | //! ```
 | ||||||
| use ide_db::famous_defs::FamousDefs; | use ide_db::famous_defs::FamousDefs; | ||||||
| use span::EditionedFileId; |  | ||||||
| use syntax::{SyntaxToken, T, ast}; | use syntax::{SyntaxToken, T, ast}; | ||||||
| 
 | 
 | ||||||
| use crate::{InlayHint, InlayHintsConfig}; | use crate::{InlayHint, InlayHintsConfig}; | ||||||
|  | @ -13,7 +12,6 @@ pub(super) fn hints( | ||||||
|     acc: &mut Vec<InlayHint>, |     acc: &mut Vec<InlayHint>, | ||||||
|     FamousDefs(_sema, _): &FamousDefs<'_, '_>, |     FamousDefs(_sema, _): &FamousDefs<'_, '_>, | ||||||
|     config: &InlayHintsConfig, |     config: &InlayHintsConfig, | ||||||
|     _file_id: EditionedFileId, |  | ||||||
|     range: impl ast::RangeItem, |     range: impl ast::RangeItem, | ||||||
| ) -> Option<()> { | ) -> Option<()> { | ||||||
|     (config.range_exclusive_hints && range.end().is_some()) |     (config.range_exclusive_hints && range.end().is_some()) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth