Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests.rs')
-rw-r--r--crates/hir-ty/src/tests.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/hir-ty/src/tests.rs b/crates/hir-ty/src/tests.rs
index a31353f1e3..67ab89f5ec 100644
--- a/crates/hir-ty/src/tests.rs
+++ b/crates/hir-ty/src/tests.rs
@@ -149,9 +149,10 @@ fn check_impl(
let (body, body_source_map) = db.body_with_source_map(def);
let inference_result = InferenceResult::for_body(&db, def);
- for (pat, mut ty) in inference_result.type_of_pat.iter() {
+ for (pat, ty) in inference_result.type_of_pat.iter() {
+ let mut ty = ty.as_ref();
if let Pat::Bind { id, .. } = body[pat] {
- ty = &inference_result.type_of_binding[id];
+ ty = inference_result.type_of_binding[id].as_ref();
}
let node = match pat_node(&body_source_map, pat, &db) {
Some(value) => value,
@@ -169,6 +170,7 @@ fn check_impl(
}
for (expr, ty) in inference_result.type_of_expr.iter() {
+ let ty = ty.as_ref();
let node = match expr_node(&body_source_map, expr, &db) {
Some(value) => value,
None => continue,
@@ -209,8 +211,8 @@ fn check_impl(
let range = node.as_ref().original_file_range_rooted(&db);
let actual = format!(
"expected {}, got {}",
- mismatch.expected.display_test(&db, display_target),
- mismatch.actual.display_test(&db, display_target)
+ mismatch.expected.as_ref().display_test(&db, display_target),
+ mismatch.actual.as_ref().display_test(&db, display_target)
);
match mismatches.remove(&range) {
Some(annotation) => assert_eq!(actual, annotation),
@@ -318,20 +320,20 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
crate::attach_db(&db, || {
let mut buf = String::new();
- let mut infer_def = |inference_result: &InferenceResult<'_>,
+ let mut infer_def = |inference_result: &InferenceResult,
body: Arc<Body>,
body_source_map: Arc<BodySourceMap>,
krate: Crate| {
let display_target = DisplayTarget::from_crate(&db, krate);
- let mut types: Vec<(InFile<SyntaxNode>, &Ty<'_>)> = Vec::new();
- let mut mismatches: Vec<(InFile<SyntaxNode>, &TypeMismatch<'_>)> = Vec::new();
+ let mut types: Vec<(InFile<SyntaxNode>, Ty<'_>)> = Vec::new();
+ let mut mismatches: Vec<(InFile<SyntaxNode>, &TypeMismatch)> = Vec::new();
if let Some(self_param) = body.self_param {
let ty = &inference_result.type_of_binding[self_param];
if let Some(syntax_ptr) = body_source_map.self_param_syntax() {
let root = db.parse_or_expand(syntax_ptr.file_id);
let node = syntax_ptr.map(|ptr| ptr.to_node(&root).syntax().clone());
- types.push((node, ty));
+ types.push((node, ty.as_ref()));
}
}
@@ -346,7 +348,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
}
Err(SyntheticSyntax) => continue,
};
- types.push((node.clone(), ty));
+ types.push((node.clone(), ty.as_ref()));
if let Some(mismatch) = inference_result.type_mismatch_for_pat(pat) {
mismatches.push((node, mismatch));
}
@@ -360,7 +362,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
}
Err(SyntheticSyntax) => continue,
};
- types.push((node.clone(), ty));
+ types.push((node.clone(), ty.as_ref()));
if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr) {
mismatches.push((node, mismatch));
}
@@ -401,8 +403,8 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
"{}{:?}: expected {}, got {}\n",
macro_prefix,
range,
- mismatch.expected.display_test(&db, display_target),
- mismatch.actual.display_test(&db, display_target),
+ mismatch.expected.as_ref().display_test(&db, display_target),
+ mismatch.actual.as_ref().display_test(&db, display_target),
);
}
}