Skip to content

Commit 1a268f4

Browse files
committed
Rename TypeWithMutability to TypeAndMut
1 parent fe30f62 commit 1a268f4

31 files changed

+106
-106
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,11 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
587587
}
588588
}
589589

590-
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::TypeWithMutability<'tcx> where
590+
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::TypeAndMut<'tcx> where
591591
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
592592
{
593593
let m = parse_mutability(st);
594-
ty::TypeWithMutability { ty: parse_ty_(st, conv), mutbl: m }
594+
ty::TypeAndMut { ty: parse_ty_(st, conv), mutbl: m }
595595
}
596596

597597
fn parse_def_<F>(st: &mut PState, source: DefIdSource, conv: &mut F) -> ast::DefId where

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn enc_mutability(w: &mut Encoder, mt: ast::Mutability) {
183183
}
184184

185185
fn enc_mt<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
186-
mt: ty::TypeWithMutability<'tcx>) {
186+
mt: ty::TypeAndMut<'tcx>) {
187187
enc_mutability(w, mt.mutbl);
188188
enc_ty(w, cx, mt.ty);
189189
}

src/librustc/middle/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
3636
/// Function Pointers
3737
FnPtr,
3838
/// Raw pointers
39-
Ptr(&'tcx ty::TypeWithMutability<'tcx>),
39+
Ptr(&'tcx ty::TypeAndMut<'tcx>),
4040
/// References
41-
RPtr(&'tcx ty::TypeWithMutability<'tcx>),
41+
RPtr(&'tcx ty::TypeAndMut<'tcx>),
4242
}
4343

4444
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
535535
}
536536
}
537537

538-
ty::TyRef(_, ty::TypeWithMutability { ty, mutbl }) => {
538+
ty::TyRef(_, ty::TypeAndMut { ty, mutbl }) => {
539539
match ty.sty {
540540
ty::TyArray(_, n) => match ctor {
541541
&Single => {
@@ -600,7 +600,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
600600
ty::TyBool =>
601601
[true, false].iter().map(|b| ConstantValue(ConstVal::Bool(*b))).collect(),
602602

603-
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) => match ty.sty {
603+
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
604604
ty::TySlice(_) =>
605605
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
606606
_ => vec!(Single)
@@ -808,7 +808,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
808808
match ty.sty {
809809
ty::TyTuple(ref fs) => fs.len(),
810810
ty::TyBox(_) => 1,
811-
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) => match ty.sty {
811+
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
812812
ty::TySlice(_) => match *ctor {
813813
Slice(length) => length,
814814
ConstantValue(_) => 0,

src/librustc/middle/implicator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
115115

116116
ty::TyArray(t, _) |
117117
ty::TySlice(t) |
118-
ty::TyRawPtr(ty::TypeWithMutability { ty: t, .. }) |
118+
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) |
119119
ty::TyBox(t) => {
120120
self.accumulate_from_ty(t)
121121
}

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ impl fmt::Debug for InteriorKind {
16141614

16151615
fn element_kind(t: Ty) -> ElementKind {
16161616
match t.sty {
1617-
ty::TyRef(_, ty::TypeWithMutability{ty, ..}) |
1617+
ty::TyRef(_, ty::TypeAndMut{ty, ..}) |
16181618
ty::TyBox(ty) => match ty.sty {
16191619
ty::TySlice(_) => VecElement,
16201620
_ => OtherElement

src/librustc/middle/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16591659
}
16601660
}
16611661

1662-
ty::TyRef(_, ty::TypeWithMutability { ty: _, mutbl }) => {
1662+
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl }) => {
16631663
// &mut T or &T
16641664
match bound {
16651665
ty::BoundCopy => {
@@ -1851,8 +1851,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18511851
Some(vec![referent_ty])
18521852
}
18531853

1854-
ty::TyRawPtr(ty::TypeWithMutability { ty: element_ty, ..}) |
1855-
ty::TyRef(_, ty::TypeWithMutability { ty: element_ty, ..}) => {
1854+
ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) |
1855+
ty::TyRef(_, ty::TypeAndMut { ty: element_ty, ..}) => {
18561856
Some(vec![element_ty])
18571857
},
18581858

src/librustc/middle/ty.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub struct CrateAnalysis {
110110
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
111111
pub struct Field<'tcx> {
112112
pub name: ast::Name,
113-
pub mt: TypeWithMutability<'tcx>
113+
pub mt: TypeAndMut<'tcx>
114114
}
115115

116116

@@ -487,7 +487,7 @@ pub struct AssociatedType<'tcx> {
487487
}
488488

489489
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
490-
pub struct TypeWithMutability<'tcx> {
490+
pub struct TypeAndMut<'tcx> {
491491
pub ty: Ty<'tcx>,
492492
pub mutbl: ast::Mutability,
493493
}
@@ -1746,11 +1746,11 @@ pub enum TypeVariants<'tcx> {
17461746
TySlice(Ty<'tcx>),
17471747

17481748
/// A raw pointer. Written as `*mut T` or `*const T`
1749-
TyRawPtr(TypeWithMutability<'tcx>),
1749+
TyRawPtr(TypeAndMut<'tcx>),
17501750

17511751
/// A reference; a pointer with an associated lifetime. Written as
17521752
/// `&a mut T` or `&'a T`.
1753-
TyRef(&'tcx Region, TypeWithMutability<'tcx>),
1753+
TyRef(&'tcx Region, TypeAndMut<'tcx>),
17541754

17551755
/// If the def-id is Some(_), then this is the type of a specific
17561756
/// fn item. Otherwise, if None(_), it a fn pointer type.
@@ -3564,28 +3564,28 @@ impl<'tcx> ctxt<'tcx> {
35643564
self.mk_ty(TyBox(ty))
35653565
}
35663566

3567-
pub fn mk_ptr(&self, tm: TypeWithMutability<'tcx>) -> Ty<'tcx> {
3567+
pub fn mk_ptr(&self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
35683568
self.mk_ty(TyRawPtr(tm))
35693569
}
35703570

3571-
pub fn mk_ref(&self, r: &'tcx Region, tm: TypeWithMutability<'tcx>) -> Ty<'tcx> {
3571+
pub fn mk_ref(&self, r: &'tcx Region, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
35723572
self.mk_ty(TyRef(r, tm))
35733573
}
35743574

35753575
pub fn mk_mut_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
3576-
self.mk_ref(r, TypeWithMutability {ty: ty, mutbl: ast::MutMutable})
3576+
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: ast::MutMutable})
35773577
}
35783578

35793579
pub fn mk_imm_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
3580-
self.mk_ref(r, TypeWithMutability {ty: ty, mutbl: ast::MutImmutable})
3580+
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: ast::MutImmutable})
35813581
}
35823582

35833583
pub fn mk_mut_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
3584-
self.mk_ptr(TypeWithMutability {ty: ty, mutbl: ast::MutMutable})
3584+
self.mk_ptr(TypeAndMut {ty: ty, mutbl: ast::MutMutable})
35853585
}
35863586

35873587
pub fn mk_imm_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
3588-
self.mk_ptr(TypeWithMutability {ty: ty, mutbl: ast::MutImmutable})
3588+
self.mk_ptr(TypeAndMut {ty: ty, mutbl: ast::MutImmutable})
35893589
}
35903590

35913591
pub fn mk_nil_ptr(&self) -> Ty<'tcx> {
@@ -4269,7 +4269,7 @@ impl<'tcx> TyS<'tcx> {
42694269
}
42704270

42714271
fn tc_mt<'tcx>(cx: &ctxt<'tcx>,
4272-
mt: TypeWithMutability<'tcx>,
4272+
mt: TypeAndMut<'tcx>,
42734273
cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
42744274
{
42754275
let mc = TC::ReachesMutable.when(mt.mutbl == MutMutable);
@@ -4341,11 +4341,11 @@ impl<'tcx> TyS<'tcx> {
43414341
// Fast-path for primitive types
43424342
let result = match self.sty {
43434343
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
4344-
TyRawPtr(..) | TyBareFn(..) | TyRef(_, TypeWithMutability {
4344+
TyRawPtr(..) | TyBareFn(..) | TyRef(_, TypeAndMut {
43454345
mutbl: ast::MutImmutable, ..
43464346
}) => Some(false),
43474347

4348-
TyStr | TyBox(..) | TyRef(_, TypeWithMutability {
4348+
TyStr | TyBox(..) | TyRef(_, TypeAndMut {
43494349
mutbl: ast::MutMutable, ..
43504350
}) => Some(true),
43514351

@@ -4780,10 +4780,10 @@ impl<'tcx> TyS<'tcx> {
47804780
//
47814781
// The parameter `explicit` indicates if this is an *explicit* dereference.
47824782
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
4783-
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeWithMutability<'tcx>> {
4783+
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
47844784
match self.sty {
47854785
TyBox(ty) => {
4786-
Some(TypeWithMutability {
4786+
Some(TypeAndMut {
47874787
ty: ty,
47884788
mutbl: ast::MutImmutable,
47894789
})
@@ -4922,10 +4922,10 @@ impl<'tcx> TyS<'tcx> {
49224922
match autoref {
49234923
None => self,
49244924
Some(AutoPtr(r, m)) => {
4925-
cx.mk_ref(r, TypeWithMutability { ty: self, mutbl: m })
4925+
cx.mk_ref(r, TypeAndMut { ty: self, mutbl: m })
49264926
}
49274927
Some(AutoUnsafe(m)) => {
4928-
cx.mk_ptr(TypeWithMutability { ty: self, mutbl: m })
4928+
cx.mk_ptr(TypeAndMut { ty: self, mutbl: m })
49294929
}
49304930
}
49314931
}
@@ -5416,7 +5416,7 @@ impl<'tcx> ctxt<'tcx> {
54165416

54175417
pub fn note_and_explain_type_err(&self, err: &TypeError<'tcx>, sp: Span) {
54185418
use self::TypeError::*;
5419-
5419+
54205420
match *err {
54215421
RegionsDoesNotOutlive(subregion, superregion) => {
54225422
self.note_and_explain_region("", subregion, "...");
@@ -5984,7 +5984,7 @@ impl<'tcx> ctxt<'tcx> {
59845984
self.lookup_struct_fields(did).iter().map(|f| {
59855985
Field {
59865986
name: f.name,
5987-
mt: TypeWithMutability {
5987+
mt: TypeAndMut {
59885988
ty: self.lookup_field_type(did, f.id, substs),
59895989
mutbl: MutImmutable
59905990
}
@@ -6070,7 +6070,7 @@ impl<'tcx> ctxt<'tcx> {
60706070
}
60716071
UpvarCapture::ByRef(borrow) => {
60726072
tcx.mk_ref(tcx.mk_region(borrow.region),
6073-
ty::TypeWithMutability {
6073+
ty::TypeAndMut {
60746074
ty: freevar_ty,
60756075
mutbl: borrow.kind.to_mutbl_lossy(),
60766076
})
@@ -6423,7 +6423,7 @@ impl<'tcx> ctxt<'tcx> {
64236423
h.as_str().hash(state);
64246424
did.node.hash(state);
64256425
};
6426-
let mt = |state: &mut SipHasher, mt: TypeWithMutability| {
6426+
let mt = |state: &mut SipHasher, mt: TypeAndMut| {
64276427
mt.mutbl.hash(state);
64286428
};
64296429
let fn_sig = |state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {

src/librustc/middle/ty_fold.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub trait TypeFolder<'tcx> : Sized {
8585
super_fold_ty(self, t)
8686
}
8787

88-
fn fold_mt(&mut self, t: &ty::TypeWithMutability<'tcx>) -> ty::TypeWithMutability<'tcx> {
88+
fn fold_mt(&mut self, t: &ty::TypeAndMut<'tcx>) -> ty::TypeAndMut<'tcx> {
8989
super_fold_mt(self, t)
9090
}
9191

@@ -251,8 +251,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureTy<'tcx> {
251251
}
252252
}
253253

254-
impl<'tcx> TypeFoldable<'tcx> for ty::TypeWithMutability<'tcx> {
255-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeWithMutability<'tcx> {
254+
impl<'tcx> TypeFoldable<'tcx> for ty::TypeAndMut<'tcx> {
255+
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeAndMut<'tcx> {
256256
folder.fold_mt(self)
257257
}
258258
}
@@ -685,9 +685,9 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
685685
}
686686

687687
pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
688-
mt: &ty::TypeWithMutability<'tcx>)
689-
-> ty::TypeWithMutability<'tcx> {
690-
ty::TypeWithMutability {ty: mt.ty.fold_with(this),
688+
mt: &ty::TypeAndMut<'tcx>)
689+
-> ty::TypeAndMut<'tcx> {
690+
ty::TypeAndMut {ty: mt.ty.fold_with(this),
691691
mutbl: mt.mutbl}
692692
}
693693

src/librustc/middle/ty_relate/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ pub trait Relate<'a,'tcx>: TypeFoldable<'tcx> {
8989
///////////////////////////////////////////////////////////////////////////
9090
// Relate impls
9191

92-
impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeWithMutability<'tcx> {
92+
impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeAndMut<'tcx> {
9393
fn relate<R>(relation: &mut R,
94-
a: &ty::TypeWithMutability<'tcx>,
95-
b: &ty::TypeWithMutability<'tcx>)
96-
-> RelateResult<'tcx, ty::TypeWithMutability<'tcx>>
94+
a: &ty::TypeAndMut<'tcx>,
95+
b: &ty::TypeAndMut<'tcx>)
96+
-> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
9797
where R: TypeRelation<'a,'tcx>
9898
{
9999
debug!("{}.mts({:?}, {:?})",
@@ -109,7 +109,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeWithMutability<'tcx> {
109109
ast::MutMutable => ty::Invariant,
110110
};
111111
let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty));
112-
Ok(ty::TypeWithMutability {ty: ty, mutbl: mutbl})
112+
Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl})
113113
}
114114
}
115115
}

src/librustc/util/ppaux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn};
1919
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
2020
use middle::ty::TyClosure;
2121
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
22-
use middle::ty::{self, TypeWithMutability, Ty, HasTypeFlags};
22+
use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags};
2323
use middle::ty_fold::{self, TypeFoldable};
2424

2525
use std::fmt;
@@ -321,7 +321,7 @@ impl<'tcx> fmt::Debug for ty::TyS<'tcx> {
321321
}
322322
}
323323

324-
impl<'tcx> fmt::Display for ty::TypeWithMutability<'tcx> {
324+
impl<'tcx> fmt::Display for ty::TypeAndMut<'tcx> {
325325
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
326326
write!(f, "{}{}",
327327
if self.mutbl == ast::MutMutable { "mut " } else { "" },

src/librustc_trans/trans/adt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
398398
mut path: DiscrField) -> Option<DiscrField> {
399399
match ty.sty {
400400
// Fat &T/&mut T/Box<T> i.e. T is [T], str, or Trait
401-
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) | ty::TyBox(ty) if !type_is_sized(tcx, ty) => {
401+
ty::TyRef(_, ty::TypeAndMut { ty, .. }) | ty::TyBox(ty) if !type_is_sized(tcx, ty) => {
402402
path.push(FAT_PTR_ADDR);
403403
Some(path)
404404
},
@@ -415,7 +415,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
415415
assert_eq!(nonzero_fields.len(), 1);
416416
let nonzero_field = tcx.lookup_field_type(did, nonzero_fields[0].id, substs);
417417
match nonzero_field.sty {
418-
ty::TyRawPtr(ty::TypeWithMutability { ty, .. }) if !type_is_sized(tcx, ty) => {
418+
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) if !type_is_sized(tcx, ty) => {
419419
path.push_all(&[0, FAT_PTR_ADDR]);
420420
Some(path)
421421
},

src/librustc_trans/trans/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
223223
// We can also mark the return value as `dereferenceable` in certain cases
224224
match ret_ty.sty {
225225
// These are not really pointers but pairs, (pointer, len)
226-
ty::TyRef(_, ty::TypeWithMutability { ty: inner, .. })
226+
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. })
227227
| ty::TyBox(inner) if common::type_is_sized(ccx.tcx(), inner) => {
228228
let llret_sz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner));
229229
attrs.ret(llvm::DereferenceableAttribute(llret_sz));

src/librustc_trans/trans/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
130130

131131
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
132132
match ty.sty {
133-
ty::TyRawPtr(ty::TypeWithMutability{ty, ..}) |
134-
ty::TyRef(_, ty::TypeWithMutability{ty, ..}) |
133+
ty::TyRawPtr(ty::TypeAndMut{ty, ..}) |
134+
ty::TyRef(_, ty::TypeAndMut{ty, ..}) |
135135
ty::TyBox(ty) => {
136136
!type_is_sized(cx, ty)
137137
}

src/librustc_trans/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
621621

622622
let len = unsafe { llvm::LLVMConstIntGetZExtValue(len) as u64 };
623623
let len = match bt.sty {
624-
ty::TyBox(ty) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) => match ty.sty {
624+
ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => match ty.sty {
625625
ty::TyStr => {
626626
assert!(len > 0);
627627
len - 1

0 commit comments

Comments
 (0)