mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
7829: Bump deps r=matklad a=lnicola Unfortunately, this brings a bunch of proc macros dep because `cargo-metadata` went full-in on `derive-builder`. I'm not sure what we can do here.. 7833: Use chalk_ir::Mutability r=Veykril a=Veykril Co-authored-by: Laurențiu Nicola <lnicola@dend.ro> Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
a6ee8e9e76
12 changed files with 109 additions and 104 deletions
65
Cargo.lock
generated
65
Cargo.lock
generated
|
@ -13,9 +13,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler"
|
name = "adler"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bedc89c5c7b5550ffb9372eb5c5ffc7f9f705cc3f4a128bd4669b9745f555093"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "always-assert"
|
name = "always-assert"
|
||||||
|
@ -158,9 +158,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-derive"
|
name = "chalk-derive"
|
||||||
version = "0.58.0"
|
version = "0.59.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e625b7c688272783140509a0de8f7aa9000217cb0982c9b10606a12b0b747ba8"
|
checksum = "4b9000fbcb67353dc8973ab9fd136277d321d85b79bd36b8756bb3ae0979a94a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -170,9 +170,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-ir"
|
name = "chalk-ir"
|
||||||
version = "0.58.0"
|
version = "0.59.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c220d870128959d7d56667060d556ffdebd490f32ee0fc9f4060a76c1193f206"
|
checksum = "b23528d61b3557c676eccf508fa0771a38453b379f0b780154eaa7f70afe8dfc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
|
@ -181,9 +181,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-recursive"
|
name = "chalk-recursive"
|
||||||
version = "0.58.0"
|
version = "0.59.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d8cd81a15aa936215378e695a8907b9f1af8626a27a32ee22e97a50984960da"
|
checksum = "a8bdd37afc666b771de8b4429fe014363d0e74aae5cc26f320f60a3eab34d744"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
|
@ -194,14 +194,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-solve"
|
name = "chalk-solve"
|
||||||
version = "0.58.0"
|
version = "0.59.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55571250dfe096a4c899be88c81418284c952ce1c8a06aa16afb5781b298e9c9"
|
checksum = "4182c42ca319cb71c89898ebc3d2671d1fa7d928123b171b66f1797a2000b9c8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
"ena",
|
"ena",
|
||||||
"itertools 0.9.0",
|
"itertools",
|
||||||
"petgraph",
|
"petgraph",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
@ -475,7 +475,7 @@ dependencies = [
|
||||||
"hir_def",
|
"hir_def",
|
||||||
"hir_expand",
|
"hir_expand",
|
||||||
"hir_ty",
|
"hir_ty",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
"profile",
|
"profile",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
@ -497,7 +497,7 @@ dependencies = [
|
||||||
"fst",
|
"fst",
|
||||||
"hir_expand",
|
"hir_expand",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"la-arena",
|
"la-arena",
|
||||||
"log",
|
"log",
|
||||||
"mbe",
|
"mbe",
|
||||||
|
@ -541,7 +541,7 @@ dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"hir_def",
|
"hir_def",
|
||||||
"hir_expand",
|
"hir_expand",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"la-arena",
|
"la-arena",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -579,7 +579,7 @@ dependencies = [
|
||||||
"ide_db",
|
"ide_db",
|
||||||
"ide_ssr",
|
"ide_ssr",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
"oorandom",
|
"oorandom",
|
||||||
"profile",
|
"profile",
|
||||||
|
@ -601,7 +601,7 @@ dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"hir",
|
"hir",
|
||||||
"ide_db",
|
"ide_db",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"profile",
|
"profile",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"stdx",
|
"stdx",
|
||||||
|
@ -619,7 +619,7 @@ dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"hir",
|
"hir",
|
||||||
"ide_db",
|
"ide_db",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
"profile",
|
"profile",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
@ -638,7 +638,7 @@ dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"fst",
|
"fst",
|
||||||
"hir",
|
"hir",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"profile",
|
"profile",
|
||||||
|
@ -657,7 +657,7 @@ dependencies = [
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"hir",
|
"hir",
|
||||||
"ide_db",
|
"ide_db",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"syntax",
|
"syntax",
|
||||||
"test_utils",
|
"test_utils",
|
||||||
|
@ -714,15 +714,6 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
@ -1206,7 +1197,7 @@ dependencies = [
|
||||||
"base_db",
|
"base_db",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
"cfg",
|
"cfg",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"la-arena",
|
"la-arena",
|
||||||
"log",
|
"log",
|
||||||
"paths",
|
"paths",
|
||||||
|
@ -1338,7 +1329,7 @@ dependencies = [
|
||||||
"ide",
|
"ide",
|
||||||
"ide_db",
|
"ide_db",
|
||||||
"ide_ssr",
|
"ide_ssr",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"jod-thread",
|
"jod-thread",
|
||||||
"log",
|
"log",
|
||||||
|
@ -1490,9 +1481,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.62"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486"
|
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
|
@ -1593,7 +1584,7 @@ dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools 0.10.0",
|
"itertools",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parser",
|
"parser",
|
||||||
"profile",
|
"profile",
|
||||||
|
@ -1923,18 +1914,18 @@ checksum = "06069a848f95fceae3e5e03c0ddc8cb78452b56654ee0c8e68f938cf790fb9e3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xshell"
|
name = "xshell"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed373ede30cea03e8c0af22f48ee1ba80efbf06fec8b4746977e6ee703878de0"
|
checksum = "6f18102278453c8f70ea5c514ac78cb4c73a0ef72a8273d17094b52f9584c0c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"xshell-macros",
|
"xshell-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xshell-macros"
|
name = "xshell-macros"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f6af9f8119104697b0105989a73c578ce33f922d9d6f3dae0e8ae3d538db321"
|
checksum = "6093c460064572007f885facc70bb0ca5e40a83ea7ff8b16c1abbee56fd2e767"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xtask"
|
name = "xtask"
|
||||||
|
|
|
@ -14,7 +14,7 @@ use hir_def::{
|
||||||
per_ns::PerNs,
|
per_ns::PerNs,
|
||||||
resolver::{HasResolver, Resolver},
|
resolver::{HasResolver, Resolver},
|
||||||
src::HasSource as _,
|
src::HasSource as _,
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::TypeRef,
|
||||||
AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, ConstParamId,
|
AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, ConstParamId,
|
||||||
DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId,
|
DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId,
|
||||||
LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId,
|
LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId,
|
||||||
|
@ -32,8 +32,8 @@ use hir_ty::{
|
||||||
method_resolution,
|
method_resolution,
|
||||||
traits::{FnTrait, Solution, SolutionVariables},
|
traits::{FnTrait, Solution, SolutionVariables},
|
||||||
AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, DebruijnIndex, GenericPredicate,
|
AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, DebruijnIndex, GenericPredicate,
|
||||||
InEnvironment, Obligation, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment,
|
InEnvironment, Mutability, Obligation, ProjectionPredicate, ProjectionTy, Scalar, Substs,
|
||||||
Ty, TyDefId, TyVariableKind,
|
TraitEnvironment, Ty, TyDefId, TyVariableKind,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use stdx::{format_to, impl_from};
|
use stdx::{format_to, impl_from};
|
||||||
|
@ -836,7 +836,7 @@ pub enum Access {
|
||||||
impl From<Mutability> for Access {
|
impl From<Mutability> for Access {
|
||||||
fn from(mutability: Mutability) -> Access {
|
fn from(mutability: Mutability) -> Access {
|
||||||
match mutability {
|
match mutability {
|
||||||
Mutability::Shared => Access::Shared,
|
Mutability::Not => Access::Shared,
|
||||||
Mutability::Mut => Access::Exclusive,
|
Mutability::Mut => Access::Exclusive,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,10 @@ impl SelfParam {
|
||||||
.params
|
.params
|
||||||
.first()
|
.first()
|
||||||
.map(|param| match *param {
|
.map(|param| match *param {
|
||||||
TypeRef::Reference(.., mutability) => mutability.into(),
|
TypeRef::Reference(.., mutability) => match mutability {
|
||||||
|
hir_def::type_ref::Mutability::Shared => Access::Shared,
|
||||||
|
hir_def::type_ref::Mutability::Mut => Access::Exclusive,
|
||||||
|
},
|
||||||
_ => Access::Owned,
|
_ => Access::Owned,
|
||||||
})
|
})
|
||||||
.unwrap_or(Access::Owned)
|
.unwrap_or(Access::Owned)
|
||||||
|
|
|
@ -17,9 +17,9 @@ ena = "0.14.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
scoped-tls = "1"
|
scoped-tls = "1"
|
||||||
chalk-solve = { version = "0.58", default-features = false }
|
chalk-solve = { version = "0.59", default-features = false }
|
||||||
chalk-ir = "0.58"
|
chalk-ir = "0.59"
|
||||||
chalk-recursive = "0.58"
|
chalk-recursive = "0.59"
|
||||||
la-arena = { version = "0.2.0", path = "../../lib/arena" }
|
la-arena = { version = "0.2.0", path = "../../lib/arena" }
|
||||||
|
|
||||||
stdx = { path = "../stdx", version = "0.0.0" }
|
stdx = { path = "../stdx", version = "0.0.0" }
|
||||||
|
|
|
@ -8,6 +8,7 @@ use crate::{
|
||||||
TraitRef, Ty,
|
TraitRef, Ty,
|
||||||
};
|
};
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
db::DefDatabase, find_path, generics::TypeParamProvenance, item_scope::ItemInNs, AdtId,
|
db::DefDatabase, find_path, generics::TypeParamProvenance, item_scope::ItemInNs, AdtId,
|
||||||
AssocContainerId, HasModule, Lookup, ModuleId, TraitId,
|
AssocContainerId, HasModule, Lookup, ModuleId, TraitId,
|
||||||
|
@ -291,9 +292,23 @@ impl HirDisplay for Ty {
|
||||||
t.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target);
|
t.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target);
|
||||||
|
|
||||||
if matches!(self, Ty::Raw(..)) {
|
if matches!(self, Ty::Raw(..)) {
|
||||||
write!(f, "*{}", m.as_keyword_for_ptr())?;
|
write!(
|
||||||
|
f,
|
||||||
|
"*{}",
|
||||||
|
match m {
|
||||||
|
Mutability::Not => "const ",
|
||||||
|
Mutability::Mut => "mut ",
|
||||||
|
}
|
||||||
|
)?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "&{}", m.as_keyword_for_ref())?;
|
write!(
|
||||||
|
f,
|
||||||
|
"&{}",
|
||||||
|
match m {
|
||||||
|
Mutability::Not => "",
|
||||||
|
Mutability::Mut => "mut ",
|
||||||
|
}
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let datas;
|
let datas;
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::mem;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
body::Body,
|
body::Body,
|
||||||
data::{ConstData, FunctionData, StaticData},
|
data::{ConstData, FunctionData, StaticData},
|
||||||
|
@ -25,7 +26,7 @@ use hir_def::{
|
||||||
lang_item::LangItemTarget,
|
lang_item::LangItemTarget,
|
||||||
path::{path, Path},
|
path::{path, Path},
|
||||||
resolver::{HasResolver, Resolver, TypeNs},
|
resolver::{HasResolver, Resolver, TypeNs},
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::TypeRef,
|
||||||
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, FunctionId, Lookup, TraitId,
|
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, FunctionId, Lookup, TraitId,
|
||||||
TypeAliasId, VariantId,
|
TypeAliasId, VariantId,
|
||||||
};
|
};
|
||||||
|
@ -87,7 +88,7 @@ impl BindingMode {
|
||||||
fn convert(annotation: BindingAnnotation) -> BindingMode {
|
fn convert(annotation: BindingAnnotation) -> BindingMode {
|
||||||
match annotation {
|
match annotation {
|
||||||
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
|
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
|
||||||
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),
|
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Not),
|
||||||
BindingAnnotation::RefMut => BindingMode::Ref(Mutability::Mut),
|
BindingAnnotation::RefMut => BindingMode::Ref(Mutability::Mut),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
//!
|
//!
|
||||||
//! See: https://doc.rust-lang.org/nomicon/coercions.html
|
//! See: https://doc.rust-lang.org/nomicon/coercions.html
|
||||||
|
|
||||||
use chalk_ir::TyVariableKind;
|
use chalk_ir::{Mutability, TyVariableKind};
|
||||||
use hir_def::{lang_item::LangItemTarget, type_ref::Mutability};
|
use hir_def::lang_item::LangItemTarget;
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty};
|
use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty};
|
||||||
|
@ -73,20 +73,20 @@ impl<'a> InferenceContext<'a> {
|
||||||
match (&mut from_ty, to_ty) {
|
match (&mut from_ty, to_ty) {
|
||||||
// `*mut T` -> `*const T`
|
// `*mut T` -> `*const T`
|
||||||
// `&mut T` -> `&T`
|
// `&mut T` -> `&T`
|
||||||
(Ty::Raw(m1, ..), Ty::Raw(m2 @ Mutability::Shared, ..))
|
(Ty::Raw(m1, ..), Ty::Raw(m2 @ Mutability::Not, ..))
|
||||||
| (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Shared, ..)) => {
|
| (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Not, ..)) => {
|
||||||
*m1 = *m2;
|
*m1 = *m2;
|
||||||
}
|
}
|
||||||
// `&T` -> `*const T`
|
// `&T` -> `*const T`
|
||||||
// `&mut T` -> `*mut T`/`*const T`
|
// `&mut T` -> `*mut T`/`*const T`
|
||||||
(Ty::Ref(.., substs), &Ty::Raw(m2 @ Mutability::Shared, ..))
|
(Ty::Ref(.., substs), &Ty::Raw(m2 @ Mutability::Not, ..))
|
||||||
| (Ty::Ref(Mutability::Mut, substs), &Ty::Raw(m2, ..)) => {
|
| (Ty::Ref(Mutability::Mut, substs), &Ty::Raw(m2, ..)) => {
|
||||||
from_ty = Ty::Raw(m2, substs.clone());
|
from_ty = Ty::Raw(m2, substs.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Illegal mutability conversion
|
// Illegal mutability conversion
|
||||||
(Ty::Raw(Mutability::Shared, ..), Ty::Raw(Mutability::Mut, ..))
|
(Ty::Raw(Mutability::Not, ..), Ty::Raw(Mutability::Mut, ..))
|
||||||
| (Ty::Ref(Mutability::Shared, ..), Ty::Ref(Mutability::Mut, ..)) => return false,
|
| (Ty::Ref(Mutability::Not, ..), Ty::Ref(Mutability::Mut, ..)) => return false,
|
||||||
|
|
||||||
// `{function_type}` -> `fn()`
|
// `{function_type}` -> `fn()`
|
||||||
(Ty::FnDef(..), Ty::Function { .. }) => match from_ty.callable_sig(self.db) {
|
(Ty::FnDef(..), Ty::Function { .. }) => match from_ty.callable_sig(self.db) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use std::iter::{repeat, repeat_with};
|
use std::iter::{repeat, repeat_with};
|
||||||
use std::{mem, sync::Arc};
|
use std::{mem, sync::Arc};
|
||||||
|
|
||||||
use chalk_ir::TyVariableKind;
|
use chalk_ir::{Mutability, TyVariableKind};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
||||||
path::{GenericArg, GenericArgs},
|
path::{GenericArg, GenericArgs},
|
||||||
|
@ -15,12 +15,14 @@ use syntax::ast::RangeOp;
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
autoderef, method_resolution, op,
|
autoderef,
|
||||||
|
lower::lower_to_chalk_mutability,
|
||||||
|
method_resolution, op,
|
||||||
primitive::{self, UintTy},
|
primitive::{self, UintTy},
|
||||||
traits::{FnTrait, InEnvironment},
|
traits::{FnTrait, InEnvironment},
|
||||||
utils::{generics, variant_data, Generics},
|
utils::{generics, variant_data, Generics},
|
||||||
Binders, CallableDefId, FnPointer, FnSig, Mutability, Obligation, OpaqueTyId, Rawness, Scalar,
|
Binders, CallableDefId, FnPointer, FnSig, Obligation, OpaqueTyId, Rawness, Scalar, Substs,
|
||||||
Substs, TraitRef, Ty,
|
TraitRef, Ty,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -462,10 +464,11 @@ impl<'a> InferenceContext<'a> {
|
||||||
cast_ty
|
cast_ty
|
||||||
}
|
}
|
||||||
Expr::Ref { expr, rawness, mutability } => {
|
Expr::Ref { expr, rawness, mutability } => {
|
||||||
|
let mutability = lower_to_chalk_mutability(*mutability);
|
||||||
let expectation = if let Some((exp_inner, exp_rawness, exp_mutability)) =
|
let expectation = if let Some((exp_inner, exp_rawness, exp_mutability)) =
|
||||||
&expected.ty.as_reference_or_ptr()
|
&expected.ty.as_reference_or_ptr()
|
||||||
{
|
{
|
||||||
if *exp_mutability == Mutability::Mut && *mutability == Mutability::Shared {
|
if *exp_mutability == Mutability::Mut && mutability == Mutability::Not {
|
||||||
// FIXME: throw type error - expected mut reference but found shared ref,
|
// FIXME: throw type error - expected mut reference but found shared ref,
|
||||||
// which cannot be coerced
|
// which cannot be coerced
|
||||||
}
|
}
|
||||||
|
@ -479,8 +482,8 @@ impl<'a> InferenceContext<'a> {
|
||||||
};
|
};
|
||||||
let inner_ty = self.infer_expr_inner(*expr, &expectation);
|
let inner_ty = self.infer_expr_inner(*expr, &expectation);
|
||||||
match rawness {
|
match rawness {
|
||||||
Rawness::RawPtr => Ty::Raw(*mutability, Substs::single(inner_ty)),
|
Rawness::RawPtr => Ty::Raw(mutability, Substs::single(inner_ty)),
|
||||||
Rawness::Ref => Ty::Ref(*mutability, Substs::single(inner_ty)),
|
Rawness::Ref => Ty::Ref(mutability, Substs::single(inner_ty)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::Box { expr } => {
|
Expr::Box { expr } => {
|
||||||
|
@ -684,11 +687,11 @@ impl<'a> InferenceContext<'a> {
|
||||||
}
|
}
|
||||||
Expr::Literal(lit) => match lit {
|
Expr::Literal(lit) => match lit {
|
||||||
Literal::Bool(..) => Ty::Scalar(Scalar::Bool),
|
Literal::Bool(..) => Ty::Scalar(Scalar::Bool),
|
||||||
Literal::String(..) => Ty::Ref(Mutability::Shared, Substs::single(Ty::Str)),
|
Literal::String(..) => Ty::Ref(Mutability::Not, Substs::single(Ty::Str)),
|
||||||
Literal::ByteString(..) => {
|
Literal::ByteString(..) => {
|
||||||
let byte_type = Ty::Scalar(Scalar::Uint(UintTy::U8));
|
let byte_type = Ty::Scalar(Scalar::Uint(UintTy::U8));
|
||||||
let array_type = Ty::Array(Substs::single(byte_type));
|
let array_type = Ty::Array(Substs::single(byte_type));
|
||||||
Ty::Ref(Mutability::Shared, Substs::single(array_type))
|
Ty::Ref(Mutability::Not, Substs::single(array_type))
|
||||||
}
|
}
|
||||||
Literal::Char(..) => Ty::Scalar(Scalar::Char),
|
Literal::Char(..) => Ty::Scalar(Scalar::Char),
|
||||||
Literal::Int(_v, ty) => match ty {
|
Literal::Int(_v, ty) => match ty {
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{BindingAnnotation, Expr, Literal, Pat, PatId, RecordFieldPat},
|
expr::{BindingAnnotation, Expr, Literal, Pat, PatId, RecordFieldPat},
|
||||||
path::Path,
|
path::Path,
|
||||||
type_ref::Mutability,
|
|
||||||
FieldId,
|
FieldId,
|
||||||
};
|
};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use super::{BindingMode, Expectation, InferenceContext};
|
use super::{BindingMode, Expectation, InferenceContext};
|
||||||
use crate::{utils::variant_data, Substs, Ty};
|
use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty};
|
||||||
|
|
||||||
impl<'a> InferenceContext<'a> {
|
impl<'a> InferenceContext<'a> {
|
||||||
fn infer_tuple_struct_pat(
|
fn infer_tuple_struct_pat(
|
||||||
|
@ -103,7 +103,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
expected = inner;
|
expected = inner;
|
||||||
default_bm = match default_bm {
|
default_bm = match default_bm {
|
||||||
BindingMode::Move => BindingMode::Ref(mutability),
|
BindingMode::Move => BindingMode::Ref(mutability),
|
||||||
BindingMode::Ref(Mutability::Shared) => BindingMode::Ref(Mutability::Shared),
|
BindingMode::Ref(Mutability::Not) => BindingMode::Ref(Mutability::Not),
|
||||||
BindingMode::Ref(Mutability::Mut) => BindingMode::Ref(mutability),
|
BindingMode::Ref(Mutability::Mut) => BindingMode::Ref(mutability),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,9 +152,10 @@ impl<'a> InferenceContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pat::Ref { pat, mutability } => {
|
Pat::Ref { pat, mutability } => {
|
||||||
|
let mutability = lower_to_chalk_mutability(*mutability);
|
||||||
let expectation = match expected.as_reference() {
|
let expectation = match expected.as_reference() {
|
||||||
Some((inner_ty, exp_mut)) => {
|
Some((inner_ty, exp_mut)) => {
|
||||||
if *mutability != exp_mut {
|
if mutability != exp_mut {
|
||||||
// FIXME: emit type error?
|
// FIXME: emit type error?
|
||||||
}
|
}
|
||||||
inner_ty
|
inner_ty
|
||||||
|
@ -162,7 +163,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
_ => &Ty::Unknown,
|
_ => &Ty::Unknown,
|
||||||
};
|
};
|
||||||
let subty = self.infer_pat(*pat, expectation, default_bm);
|
let subty = self.infer_pat(*pat, expectation, default_bm);
|
||||||
Ty::Ref(*mutability, Substs::single(subty))
|
Ty::Ref(mutability, Substs::single(subty))
|
||||||
}
|
}
|
||||||
Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat(
|
Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat(
|
||||||
p.as_ref(),
|
p.as_ref(),
|
||||||
|
|
|
@ -27,11 +27,9 @@ use std::{iter, mem, ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use base_db::salsa;
|
use base_db::salsa;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType, expr::ExprId, type_ref::Rawness, AdtId, AssocContainerId,
|
||||||
expr::ExprId,
|
DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, Lookup, TraitId,
|
||||||
type_ref::{Mutability, Rawness},
|
TypeAliasId, TypeParamId,
|
||||||
AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId,
|
|
||||||
Lookup, TraitId, TypeAliasId, TypeParamId,
|
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ pub use lower::{
|
||||||
};
|
};
|
||||||
pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
|
pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
|
||||||
|
|
||||||
pub use chalk_ir::{BoundVar, DebruijnIndex, Scalar, TyVariableKind};
|
pub use chalk_ir::{BoundVar, DebruijnIndex, Mutability, Scalar, TyVariableKind};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub enum Lifetime {
|
pub enum Lifetime {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
use std::{iter, sync::Arc};
|
use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
adt::StructKind,
|
adt::StructKind,
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
|
@ -157,7 +158,7 @@ impl Ty {
|
||||||
}
|
}
|
||||||
TypeRef::RawPtr(inner, mutability) => {
|
TypeRef::RawPtr(inner, mutability) => {
|
||||||
let inner_ty = Ty::from_hir(ctx, inner);
|
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) => {
|
TypeRef::Array(inner) => {
|
||||||
let inner_ty = Ty::from_hir(ctx, inner);
|
let inner_ty = Ty::from_hir(ctx, inner);
|
||||||
|
@ -169,7 +170,7 @@ impl Ty {
|
||||||
}
|
}
|
||||||
TypeRef::Reference(inner, _, mutability) => {
|
TypeRef::Reference(inner, _, mutability) => {
|
||||||
let inner_ty = Ty::from_hir(ctx, inner);
|
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::Placeholder => Ty::Unknown,
|
||||||
TypeRef::Fn(params, is_varargs) => {
|
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)))
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@ use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
lang_item::LangItemTarget, type_ref::Mutability, AdtId, AssocContainerId, AssocItemId,
|
lang_item::LangItemTarget, AdtId, AssocContainerId, AssocItemId, FunctionId, GenericDefId,
|
||||||
FunctionId, GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId, TypeAliasId,
|
HasModule, ImplId, Lookup, ModuleId, TraitId, TypeAliasId,
|
||||||
};
|
};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
@ -251,7 +252,7 @@ impl Ty {
|
||||||
}
|
}
|
||||||
Ty::Str => lang_item_crate!("str_alloc", "str"),
|
Ty::Str => lang_item_crate!("str_alloc", "str"),
|
||||||
Ty::Slice(_) => lang_item_crate!("slice_alloc", "slice"),
|
Ty::Slice(_) => lang_item_crate!("slice_alloc", "slice"),
|
||||||
Ty::Raw(Mutability::Shared, _) => lang_item_crate!("const_ptr"),
|
Ty::Raw(Mutability::Not, _) => lang_item_crate!("const_ptr"),
|
||||||
Ty::Raw(Mutability::Mut, _) => lang_item_crate!("mut_ptr"),
|
Ty::Raw(Mutability::Mut, _) => lang_item_crate!("mut_ptr"),
|
||||||
Ty::Dyn(_) => {
|
Ty::Dyn(_) => {
|
||||||
return self.dyn_trait().and_then(|trait_| {
|
return self.dyn_trait().and_then(|trait_| {
|
||||||
|
@ -429,7 +430,7 @@ fn iterate_method_candidates_with_autoref(
|
||||||
}
|
}
|
||||||
let refed = Canonical {
|
let refed = Canonical {
|
||||||
kinds: deref_chain[0].kinds.clone(),
|
kinds: deref_chain[0].kinds.clone(),
|
||||||
value: Ty::Ref(Mutability::Shared, Substs::single(deref_chain[0].value.clone())),
|
value: Ty::Ref(Mutability::Not, Substs::single(deref_chain[0].value.clone())),
|
||||||
};
|
};
|
||||||
if iterate_method_candidates_by_receiver(
|
if iterate_method_candidates_by_receiver(
|
||||||
&refed,
|
&refed,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use chalk_ir::{
|
||||||
use chalk_solve::rust_ir;
|
use chalk_solve::rust_ir;
|
||||||
|
|
||||||
use base_db::salsa::InternKey;
|
use base_db::salsa::InternKey;
|
||||||
use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId};
|
use hir_def::{AssocContainerId, GenericDefId, Lookup, TypeAliasId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
|
@ -65,7 +65,7 @@ impl ToChalk for Ty {
|
||||||
}
|
}
|
||||||
Ty::Raw(mutability, substs) => {
|
Ty::Raw(mutability, substs) => {
|
||||||
let ty = substs[0].clone().to_chalk(db);
|
let ty = substs[0].clone().to_chalk(db);
|
||||||
chalk_ir::TyKind::Raw(mutability.to_chalk(db), ty).intern(&Interner)
|
chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner)
|
||||||
}
|
}
|
||||||
Ty::Slice(substs) => {
|
Ty::Slice(substs) => {
|
||||||
chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner)
|
chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner)
|
||||||
|
@ -198,11 +198,11 @@ impl ToChalk for Ty {
|
||||||
Ty::Tuple(cardinality, from_chalk(db, subst))
|
Ty::Tuple(cardinality, from_chalk(db, subst))
|
||||||
}
|
}
|
||||||
chalk_ir::TyKind::Raw(mutability, ty) => {
|
chalk_ir::TyKind::Raw(mutability, ty) => {
|
||||||
Ty::Raw(from_chalk(db, mutability), Substs::single(from_chalk(db, ty)))
|
Ty::Raw(mutability, Substs::single(from_chalk(db, ty)))
|
||||||
}
|
}
|
||||||
chalk_ir::TyKind::Slice(ty) => Ty::Slice(Substs::single(from_chalk(db, ty))),
|
chalk_ir::TyKind::Slice(ty) => Ty::Slice(Substs::single(from_chalk(db, ty))),
|
||||||
chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => {
|
chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => {
|
||||||
Ty::Ref(from_chalk(db, mutability), Substs::single(from_chalk(db, ty)))
|
Ty::Ref(mutability, Substs::single(from_chalk(db, ty)))
|
||||||
}
|
}
|
||||||
chalk_ir::TyKind::Str => Ty::Str,
|
chalk_ir::TyKind::Str => Ty::Str,
|
||||||
chalk_ir::TyKind::Never => Ty::Never,
|
chalk_ir::TyKind::Never => Ty::Never,
|
||||||
|
@ -230,12 +230,12 @@ impl ToChalk for Ty {
|
||||||
/// fake lifetime here, because Chalks built-in logic may expect it to be there.
|
/// fake lifetime here, because Chalks built-in logic may expect it to be there.
|
||||||
fn ref_to_chalk(
|
fn ref_to_chalk(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
mutability: Mutability,
|
mutability: chalk_ir::Mutability,
|
||||||
subst: Substs,
|
subst: Substs,
|
||||||
) -> chalk_ir::Ty<Interner> {
|
) -> chalk_ir::Ty<Interner> {
|
||||||
let arg = subst[0].clone().to_chalk(db);
|
let arg = subst[0].clone().to_chalk(db);
|
||||||
let lifetime = LifetimeData::Static.intern(&Interner);
|
let lifetime = LifetimeData::Static.intern(&Interner);
|
||||||
chalk_ir::TyKind::Ref(mutability.to_chalk(db), lifetime, arg).intern(&Interner)
|
chalk_ir::TyKind::Ref(mutability, lifetime, arg).intern(&Interner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// We currently don't model constants, but Chalk does. So, we have to insert a
|
/// We currently don't model constants, but Chalk does. So, we have to insert a
|
||||||
|
@ -313,22 +313,6 @@ impl ToChalk for OpaqueTyId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToChalk for Mutability {
|
|
||||||
type Chalk = chalk_ir::Mutability;
|
|
||||||
fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk {
|
|
||||||
match self {
|
|
||||||
Mutability::Shared => chalk_ir::Mutability::Not,
|
|
||||||
Mutability::Mut => chalk_ir::Mutability::Mut,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn from_chalk(_db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
|
|
||||||
match chalk {
|
|
||||||
chalk_ir::Mutability::Mut => Mutability::Mut,
|
|
||||||
chalk_ir::Mutability::Not => Mutability::Shared,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToChalk for hir_def::ImplId {
|
impl ToChalk for hir_def::ImplId {
|
||||||
type Chalk = ImplId;
|
type Chalk = ImplId;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue