mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 03:54:42 +00:00 
			
		
		
		
	Don't show dyn hint in a HRTB bound
				
					
				
			This commit is contained in:
		
							parent
							
								
									3816d0ae53
								
							
						
					
					
						commit
						3931afa624
					
				
					 1 changed files with 17 additions and 2 deletions
				
			
		|  | @ -17,8 +17,12 @@ pub(super) fn hints( | ||||||
|     let parent = path.syntax().parent()?; |     let parent = path.syntax().parent()?; | ||||||
|     let range = match path { |     let range = match path { | ||||||
|         Either::Left(path) => { |         Either::Left(path) => { | ||||||
|             let paren = |             let paren = parent | ||||||
|                 parent.ancestors().take_while(|it| ast::ParenType::can_cast(it.kind())).last(); |                 .ancestors() | ||||||
|  |                 .take_while(|it| { | ||||||
|  |                     ast::ParenType::can_cast(it.kind()) || ast::ForType::can_cast(it.kind()) | ||||||
|  |                 }) | ||||||
|  |                 .last(); | ||||||
|             let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent); |             let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent); | ||||||
|             if ast::TypeBound::can_cast(parent.kind()) |             if ast::TypeBound::can_cast(parent.kind()) | ||||||
|                 || ast::TypeAnchor::can_cast(parent.kind()) |                 || ast::TypeAnchor::can_cast(parent.kind()) | ||||||
|  | @ -136,4 +140,15 @@ fn foo( | ||||||
|             "#]],
 |             "#]],
 | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     #[test] | ||||||
|  |     fn hrtb_bound_does_not_add_dyn() { | ||||||
|  |         check( | ||||||
|  |             r#" | ||||||
|  | //- minicore: fn
 | ||||||
|  | fn test<F>(f: F) where F: for<'a> FnOnce(&'a i32) {} | ||||||
|  |      // ^: Sized
 | ||||||
|  |         "#,
 | ||||||
|  |         ); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Chayim Refael Friedman
						Chayim Refael Friedman