File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -139,13 +139,11 @@ impl Visibility {
139139 let def_map_block = def_map. block_id ( ) ;
140140 loop {
141141 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.
143143 ( None , _) => ( ) ,
144+ // `to_module` is at `def_map`'s block, no need to move further.
144145 ( Some ( a) , Some ( b) ) if a == b => {
145146 cov_mark:: hit!( is_visible_from_same_block_def_map) ;
146- if let Some ( parent) = def_map. parent ( ) {
147- to_module = parent;
148- }
149147 }
150148 _ => {
151149 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() {
923923 "# ] ] ,
924924 ) ;
925925}
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