mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Minor cleanup
This commit is contained in:
parent
64a1b26b8d
commit
f73d0ee439
2 changed files with 12 additions and 14 deletions
|
@ -34,10 +34,10 @@ use rustc_hash::FxHashMap;
|
||||||
use stdx::impl_from;
|
use stdx::impl_from;
|
||||||
use syntax::SmolStr;
|
use syntax::SmolStr;
|
||||||
|
|
||||||
use super::{DomainGoal, InEnvironment, ProjectionTy, TraitEnvironment, TraitRef, Ty};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, fold_tys, lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy,
|
db::HirDatabase, fold_tys, lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy,
|
||||||
Goal, Interner, Substitution, TyBuilder, TyExt, TyKind,
|
DomainGoal, Goal, InEnvironment, Interner, ProjectionTy, Substitution, TraitEnvironment,
|
||||||
|
TraitRef, Ty, TyBuilder, TyExt, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
// This lint has a false positive here. See the link below for details.
|
// This lint has a false positive here. See the link below for details.
|
||||||
|
|
|
@ -10,13 +10,14 @@ use hir_def::{expr::ExprId, lang_item::LangItemTarget};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
autoderef,
|
autoderef,
|
||||||
infer::{Adjust, Adjustment, AutoBorrow, InferResult, PointerCast, TypeMismatch},
|
infer::{
|
||||||
static_lifetime, Canonical, DomainGoal, FnPointer, FnSig, Interner, Solution, Substitution, Ty,
|
Adjust, Adjustment, AutoBorrow, InferOk, InferResult, InferenceContext, PointerCast,
|
||||||
TyBuilder, TyExt, TyKind,
|
TypeError, TypeMismatch,
|
||||||
|
},
|
||||||
|
static_lifetime, Canonical, DomainGoal, FnPointer, FnSig, InEnvironment, Interner, Solution,
|
||||||
|
Substitution, Ty, TyBuilder, TyExt, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{InEnvironment, InferOk, InferenceContext, TypeError};
|
|
||||||
|
|
||||||
pub(crate) type CoerceResult = Result<InferOk<(Vec<Adjustment>, Ty)>, TypeError>;
|
pub(crate) type CoerceResult = Result<InferOk<(Vec<Adjustment>, Ty)>, TypeError>;
|
||||||
|
|
||||||
/// Do not require any adjustments, i.e. coerce `x -> x`.
|
/// Do not require any adjustments, i.e. coerce `x -> x`.
|
||||||
|
@ -36,6 +37,7 @@ fn success(
|
||||||
) -> CoerceResult {
|
) -> CoerceResult {
|
||||||
Ok(InferOk { goals, value: (adj, target) })
|
Ok(InferOk { goals, value: (adj, target) })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(super) struct CoerceMany {
|
pub(super) struct CoerceMany {
|
||||||
expected_ty: Ty,
|
expected_ty: Ty,
|
||||||
|
@ -171,12 +173,8 @@ impl<'a> InferenceContext<'a> {
|
||||||
|
|
||||||
// Examine the supertype and consider auto-borrowing.
|
// Examine the supertype and consider auto-borrowing.
|
||||||
match to_ty.kind(&Interner) {
|
match to_ty.kind(&Interner) {
|
||||||
TyKind::Raw(mt, _) => {
|
TyKind::Raw(mt, _) => return self.coerce_ptr(from_ty, to_ty, *mt),
|
||||||
return self.coerce_ptr(from_ty, to_ty, *mt);
|
TyKind::Ref(mt, _, _) => return self.coerce_ref(from_ty, to_ty, *mt),
|
||||||
}
|
|
||||||
TyKind::Ref(mt, _, _) => {
|
|
||||||
return self.coerce_ref(from_ty, to_ty, *mt);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +335,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// FIXME: record overloarded deref adjustments
|
// FIXME: record overloaded deref adjustments
|
||||||
success(
|
success(
|
||||||
vec![Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(to_mt)), target: ty.clone() }],
|
vec![Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(to_mt)), target: ty.clone() }],
|
||||||
ty,
|
ty,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue