File tree 2 files changed +71
-2
lines changed
2 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -1094,13 +1094,13 @@ fn iterate_inherent_methods(
1094
1094
None => return ControlFlow :: Continue ( ( ) ) ,
1095
1095
} ;
1096
1096
1097
- let ( module, block) = match visible_from_module {
1097
+ let ( module, mut block) = match visible_from_module {
1098
1098
VisibleFromModule :: Filter ( module) => ( Some ( module) , module. containing_block ( ) ) ,
1099
1099
VisibleFromModule :: IncludeBlock ( block) => ( None , Some ( block) ) ,
1100
1100
VisibleFromModule :: None => ( None , None ) ,
1101
1101
} ;
1102
1102
1103
- if let Some ( block_id) = block {
1103
+ while let Some ( block_id) = block {
1104
1104
if let Some ( impls) = db. inherent_impls_in_block ( block_id) {
1105
1105
impls_for_self_ty (
1106
1106
& impls,
@@ -1113,6 +1113,11 @@ fn iterate_inherent_methods(
1113
1113
callback,
1114
1114
) ?;
1115
1115
}
1116
+
1117
+ block = db
1118
+ . block_def_map ( block_id)
1119
+ . and_then ( |map| map. parent ( ) )
1120
+ . and_then ( |module| module. containing_block ( ) ) ;
1116
1121
}
1117
1122
1118
1123
for krate in def_crates {
Original file line number Diff line number Diff line change @@ -1916,4 +1916,68 @@ fn main() {
1916
1916
"# ,
1917
1917
)
1918
1918
}
1919
+
1920
+ #[ test]
1921
+ fn query_impls_in_nearest_block ( ) {
1922
+ check (
1923
+ r#"
1924
+ struct S1;
1925
+ impl S1 {
1926
+ fn e() -> () {}
1927
+ }
1928
+ fn f1() {
1929
+ struct S1;
1930
+ impl S1 {
1931
+ fn e() -> () {}
1932
+ //^
1933
+ }
1934
+ fn f2() {
1935
+ fn f3() {
1936
+ S1::e$0();
1937
+ }
1938
+ }
1939
+ }
1940
+ "# ,
1941
+ ) ;
1942
+
1943
+ check (
1944
+ r#"
1945
+ struct S1;
1946
+ impl S1 {
1947
+ fn e() -> () {}
1948
+ }
1949
+ fn f1() {
1950
+ struct S1;
1951
+ impl S1 {
1952
+ fn e() -> () {}
1953
+ //^
1954
+ }
1955
+ fn f2() {
1956
+ struct S2;
1957
+ S1::e$0();
1958
+ }
1959
+ }
1960
+ fn f12() {
1961
+ struct S1;
1962
+ impl S1 {
1963
+ fn e() -> () {}
1964
+ }
1965
+ }
1966
+ "# ,
1967
+ ) ;
1968
+
1969
+ check (
1970
+ r#"
1971
+ struct S1;
1972
+ impl S1 {
1973
+ fn e() -> () {}
1974
+ //^
1975
+ }
1976
+ fn f2() {
1977
+ struct S2;
1978
+ S1::e$0();
1979
+ }
1980
+ "# ,
1981
+ ) ;
1982
+ }
1919
1983
}
You can’t perform that action at this time.
0 commit comments