diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/nameres/tests/incremental.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/tests/incremental.rs b/crates/hir_def/src/nameres/tests/incremental.rs index 509e1bbbc..747407ec7 100644 --- a/crates/hir_def/src/nameres/tests/incremental.rs +++ b/crates/hir_def/src/nameres/tests/incremental.rs | |||
@@ -105,3 +105,55 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() { | |||
105 | assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) | 105 | assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) |
106 | } | 106 | } |
107 | } | 107 | } |
108 | |||
109 | #[test] | ||
110 | fn typing_inside_a_function_doe_should_not_invalidate_expansions() { | ||
111 | let (mut db, pos) = TestDB::with_position( | ||
112 | r#" | ||
113 | //- /lib.rs | ||
114 | macro_rules! m { | ||
115 | ($ident:ident) => { | ||
116 | fn $ident() { }; | ||
117 | } | ||
118 | } | ||
119 | mod foo; | ||
120 | |||
121 | //- /foo/mod.rs | ||
122 | pub mod bar; | ||
123 | |||
124 | //- /foo/bar.rs | ||
125 | m!(X); | ||
126 | fn quux() { 1$0 } | ||
127 | m!(Y); | ||
128 | m!(Z); | ||
129 | "#, | ||
130 | ); | ||
131 | let krate = db.test_crate(); | ||
132 | { | ||
133 | let events = db.log_executed(|| { | ||
134 | let crate_def_map = db.crate_def_map(krate); | ||
135 | let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); | ||
136 | assert_eq!(module_data.scope.resolutions().count(), 4); | ||
137 | }); | ||
138 | let n_recalculated_item_trees = events.iter().filter(|it| it.contains("item_tree")).count(); | ||
139 | assert_eq!(n_recalculated_item_trees, 6); | ||
140 | } | ||
141 | |||
142 | let new_text = r#" | ||
143 | m!(X); | ||
144 | fn quux() { 92 } | ||
145 | m!(Y); | ||
146 | m!(Z); | ||
147 | "#; | ||
148 | db.set_file_text(pos.file_id, Arc::new(new_text.to_string())); | ||
149 | |||
150 | { | ||
151 | let events = db.log_executed(|| { | ||
152 | let crate_def_map = db.crate_def_map(krate); | ||
153 | let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); | ||
154 | assert_eq!(module_data.scope.resolutions().count(), 4); | ||
155 | }); | ||
156 | let n_recalculated_item_trees = events.iter().filter(|it| it.contains("item_tree")).count(); | ||
157 | assert_eq!(n_recalculated_item_trees, 1); | ||
158 | } | ||
159 | } | ||