File tree Expand file tree Collapse file tree 1 file changed +31
-5
lines changed
src/tools/rust-analyzer/crates/ide/src/inlay_hints Expand file tree Collapse file tree 1 file changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,12 @@ pub(super) fn hints(
1717 let parent = path. syntax ( ) . parent ( ) ?;
1818 let range = match path {
1919 Either :: Left ( path) => {
20- let paren =
21- parent. ancestors ( ) . take_while ( |it| ast:: ParenType :: can_cast ( it. kind ( ) ) ) . last ( ) ;
20+ let paren = parent
21+ . ancestors ( )
22+ . take_while ( |it| {
23+ ast:: ParenType :: can_cast ( it. kind ( ) ) || ast:: ForType :: can_cast ( it. kind ( ) )
24+ } )
25+ . last ( ) ;
2226 let parent = paren. as_ref ( ) . and_then ( |it| it. parent ( ) ) . unwrap_or ( parent) ;
2327 if ast:: TypeBound :: can_cast ( parent. kind ( ) )
2428 || ast:: TypeAnchor :: can_cast ( parent. kind ( ) )
@@ -34,7 +38,7 @@ pub(super) fn hints(
3438 return None ;
3539 }
3640 sema. resolve_trait ( & path. path ( ) ?) ?;
37- paren . map_or_else ( || path. syntax ( ) . text_range ( ) , |it| it . text_range ( ) )
41+ path. syntax ( ) . text_range ( )
3842 }
3943 Either :: Right ( dyn_) => {
4044 if dyn_. dyn_token ( ) . is_some ( ) {
@@ -89,7 +93,7 @@ fn foo(_: &T, _: for<'a> T) {}
8993impl T {}
9094 // ^ dyn
9195impl T for (T) {}
92- // ^^ ^ dyn
96+ // ^ dyn
9397impl T
9498"# ,
9599 ) ;
@@ -112,7 +116,7 @@ fn foo(
112116 _: &mut (T + T)
113117 // ^^^^^ dyn
114118 _: *mut (T),
115- // ^^ ^ dyn
119+ // ^ dyn
116120) {}
117121"# ,
118122 ) ;
@@ -136,4 +140,26 @@ fn foo(
136140 "# ] ] ,
137141 ) ;
138142 }
143+
144+ #[ test]
145+ fn hrtb_bound_does_not_add_dyn ( ) {
146+ check (
147+ r#"
148+ //- minicore: fn
149+ fn test<F>(f: F) where F: for<'a> FnOnce(&'a i32) {}
150+ // ^: Sized
151+ "# ,
152+ ) ;
153+ }
154+
155+ #[ test]
156+ fn with_parentheses ( ) {
157+ check (
158+ r#"
159+ trait T {}
160+ fn foo(v: &(T)) {}
161+ // ^ dyn
162+ "# ,
163+ ) ;
164+ }
139165}
You can’t perform that action at this time.
0 commit comments