File tree Expand file tree Collapse file tree 3 files changed +37
-6
lines changed Expand file tree Collapse file tree 3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ impl<'a> InferenceContext<'a> {
227
227
self . table . trait_env . clone ( ) ,
228
228
krate,
229
229
& traits_in_scope,
230
- None ,
230
+ self . resolver . module ( ) ,
231
231
Some ( name) ,
232
232
method_resolution:: LookupMode :: Path ,
233
233
move |_ty, item| {
Original file line number Diff line number Diff line change @@ -84,6 +84,37 @@ fn infer_associated_method_struct() {
84
84
) ;
85
85
}
86
86
87
+ #[ test]
88
+ fn infer_associated_method_struct_in_local_scope ( ) {
89
+ check_infer (
90
+ r#"
91
+ fn mismatch() {
92
+ struct A;
93
+
94
+ impl A {
95
+ fn from(_: i32, _: i32) -> Self {
96
+ A
97
+ }
98
+ }
99
+
100
+ let _a = A::from(1, 2);
101
+ }
102
+ "# ,
103
+ expect ! [ [ r#"
104
+ 14..146 '{ ... 2); }': ()
105
+ 125..127 '_a': A
106
+ 130..137 'A::from': fn from(i32, i32) -> A
107
+ 130..143 'A::from(1, 2)': A
108
+ 138..139 '1': i32
109
+ 141..142 '2': i32
110
+ 60..61 '_': i32
111
+ 68..69 '_': i32
112
+ 84..109 '{ ... }': A
113
+ 98..99 'A': A
114
+ "# ] ] ,
115
+ ) ;
116
+ }
117
+
87
118
#[ test]
88
119
fn infer_associated_method_enum ( ) {
89
120
check_infer (
@@ -277,7 +308,7 @@ fn test() {
277
308
pub mod foo {
278
309
pub struct S;
279
310
impl S {
280
- fn thing() -> i128 { 0 }
311
+ pub fn thing() -> i128 { 0 }
281
312
}
282
313
}
283
314
"# ,
Original file line number Diff line number Diff line change @@ -823,10 +823,10 @@ fn test_hover_infer_associated_method_exact() {
823
823
check (
824
824
r#"
825
825
mod wrapper {
826
- struct Thing { x: u32 }
826
+ pub struct Thing { x: u32 }
827
827
828
828
impl Thing {
829
- fn new() -> Thing { Thing { x: 0 } }
829
+ pub fn new() -> Thing { Thing { x: 0 } }
830
830
}
831
831
}
832
832
@@ -840,9 +840,9 @@ fn main() { let foo_test = wrapper::Thing::new$0(); }
840
840
```
841
841
842
842
```rust
843
- fn new() -> Thing
843
+ pub fn new() -> Thing
844
844
```
845
- "# ] ] ,
845
+ "# ] ] ,
846
846
)
847
847
}
848
848
You can’t perform that action at this time.
0 commit comments