Skip to content

Commit a6ee8e9

Browse files
bors[bot]lnicolaVeykril
authored
Merge #7829 #7833
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 <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
3 parents f17f9f5 + 63e8bdb + 7072f59 commit a6ee8e9

File tree

12 files changed

+109
-104
lines changed

12 files changed

+109
-104
lines changed

Cargo.lock

Lines changed: 28 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir/src/code_model.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use hir_def::{
1414
per_ns::PerNs,
1515
resolver::{HasResolver, Resolver},
1616
src::HasSource as _,
17-
type_ref::{Mutability, TypeRef},
17+
type_ref::TypeRef,
1818
AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, ConstParamId,
1919
DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId,
2020
LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId,
@@ -32,8 +32,8 @@ use hir_ty::{
3232
method_resolution,
3333
traits::{FnTrait, Solution, SolutionVariables},
3434
AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, DebruijnIndex, GenericPredicate,
35-
InEnvironment, Obligation, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment,
36-
Ty, TyDefId, TyVariableKind,
35+
InEnvironment, Mutability, Obligation, ProjectionPredicate, ProjectionTy, Scalar, Substs,
36+
TraitEnvironment, Ty, TyDefId, TyVariableKind,
3737
};
3838
use rustc_hash::FxHashSet;
3939
use stdx::{format_to, impl_from};
@@ -836,7 +836,7 @@ pub enum Access {
836836
impl From<Mutability> for Access {
837837
fn from(mutability: Mutability) -> Access {
838838
match mutability {
839-
Mutability::Shared => Access::Shared,
839+
Mutability::Not => Access::Shared,
840840
Mutability::Mut => Access::Exclusive,
841841
}
842842
}
@@ -865,7 +865,10 @@ impl SelfParam {
865865
.params
866866
.first()
867867
.map(|param| match *param {
868-
TypeRef::Reference(.., mutability) => mutability.into(),
868+
TypeRef::Reference(.., mutability) => match mutability {
869+
hir_def::type_ref::Mutability::Shared => Access::Shared,
870+
hir_def::type_ref::Mutability::Mut => Access::Exclusive,
871+
},
869872
_ => Access::Owned,
870873
})
871874
.unwrap_or(Access::Owned)

crates/hir_ty/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ ena = "0.14.0"
1717
log = "0.4.8"
1818
rustc-hash = "1.1.0"
1919
scoped-tls = "1"
20-
chalk-solve = { version = "0.58", default-features = false }
21-
chalk-ir = "0.58"
22-
chalk-recursive = "0.58"
20+
chalk-solve = { version = "0.59", default-features = false }
21+
chalk-ir = "0.59"
22+
chalk-recursive = "0.59"
2323
la-arena = { version = "0.2.0", path = "../../lib/arena" }
2424

2525
stdx = { path = "../stdx", version = "0.0.0" }

crates/hir_ty/src/display.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
TraitRef, Ty,
99
};
1010
use arrayvec::ArrayVec;
11+
use chalk_ir::Mutability;
1112
use hir_def::{
1213
db::DefDatabase, find_path, generics::TypeParamProvenance, item_scope::ItemInNs, AdtId,
1314
AssocContainerId, HasModule, Lookup, ModuleId, TraitId,
@@ -291,9 +292,23 @@ impl HirDisplay for Ty {
291292
t.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target);
292293

293294
if matches!(self, Ty::Raw(..)) {
294-
write!(f, "*{}", m.as_keyword_for_ptr())?;
295+
write!(
296+
f,
297+
"*{}",
298+
match m {
299+
Mutability::Not => "const ",
300+
Mutability::Mut => "mut ",
301+
}
302+
)?;
295303
} else {
296-
write!(f, "&{}", m.as_keyword_for_ref())?;
304+
write!(
305+
f,
306+
"&{}",
307+
match m {
308+
Mutability::Not => "",
309+
Mutability::Mut => "mut ",
310+
}
311+
)?;
297312
}
298313

299314
let datas;

crates/hir_ty/src/infer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ use std::mem;
1818
use std::ops::Index;
1919
use std::sync::Arc;
2020

21+
use chalk_ir::Mutability;
2122
use hir_def::{
2223
body::Body,
2324
data::{ConstData, FunctionData, StaticData},
2425
expr::{ArithOp, BinaryOp, BindingAnnotation, ExprId, PatId},
2526
lang_item::LangItemTarget,
2627
path::{path, Path},
2728
resolver::{HasResolver, Resolver, TypeNs},
28-
type_ref::{Mutability, TypeRef},
29+
type_ref::TypeRef,
2930
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, FunctionId, Lookup, TraitId,
3031
TypeAliasId, VariantId,
3132
};
@@ -87,7 +88,7 @@ impl BindingMode {
8788
fn convert(annotation: BindingAnnotation) -> BindingMode {
8889
match annotation {
8990
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
90-
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),
91+
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Not),
9192
BindingAnnotation::RefMut => BindingMode::Ref(Mutability::Mut),
9293
}
9394
}

crates/hir_ty/src/infer/coerce.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//!
55
//! See: https://doc.rust-lang.org/nomicon/coercions.html
66
7-
use chalk_ir::TyVariableKind;
8-
use hir_def::{lang_item::LangItemTarget, type_ref::Mutability};
7+
use chalk_ir::{Mutability, TyVariableKind};
8+
use hir_def::lang_item::LangItemTarget;
99
use test_utils::mark;
1010

1111
use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty};
@@ -73,20 +73,20 @@ impl<'a> InferenceContext<'a> {
7373
match (&mut from_ty, to_ty) {
7474
// `*mut T` -> `*const T`
7575
// `&mut T` -> `&T`
76-
(Ty::Raw(m1, ..), Ty::Raw(m2 @ Mutability::Shared, ..))
77-
| (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Shared, ..)) => {
76+
(Ty::Raw(m1, ..), Ty::Raw(m2 @ Mutability::Not, ..))
77+
| (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Not, ..)) => {
7878
*m1 = *m2;
7979
}
8080
// `&T` -> `*const T`
8181
// `&mut T` -> `*mut T`/`*const T`
82-
(Ty::Ref(.., substs), &Ty::Raw(m2 @ Mutability::Shared, ..))
82+
(Ty::Ref(.., substs), &Ty::Raw(m2 @ Mutability::Not, ..))
8383
| (Ty::Ref(Mutability::Mut, substs), &Ty::Raw(m2, ..)) => {
8484
from_ty = Ty::Raw(m2, substs.clone());
8585
}
8686

8787
// Illegal mutability conversion
88-
(Ty::Raw(Mutability::Shared, ..), Ty::Raw(Mutability::Mut, ..))
89-
| (Ty::Ref(Mutability::Shared, ..), Ty::Ref(Mutability::Mut, ..)) => return false,
88+
(Ty::Raw(Mutability::Not, ..), Ty::Raw(Mutability::Mut, ..))
89+
| (Ty::Ref(Mutability::Not, ..), Ty::Ref(Mutability::Mut, ..)) => return false,
9090

9191
// `{function_type}` -> `fn()`
9292
(Ty::FnDef(..), Ty::Function { .. }) => match from_ty.callable_sig(self.db) {

0 commit comments

Comments
 (0)