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(
17
17
let parent = path. syntax ( ) . parent ( ) ?;
18
18
let range = match path {
19
19
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 ( ) ;
22
26
let parent = paren. as_ref ( ) . and_then ( |it| it. parent ( ) ) . unwrap_or ( parent) ;
23
27
if ast:: TypeBound :: can_cast ( parent. kind ( ) )
24
28
|| ast:: TypeAnchor :: can_cast ( parent. kind ( ) )
@@ -34,7 +38,7 @@ pub(super) fn hints(
34
38
return None ;
35
39
}
36
40
sema. resolve_trait ( & path. path ( ) ?) ?;
37
- paren . map_or_else ( || path. syntax ( ) . text_range ( ) , |it| it . text_range ( ) )
41
+ path. syntax ( ) . text_range ( )
38
42
}
39
43
Either :: Right ( dyn_) => {
40
44
if dyn_. dyn_token ( ) . is_some ( ) {
@@ -89,7 +93,7 @@ fn foo(_: &T, _: for<'a> T) {}
89
93
impl T {}
90
94
// ^ dyn
91
95
impl T for (T) {}
92
- // ^^ ^ dyn
96
+ // ^ dyn
93
97
impl T
94
98
"# ,
95
99
) ;
@@ -112,7 +116,7 @@ fn foo(
112
116
_: &mut (T + T)
113
117
// ^^^^^ dyn
114
118
_: *mut (T),
115
- // ^^ ^ dyn
119
+ // ^ dyn
116
120
) {}
117
121
"# ,
118
122
) ;
@@ -136,4 +140,26 @@ fn foo(
136
140
"# ] ] ,
137
141
) ;
138
142
}
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
+ }
139
165
}
You can’t perform that action at this time.
0 commit comments