Skip to content

Commit c0bf3af

Browse files
authored
Rollup merge of rust-lang#67355 - Centril:merge-mut, r=oli-obk
Merge `ast::Mutability` and `mir::Mutability` r? @oli-obk
2 parents 1113eb5 + 6d7c6d7 commit c0bf3af

File tree

91 files changed

+294
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+294
-326
lines changed

src/librustc/hir/lowering.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ impl<'a> LoweringContext<'a> {
22532253
let is_mutable_pat = match arg.pat.kind {
22542254
PatKind::Ident(BindingMode::ByValue(mt), _, _) |
22552255
PatKind::Ident(BindingMode::ByRef(mt), _, _) =>
2256-
mt == Mutability::Mutable,
2256+
mt == Mutability::Mut,
22572257
_ => false,
22582258
};
22592259

@@ -2264,7 +2264,7 @@ impl<'a> LoweringContext<'a> {
22642264
// the case where we have a mutable pattern to a reference as that would
22652265
// no longer be an `ImplicitSelf`.
22662266
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() &&
2267-
mt.mutbl == ast::Mutability::Mutable =>
2267+
mt.mutbl == ast::Mutability::Mut =>
22682268
hir::ImplicitSelfKind::MutRef,
22692269
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() =>
22702270
hir::ImplicitSelfKind::ImmRef,
@@ -3068,10 +3068,10 @@ impl<'a> LoweringContext<'a> {
30683068

30693069
fn lower_binding_mode(&mut self, b: &BindingMode) -> hir::BindingAnnotation {
30703070
match *b {
3071-
BindingMode::ByValue(Mutability::Immutable) => hir::BindingAnnotation::Unannotated,
3072-
BindingMode::ByRef(Mutability::Immutable) => hir::BindingAnnotation::Ref,
3073-
BindingMode::ByValue(Mutability::Mutable) => hir::BindingAnnotation::Mutable,
3074-
BindingMode::ByRef(Mutability::Mutable) => hir::BindingAnnotation::RefMut,
3071+
BindingMode::ByValue(Mutability::Not) => hir::BindingAnnotation::Unannotated,
3072+
BindingMode::ByRef(Mutability::Not) => hir::BindingAnnotation::Ref,
3073+
BindingMode::ByValue(Mutability::Mut) => hir::BindingAnnotation::Mutable,
3074+
BindingMode::ByRef(Mutability::Mut) => hir::BindingAnnotation::RefMut,
30753075
}
30763076
}
30773077

src/librustc/hir/lowering/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ impl LoweringContext<'_> {
13401340
fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr {
13411341
self.expr(
13421342
span,
1343-
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mutable, e),
1343+
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, e),
13441344
ThinVec::new(),
13451345
)
13461346
}

src/librustc/hir/pat_util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ impl hir::Pat {
169169
self.each_binding(|annotation, _, _, _| {
170170
match annotation {
171171
hir::BindingAnnotation::Ref => match result {
172-
None | Some(hir::Mutability::Immutable) =>
173-
result = Some(hir::Mutability::Immutable),
172+
None | Some(hir::Mutability::Not) => result = Some(hir::Mutability::Not),
174173
_ => {}
175174
}
176-
hir::BindingAnnotation::RefMut => result = Some(hir::Mutability::Mutable),
175+
hir::BindingAnnotation::RefMut => result = Some(hir::Mutability::Mut),
177176
_ => {}
178177
}
179178
});

src/librustc/hir/print.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'a> State<'a> {
386386
}
387387
hir::ForeignItemKind::Static(ref t, m) => {
388388
self.head(visibility_qualified(&item.vis, "static"));
389-
if m == hir::Mutability::Mutable {
389+
if m == hir::Mutability::Mut {
390390
self.word_space("mut");
391391
}
392392
self.print_ident(item.ident);
@@ -502,7 +502,7 @@ impl<'a> State<'a> {
502502
}
503503
hir::ItemKind::Static(ref ty, m, expr) => {
504504
self.head(visibility_qualified(&item.vis, "static"));
505-
if m == hir::Mutability::Mutable {
505+
if m == hir::Mutability::Mut {
506506
self.word_space("mut");
507507
}
508508
self.print_ident(item.ident);
@@ -1632,11 +1632,11 @@ impl<'a> State<'a> {
16321632
match binding_mode {
16331633
hir::BindingAnnotation::Ref => {
16341634
self.word_nbsp("ref");
1635-
self.print_mutability(hir::Mutability::Immutable, false);
1635+
self.print_mutability(hir::Mutability::Not, false);
16361636
}
16371637
hir::BindingAnnotation::RefMut => {
16381638
self.word_nbsp("ref");
1639-
self.print_mutability(hir::Mutability::Mutable, false);
1639+
self.print_mutability(hir::Mutability::Mut, false);
16401640
}
16411641
hir::BindingAnnotation::Unannotated => {}
16421642
hir::BindingAnnotation::Mutable => {
@@ -2065,8 +2065,8 @@ impl<'a> State<'a> {
20652065

20662066
pub fn print_mutability(&mut self, mutbl: hir::Mutability, print_const: bool) {
20672067
match mutbl {
2068-
hir::Mutability::Mutable => self.word_nbsp("mut"),
2069-
hir::Mutability::Immutable => if print_const { self.word_nbsp("const") },
2068+
hir::Mutability::Mut => self.word_nbsp("mut"),
2069+
hir::Mutability::Not => if print_const { self.word_nbsp("const") },
20702070
}
20712071
}
20722072

src/librustc/lint/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind {
132132
}
133133
}
134134
}
135-
TyKind::Rptr(_, MutTy { ty: inner_ty, mutbl: Mutability::Immutable }) => {
135+
TyKind::Rptr(_, MutTy { ty: inner_ty, mutbl: Mutability::Not }) => {
136136
if let Some(impl_did) = cx.tcx.impl_of_method(ty.hir_id.owner_def_id()) {
137137
if cx.tcx.impl_trait_ref(impl_did).is_some() {
138138
return;

src/librustc/mir/interpret/allocation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<Tag> Allocation<Tag> {
106106
undef_mask: UndefMask::new(size, true),
107107
size,
108108
align,
109-
mutability: Mutability::Immutable,
109+
mutability: Mutability::Not,
110110
extra: (),
111111
}
112112
}
@@ -123,7 +123,7 @@ impl<Tag> Allocation<Tag> {
123123
undef_mask: UndefMask::new(size, false),
124124
size,
125125
align,
126-
mutability: Mutability::Mutable,
126+
mutability: Mutability::Mut,
127127
extra: (),
128128
}
129129
}

src/librustc/mir/mod.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::ops::Index;
3434
use std::slice;
3535
use std::{iter, mem, option, u32};
3636
use syntax::ast::Name;
37+
pub use syntax::ast::Mutability;
3738
use syntax::symbol::Symbol;
3839
use syntax_pos::{Span, DUMMY_SP};
3940

@@ -396,22 +397,7 @@ pub struct SourceInfo {
396397
}
397398

398399
///////////////////////////////////////////////////////////////////////////
399-
// Mutability and borrow kinds
400-
401-
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]
402-
pub enum Mutability {
403-
Mut,
404-
Not,
405-
}
406-
407-
impl From<Mutability> for hir::Mutability {
408-
fn from(m: Mutability) -> Self {
409-
match m {
410-
Mutability::Mut => hir::Mutability::Mutable,
411-
Mutability::Not => hir::Mutability::Immutable,
412-
}
413-
}
414-
}
400+
// Borrow kinds
415401

416402
#[derive(
417403
Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, HashStable,
@@ -2886,7 +2872,6 @@ pub enum ClosureOutlivesSubject<'tcx> {
28862872
CloneTypeFoldableAndLiftImpls! {
28872873
BlockTailInfo,
28882874
MirPhase,
2889-
Mutability,
28902875
SourceInfo,
28912876
FakeReadCause,
28922877
RetagKind,

src/librustc/mir/tcx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,17 @@ impl<'tcx> BinOp {
279279
impl BorrowKind {
280280
pub fn to_mutbl_lossy(self) -> hir::Mutability {
281281
match self {
282-
BorrowKind::Mut { .. } => hir::Mutability::Mutable,
283-
BorrowKind::Shared => hir::Mutability::Immutable,
282+
BorrowKind::Mut { .. } => hir::Mutability::Mut,
283+
BorrowKind::Shared => hir::Mutability::Not,
284284

285285
// We have no type corresponding to a unique imm borrow, so
286286
// use `&mut`. It gives all the capabilities of an `&uniq`
287287
// and hence is a safe "over approximation".
288-
BorrowKind::Unique => hir::Mutability::Mutable,
288+
BorrowKind::Unique => hir::Mutability::Mut,
289289

290290
// We have no type corresponding to a shallow borrow, so use
291291
// `&` as an approximation.
292-
BorrowKind::Shallow => hir::Mutability::Immutable,
292+
BorrowKind::Shallow => hir::Mutability::Not,
293293
}
294294
}
295295
}

src/librustc/traits/error_reporting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,8 +1548,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15481548

15491549
if let ty::Ref(region, t_type, mutability) = trait_ref.skip_binder().self_ty().kind {
15501550
let trait_type = match mutability {
1551-
hir::Mutability::Mutable => self.tcx.mk_imm_ref(region, t_type),
1552-
hir::Mutability::Immutable => self.tcx.mk_mut_ref(region, t_type),
1551+
hir::Mutability::Mut => self.tcx.mk_imm_ref(region, t_type),
1552+
hir::Mutability::Not => self.tcx.mk_mut_ref(region, t_type),
15531553
};
15541554

15551555
let new_obligation = self.mk_obligation_for_def_id(
@@ -1565,7 +1565,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15651565
let sp = self.tcx.sess.source_map()
15661566
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
15671567
if points_at_arg &&
1568-
mutability == hir::Mutability::Immutable &&
1568+
mutability == hir::Mutability::Not &&
15691569
refs_number > 0
15701570
{
15711571
err.span_suggestion(

src/librustc/traits/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
26222622
| ty::Char
26232623
| ty::RawPtr(..)
26242624
| ty::Never
2625-
| ty::Ref(_, _, hir::Mutability::Immutable) => {
2625+
| ty::Ref(_, _, hir::Mutability::Not) => {
26262626
// Implementations provided in libcore
26272627
None
26282628
}
@@ -2633,7 +2633,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
26332633
| ty::Generator(..)
26342634
| ty::GeneratorWitness(..)
26352635
| ty::Foreign(..)
2636-
| ty::Ref(_, _, hir::Mutability::Mutable) => None,
2636+
| ty::Ref(_, _, hir::Mutability::Mut) => None,
26372637

26382638
ty::Array(element_ty, _) => {
26392639
// (*) binder moved here

0 commit comments

Comments
 (0)