mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Use chalk_ir::Mutability
This commit is contained in:
parent
4a9eec4478
commit
7072f59fc6
10 changed files with 78 additions and 64 deletions
|
@ -8,6 +8,7 @@
|
|||
use std::{iter, sync::Arc};
|
||||
|
||||
use base_db::CrateId;
|
||||
use chalk_ir::Mutability;
|
||||
use hir_def::{
|
||||
adt::StructKind,
|
||||
builtin_type::BuiltinType,
|
||||
|
@ -157,7 +158,7 @@ impl Ty {
|
|||
}
|
||||
TypeRef::RawPtr(inner, mutability) => {
|
||||
let inner_ty = Ty::from_hir(ctx, inner);
|
||||
Ty::Raw(*mutability, Substs::single(inner_ty))
|
||||
Ty::Raw(lower_to_chalk_mutability(*mutability), Substs::single(inner_ty))
|
||||
}
|
||||
TypeRef::Array(inner) => {
|
||||
let inner_ty = Ty::from_hir(ctx, inner);
|
||||
|
@ -169,7 +170,7 @@ impl Ty {
|
|||
}
|
||||
TypeRef::Reference(inner, _, mutability) => {
|
||||
let inner_ty = Ty::from_hir(ctx, inner);
|
||||
Ty::Ref(*mutability, Substs::single(inner_ty))
|
||||
Ty::Ref(lower_to_chalk_mutability(*mutability), Substs::single(inner_ty))
|
||||
}
|
||||
TypeRef::Placeholder => Ty::Unknown,
|
||||
TypeRef::Fn(params, is_varargs) => {
|
||||
|
@ -1259,3 +1260,10 @@ pub(crate) fn return_type_impl_traits(
|
|||
Some(Arc::new(Binders::new(num_binders, return_type_impl_traits)))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn lower_to_chalk_mutability(m: hir_def::type_ref::Mutability) -> Mutability {
|
||||
match m {
|
||||
hir_def::type_ref::Mutability::Shared => Mutability::Not,
|
||||
hir_def::type_ref::Mutability::Mut => Mutability::Mut,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue