Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r--crates/hir/src/diagnostics.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index 6ef6ea272e..050777a480 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -617,7 +617,7 @@ impl<'db> AnyDiagnostic<'db> {
pub(crate) fn inference_diagnostic(
db: &'db dyn HirDatabase,
def: DefWithBodyId,
- d: &InferenceDiagnostic<'db>,
+ d: &InferenceDiagnostic,
source_map: &hir_def::expr_store::BodySourceMap,
sig_map: &hir_def::expr_store::ExpressionStoreSourceMap,
) -> Option<AnyDiagnostic<'db>> {
@@ -663,7 +663,8 @@ impl<'db> AnyDiagnostic<'db> {
}
InferenceDiagnostic::ExpectedFunction { call_expr, found } => {
let call_expr = expr_syntax(*call_expr)?;
- ExpectedFunction { call: call_expr, found: Type::new(db, def, *found) }.into()
+ ExpectedFunction { call: call_expr, found: Type::new(db, def, found.as_ref()) }
+ .into()
}
InferenceDiagnostic::UnresolvedField {
expr,
@@ -675,7 +676,7 @@ impl<'db> AnyDiagnostic<'db> {
UnresolvedField {
expr,
name: name.clone(),
- receiver: Type::new(db, def, *receiver),
+ receiver: Type::new(db, def, receiver.as_ref()),
method_with_same_name_exists: *method_with_same_name_exists,
}
.into()
@@ -691,8 +692,10 @@ impl<'db> AnyDiagnostic<'db> {
UnresolvedMethodCall {
expr,
name: name.clone(),
- receiver: Type::new(db, def, *receiver),
- field_with_same_name: (*field_with_same_name).map(|ty| Type::new(db, def, ty)),
+ receiver: Type::new(db, def, receiver.as_ref()),
+ field_with_same_name: field_with_same_name
+ .as_ref()
+ .map(|ty| Type::new(db, def, ty.as_ref())),
assoc_func_with_same_name: assoc_func_with_same_name.map(Into::into),
}
.into()
@@ -719,7 +722,7 @@ impl<'db> AnyDiagnostic<'db> {
}
InferenceDiagnostic::TypedHole { expr, expected } => {
let expr = expr_syntax(*expr)?;
- TypedHole { expr, expected: Type::new(db, def, *expected) }.into()
+ TypedHole { expr, expected: Type::new(db, def, expected.as_ref()) }.into()
}
&InferenceDiagnostic::MismatchedTupleStructPatArgCount { pat, expected, found } => {
let expr_or_pat = match pat {
@@ -736,12 +739,12 @@ impl<'db> AnyDiagnostic<'db> {
}
InferenceDiagnostic::CastToUnsized { expr, cast_ty } => {
let expr = expr_syntax(*expr)?;
- CastToUnsized { expr, cast_ty: Type::new(db, def, *cast_ty) }.into()
+ CastToUnsized { expr, cast_ty: Type::new(db, def, cast_ty.as_ref()) }.into()
}
InferenceDiagnostic::InvalidCast { expr, error, expr_ty, cast_ty } => {
let expr = expr_syntax(*expr)?;
- let expr_ty = Type::new(db, def, *expr_ty);
- let cast_ty = Type::new(db, def, *cast_ty);
+ let expr_ty = Type::new(db, def, expr_ty.as_ref());
+ let cast_ty = Type::new(db, def, cast_ty.as_ref());
InvalidCast { expr, error: *error, expr_ty, cast_ty }.into()
}
InferenceDiagnostic::TyDiagnostic { source, diag } => {