Restore a mark

This commit is contained in:
Aleksey Kladov 2019-11-21 15:49:24 +03:00
parent 6d64798a23
commit c37d1c5b38
3 changed files with 20 additions and 1 deletions

View file

@ -12,6 +12,7 @@ use ra_syntax::{
},
AstNode, AstPtr,
};
use test_utils::tested_by;
use crate::{
body::{Body, BodySourceMap, Expander, PatPtr},
@ -153,6 +154,7 @@ where
None => self.collect_expr_opt(condition.expr()),
// if let -- desugar to match
Some(pat) => {
tested_by!(infer_resolve_while_let);
let pat = self.collect_pat(pat);
let match_expr = self.collect_expr_opt(condition.expr());
let placeholder_pat = self.missing_pat();

View file

@ -174,7 +174,7 @@ mod tests {
use hir_expand::{name::AsName, Source};
use ra_db::{fixture::WithFixture, FileId, SourceDatabase};
use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
use test_utils::{assert_eq_text, extract_offset};
use test_utils::{assert_eq_text, covers, extract_offset};
use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId};
@ -382,4 +382,20 @@ mod tests {
53,
);
}
#[test]
fn infer_resolve_while_let() {
covers!(infer_resolve_while_let);
do_check_local_name(
r#"
fn test() {
let foo: Option<f32> = None;
while let Option::Some(spam) = foo {
spam<|>
}
}
"#,
75,
);
}
}

View file

@ -11,4 +11,5 @@ test_utils::marks!(
prelude_is_macro_use
macro_dollar_crate_self
macro_dollar_crate_other
infer_resolve_while_let
);