File tree 2 files changed +20
-4
lines changed
src/tools/rust-analyzer/crates 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -139,13 +139,11 @@ impl Visibility {
139
139
let def_map_block = def_map. block_id ( ) ;
140
140
loop {
141
141
match ( to_module. block , def_map_block) {
142
- // to_module is not a block, so there is no parent def map to use
142
+ // ` to_module` is not a block, so there is no parent def map to use.
143
143
( None , _) => ( ) ,
144
+ // `to_module` is at `def_map`'s block, no need to move further.
144
145
( Some ( a) , Some ( b) ) if a == b => {
145
146
cov_mark:: hit!( is_visible_from_same_block_def_map) ;
146
- if let Some ( parent) = def_map. parent ( ) {
147
- to_module = parent;
148
- }
149
147
}
150
148
_ => {
151
149
if let Some ( parent) = to_module. def_map ( db) . parent ( ) {
Original file line number Diff line number Diff line change @@ -923,3 +923,21 @@ fn foo() {
923
923
"# ] ] ,
924
924
) ;
925
925
}
926
+
927
+ #[ test]
928
+ fn private_item_in_module_in_function_body ( ) {
929
+ check_empty (
930
+ r#"
931
+ fn main() {
932
+ mod foo {
933
+ struct Private;
934
+ pub struct Public;
935
+ }
936
+ foo::$0
937
+ }
938
+ "# ,
939
+ expect ! [ [ r#"
940
+ st Public Public
941
+ "# ] ] ,
942
+ ) ;
943
+ }
You can’t perform that action at this time.
0 commit comments