aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
-rw-r--r--crates/ra_hir_def/src/body/scope.rs18
-rw-r--r--crates/ra_hir_def/src/marks.rs1
3 files changed, 20 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index a5bb60e85..77f091288 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -12,6 +12,7 @@ use ra_syntax::{
12 }, 12 },
13 AstNode, AstPtr, 13 AstNode, AstPtr,
14}; 14};
15use test_utils::tested_by;
15 16
16use crate::{ 17use crate::{
17 body::{Body, BodySourceMap, Expander, PatPtr}, 18 body::{Body, BodySourceMap, Expander, PatPtr},
@@ -153,6 +154,7 @@ where
153 None => self.collect_expr_opt(condition.expr()), 154 None => self.collect_expr_opt(condition.expr()),
154 // if let -- desugar to match 155 // if let -- desugar to match
155 Some(pat) => { 156 Some(pat) => {
157 tested_by!(infer_resolve_while_let);
156 let pat = self.collect_pat(pat); 158 let pat = self.collect_pat(pat);
157 let match_expr = self.collect_expr_opt(condition.expr()); 159 let match_expr = self.collect_expr_opt(condition.expr());
158 let placeholder_pat = self.missing_pat(); 160 let placeholder_pat = self.missing_pat();
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs
index aeb71ff22..5d7d17231 100644
--- a/crates/ra_hir_def/src/body/scope.rs
+++ b/crates/ra_hir_def/src/body/scope.rs
@@ -174,7 +174,7 @@ mod tests {
174 use hir_expand::{name::AsName, Source}; 174 use hir_expand::{name::AsName, Source};
175 use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; 175 use ra_db::{fixture::WithFixture, FileId, SourceDatabase};
176 use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; 176 use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
177 use test_utils::{assert_eq_text, extract_offset}; 177 use test_utils::{assert_eq_text, covers, extract_offset};
178 178
179 use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId}; 179 use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId};
180 180
@@ -382,4 +382,20 @@ mod tests {
382 53, 382 53,
383 ); 383 );
384 } 384 }
385
386 #[test]
387 fn infer_resolve_while_let() {
388 covers!(infer_resolve_while_let);
389 do_check_local_name(
390 r#"
391fn test() {
392 let foo: Option<f32> = None;
393 while let Option::Some(spam) = foo {
394 spam<|>
395 }
396}
397"#,
398 75,
399 );
400 }
385} 401}
diff --git a/crates/ra_hir_def/src/marks.rs b/crates/ra_hir_def/src/marks.rs
index 0b99eac71..65239ca0a 100644
--- a/crates/ra_hir_def/src/marks.rs
+++ b/crates/ra_hir_def/src/marks.rs
@@ -11,4 +11,5 @@ test_utils::marks!(
11 prelude_is_macro_use 11 prelude_is_macro_use
12 macro_dollar_crate_self 12 macro_dollar_crate_self
13 macro_dollar_crate_other 13 macro_dollar_crate_other
14 infer_resolve_while_let
14); 15);