提交 1a268f4d 编写于 作者: J Jared Roesch

Rename TypeWithMutability to TypeAndMut

上级 fe30f625
......@@ -587,11 +587,11 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
}
}
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::TypeWithMutability<'tcx> where
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::TypeAndMut<'tcx> where
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
{
let m = parse_mutability(st);
ty::TypeWithMutability { ty: parse_ty_(st, conv), mutbl: m }
ty::TypeAndMut { ty: parse_ty_(st, conv), mutbl: m }
}
fn parse_def_<F>(st: &mut PState, source: DefIdSource, conv: &mut F) -> ast::DefId where
......
......@@ -183,7 +183,7 @@ fn enc_mutability(w: &mut Encoder, mt: ast::Mutability) {
}
fn enc_mt<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
mt: ty::TypeWithMutability<'tcx>) {
mt: ty::TypeAndMut<'tcx>) {
enc_mutability(w, mt.mutbl);
enc_ty(w, cx, mt.ty);
}
......
......@@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
/// Function Pointers
FnPtr,
/// Raw pointers
Ptr(&'tcx ty::TypeWithMutability<'tcx>),
Ptr(&'tcx ty::TypeAndMut<'tcx>),
/// References
RPtr(&'tcx ty::TypeWithMutability<'tcx>),
RPtr(&'tcx ty::TypeAndMut<'tcx>),
}
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
......
......@@ -535,7 +535,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}
ty::TyRef(_, ty::TypeWithMutability { ty, mutbl }) => {
ty::TyRef(_, ty::TypeAndMut { ty, mutbl }) => {
match ty.sty {
ty::TyArray(_, n) => match ctor {
&Single => {
......@@ -600,7 +600,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
ty::TyBool =>
[true, false].iter().map(|b| ConstantValue(ConstVal::Bool(*b))).collect(),
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) => match ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
ty::TySlice(_) =>
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
_ => vec!(Single)
......@@ -808,7 +808,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
match ty.sty {
ty::TyTuple(ref fs) => fs.len(),
ty::TyBox(_) => 1,
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) => match ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
ty::TySlice(_) => match *ctor {
Slice(length) => length,
ConstantValue(_) => 0,
......
......@@ -115,7 +115,7 @@ fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
ty::TyArray(t, _) |
ty::TySlice(t) |
ty::TyRawPtr(ty::TypeWithMutability { ty: t, .. }) |
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) |
ty::TyBox(t) => {
self.accumulate_from_ty(t)
}
......
......@@ -1614,7 +1614,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn element_kind(t: Ty) -> ElementKind {
match t.sty {
ty::TyRef(_, ty::TypeWithMutability{ty, ..}) |
ty::TyRef(_, ty::TypeAndMut{ty, ..}) |
ty::TyBox(ty) => match ty.sty {
ty::TySlice(_) => VecElement,
_ => OtherElement
......
......@@ -1659,7 +1659,7 @@ fn builtin_bound(&mut self,
}
}
ty::TyRef(_, ty::TypeWithMutability { ty: _, mutbl }) => {
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl }) => {
// &mut T or &T
match bound {
ty::BoundCopy => {
......@@ -1851,8 +1851,8 @@ fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Option<Vec<Ty<'tcx>>> {
Some(vec![referent_ty])
}
ty::TyRawPtr(ty::TypeWithMutability { ty: element_ty, ..}) |
ty::TyRef(_, ty::TypeWithMutability { ty: element_ty, ..}) => {
ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) |
ty::TyRef(_, ty::TypeAndMut { ty: element_ty, ..}) => {
Some(vec![element_ty])
},
......
......@@ -110,7 +110,7 @@ pub struct CrateAnalysis {
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct Field<'tcx> {
pub name: ast::Name,
pub mt: TypeWithMutability<'tcx>
pub mt: TypeAndMut<'tcx>
}
......@@ -487,7 +487,7 @@ pub struct AssociatedType<'tcx> {
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct TypeWithMutability<'tcx> {
pub struct TypeAndMut<'tcx> {
pub ty: Ty<'tcx>,
pub mutbl: ast::Mutability,
}
......@@ -1746,11 +1746,11 @@ pub enum TypeVariants<'tcx> {
TySlice(Ty<'tcx>),
/// A raw pointer. Written as `*mut T` or `*const T`
TyRawPtr(TypeWithMutability<'tcx>),
TyRawPtr(TypeAndMut<'tcx>),
/// A reference; a pointer with an associated lifetime. Written as
/// `&a mut T` or `&'a T`.
TyRef(&'tcx Region, TypeWithMutability<'tcx>),
TyRef(&'tcx Region, TypeAndMut<'tcx>),
/// If the def-id is Some(_), then this is the type of a specific
/// fn item. Otherwise, if None(_), it a fn pointer type.
......@@ -3564,28 +3564,28 @@ pub fn mk_box(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ty(TyBox(ty))
}
pub fn mk_ptr(&self, tm: TypeWithMutability<'tcx>) -> Ty<'tcx> {
pub fn mk_ptr(&self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
self.mk_ty(TyRawPtr(tm))
}
pub fn mk_ref(&self, r: &'tcx Region, tm: TypeWithMutability<'tcx>) -> Ty<'tcx> {
pub fn mk_ref(&self, r: &'tcx Region, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
self.mk_ty(TyRef(r, tm))
}
pub fn mk_mut_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ref(r, TypeWithMutability {ty: ty, mutbl: ast::MutMutable})
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: ast::MutMutable})
}
pub fn mk_imm_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ref(r, TypeWithMutability {ty: ty, mutbl: ast::MutImmutable})
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: ast::MutImmutable})
}
pub fn mk_mut_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ptr(TypeWithMutability {ty: ty, mutbl: ast::MutMutable})
self.mk_ptr(TypeAndMut {ty: ty, mutbl: ast::MutMutable})
}
pub fn mk_imm_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ptr(TypeWithMutability {ty: ty, mutbl: ast::MutImmutable})
self.mk_ptr(TypeAndMut {ty: ty, mutbl: ast::MutImmutable})
}
pub fn mk_nil_ptr(&self) -> Ty<'tcx> {
......@@ -4269,7 +4269,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
}
fn tc_mt<'tcx>(cx: &ctxt<'tcx>,
mt: TypeWithMutability<'tcx>,
mt: TypeAndMut<'tcx>,
cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
{
let mc = TC::ReachesMutable.when(mt.mutbl == MutMutable);
......@@ -4341,11 +4341,11 @@ pub fn moves_by_default<'a>(&'tcx self, param_env: &ParameterEnvironment<'a,'tcx
// Fast-path for primitive types
let result = match self.sty {
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
TyRawPtr(..) | TyBareFn(..) | TyRef(_, TypeWithMutability {
TyRawPtr(..) | TyBareFn(..) | TyRef(_, TypeAndMut {
mutbl: ast::MutImmutable, ..
}) => Some(false),
TyStr | TyBox(..) | TyRef(_, TypeWithMutability {
TyStr | TyBox(..) | TyRef(_, TypeAndMut {
mutbl: ast::MutMutable, ..
}) => Some(true),
......@@ -4780,10 +4780,10 @@ pub fn is_c_like_enum(&self, cx: &ctxt) -> bool {
//
// The parameter `explicit` indicates if this is an *explicit* dereference.
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeWithMutability<'tcx>> {
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
match self.sty {
TyBox(ty) => {
Some(TypeWithMutability {
Some(TypeAndMut {
ty: ty,
mutbl: ast::MutImmutable,
})
......@@ -4922,10 +4922,10 @@ pub fn adjust_for_autoref(&'tcx self, cx: &ctxt<'tcx>,
match autoref {
None => self,
Some(AutoPtr(r, m)) => {
cx.mk_ref(r, TypeWithMutability { ty: self, mutbl: m })
cx.mk_ref(r, TypeAndMut { ty: self, mutbl: m })
}
Some(AutoUnsafe(m)) => {
cx.mk_ptr(TypeWithMutability { ty: self, mutbl: m })
cx.mk_ptr(TypeAndMut { ty: self, mutbl: m })
}
}
}
......@@ -5416,7 +5416,7 @@ pub fn field_idx_strict(&self, name: ast::Name, fields: &[Field<'tcx>])
pub fn note_and_explain_type_err(&self, err: &TypeError<'tcx>, sp: Span) {
use self::TypeError::*;
match *err {
RegionsDoesNotOutlive(subregion, superregion) => {
self.note_and_explain_region("", subregion, "...");
......@@ -5984,7 +5984,7 @@ pub fn struct_fields(&self, did: ast::DefId, substs: &Substs<'tcx>)
self.lookup_struct_fields(did).iter().map(|f| {
Field {
name: f.name,
mt: TypeWithMutability {
mt: TypeAndMut {
ty: self.lookup_field_type(did, f.id, substs),
mutbl: MutImmutable
}
......@@ -6070,7 +6070,7 @@ pub fn closure_upvars<'a>(typer: &infer::InferCtxt<'a, 'tcx>,
}
UpvarCapture::ByRef(borrow) => {
tcx.mk_ref(tcx.mk_region(borrow.region),
ty::TypeWithMutability {
ty::TypeAndMut {
ty: freevar_ty,
mutbl: borrow.kind.to_mutbl_lossy(),
})
......@@ -6423,7 +6423,7 @@ fn helper<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh,
h.as_str().hash(state);
did.node.hash(state);
};
let mt = |state: &mut SipHasher, mt: TypeWithMutability| {
let mt = |state: &mut SipHasher, mt: TypeAndMut| {
mt.mutbl.hash(state);
};
let fn_sig = |state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
......
......@@ -85,7 +85,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
super_fold_ty(self, t)
}
fn fold_mt(&mut self, t: &ty::TypeWithMutability<'tcx>) -> ty::TypeWithMutability<'tcx> {
fn fold_mt(&mut self, t: &ty::TypeAndMut<'tcx>) -> ty::TypeAndMut<'tcx> {
super_fold_mt(self, t)
}
......@@ -251,8 +251,8 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureTy<'tcx>
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TypeWithMutability<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeWithMutability<'tcx> {
impl<'tcx> TypeFoldable<'tcx> for ty::TypeAndMut<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeAndMut<'tcx> {
folder.fold_mt(self)
}
}
......@@ -685,9 +685,9 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
}
pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
mt: &ty::TypeWithMutability<'tcx>)
-> ty::TypeWithMutability<'tcx> {
ty::TypeWithMutability {ty: mt.ty.fold_with(this),
mt: &ty::TypeAndMut<'tcx>)
-> ty::TypeAndMut<'tcx> {
ty::TypeAndMut {ty: mt.ty.fold_with(this),
mutbl: mt.mutbl}
}
......
......@@ -89,11 +89,11 @@ fn relate<R:TypeRelation<'a,'tcx>>(relation: &mut R,
///////////////////////////////////////////////////////////////////////////
// Relate impls
impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeWithMutability<'tcx> {
impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeAndMut<'tcx> {
fn relate<R>(relation: &mut R,
a: &ty::TypeWithMutability<'tcx>,
b: &ty::TypeWithMutability<'tcx>)
-> RelateResult<'tcx, ty::TypeWithMutability<'tcx>>
a: &ty::TypeAndMut<'tcx>,
b: &ty::TypeAndMut<'tcx>)
-> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
where R: TypeRelation<'a,'tcx>
{
debug!("{}.mts({:?}, {:?})",
......@@ -109,7 +109,7 @@ fn relate<R>(relation: &mut R,
ast::MutMutable => ty::Invariant,
};
let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty));
Ok(ty::TypeWithMutability {ty: ty, mutbl: mutbl})
Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl})
}
}
}
......
......@@ -19,7 +19,7 @@
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
use middle::ty::TyClosure;
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
use middle::ty::{self, TypeWithMutability, Ty, HasTypeFlags};
use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags};
use middle::ty_fold::{self, TypeFoldable};
use std::fmt;
......@@ -321,7 +321,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
impl<'tcx> fmt::Display for ty::TypeWithMutability<'tcx> {
impl<'tcx> fmt::Display for ty::TypeAndMut<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{}",
if self.mutbl == ast::MutMutable { "mut " } else { "" },
......
......@@ -398,7 +398,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
mut path: DiscrField) -> Option<DiscrField> {
match ty.sty {
// Fat &T/&mut T/Box<T> i.e. T is [T], str, or Trait
ty::TyRef(_, ty::TypeWithMutability { ty, .. }) | ty::TyBox(ty) if !type_is_sized(tcx, ty) => {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) | ty::TyBox(ty) if !type_is_sized(tcx, ty) => {
path.push(FAT_PTR_ADDR);
Some(path)
},
......@@ -415,7 +415,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
assert_eq!(nonzero_fields.len(), 1);
let nonzero_field = tcx.lookup_field_type(did, nonzero_fields[0].id, substs);
match nonzero_field.sty {
ty::TyRawPtr(ty::TypeWithMutability { ty, .. }) if !type_is_sized(tcx, ty) => {
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) if !type_is_sized(tcx, ty) => {
path.push_all(&[0, FAT_PTR_ADDR]);
Some(path)
},
......
......@@ -223,7 +223,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// We can also mark the return value as `dereferenceable` in certain cases
match ret_ty.sty {
// These are not really pointers but pairs, (pointer, len)
ty::TyRef(_, ty::TypeWithMutability { ty: inner, .. })
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. })
| ty::TyBox(inner) if common::type_is_sized(ccx.tcx(), inner) => {
let llret_sz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner));
attrs.ret(llvm::DereferenceableAttribute(llret_sz));
......
......@@ -130,8 +130,8 @@ pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::TyRawPtr(ty::TypeWithMutability{ty, ..}) |
ty::TyRef(_, ty::TypeWithMutability{ty, ..}) |
ty::TyRawPtr(ty::TypeAndMut{ty, ..}) |
ty::TyRef(_, ty::TypeAndMut{ty, ..}) |
ty::TyBox(ty) => {
!type_is_sized(cx, ty)
}
......
......@@ -621,7 +621,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let len = unsafe { llvm::LLVMConstIntGetZExtValue(len) as u64 };
let len = match bt.sty {
ty::TyBox(ty) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) => match ty.sty {
ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => match ty.sty {
ty::TyStr => {
assert!(len > 0);
len - 1
......
......@@ -206,7 +206,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::TyRawPtr(ty::TypeWithMutability { ty: inner_type, mutbl } ) => {
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
unique_type_id.push('*');
if mutbl == ast::MutMutable {
unique_type_id.push_str("mut");
......@@ -216,7 +216,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::TyRef(_, ty::TypeWithMutability { ty: inner_type, mutbl }) => {
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
unique_type_id.push('&');
if mutbl == ast::MutMutable {
unique_type_id.push_str("mut");
......@@ -561,7 +561,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
unique_type_id: UniqueTypeId,
span: Span)
-> MetadataCreationResult {
let data_ptr_type = cx.tcx().mk_ptr(ty::TypeWithMutability {
let data_ptr_type = cx.tcx().mk_ptr(ty::TypeAndMut {
ty: element_type,
mutbl: ast::MutImmutable
});
......@@ -765,7 +765,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
trait_pointer_metadata(cx, t, None, unique_type_id),
false)
}
ty::TyBox(ty) | ty::TyRawPtr(ty::TypeWithMutability{ty, ..}) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) => {
ty::TyBox(ty) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => {
match ty.sty {
ty::TySlice(typ) => {
vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
......
......@@ -77,7 +77,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name(cx, inner_type, true, output);
output.push('>');
},
ty::TyRawPtr(ty::TypeWithMutability { ty: inner_type, mutbl } ) => {
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
output.push('*');
match mutbl {
ast::MutImmutable => output.push_str("const "),
......@@ -86,7 +86,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name(cx, inner_type, true, output);
},
ty::TyRef(_, ty::TypeWithMutability { ty: inner_type, mutbl }) => {
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
output.push('&');
if mutbl == ast::MutMutable {
output.push_str("mut ");
......
......@@ -440,9 +440,9 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
match (&source.ty.sty, &target.ty.sty) {
(&ty::TyBox(a), &ty::TyBox(b)) |
(&ty::TyRef(_, ty::TypeWithMutability { ty: a, .. }), &ty::TyRef(_, ty::TypeWithMutability { ty: b, .. })) |
(&ty::TyRef(_, ty::TypeWithMutability { ty: a, .. }), &ty::TyRawPtr(ty::TypeWithMutability { ty: b, .. })) |
(&ty::TyRawPtr(ty::TypeWithMutability { ty: a, .. }), &ty::TyRawPtr(ty::TypeWithMutability { ty: b, .. })) => {
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), &ty::TyRef(_, ty::TypeAndMut { ty: b, .. })) |
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) |
(&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => {
let (inner_source, inner_target) = (a, b);
let (base, old_info) = if !type_is_sized(bcx.tcx(), inner_source) {
......@@ -1346,7 +1346,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
let fields: Vec<_> = v.iter().enumerate().map(|(i, &f)| {
ty::Field {
name: token::intern(&i.to_string()),
mt: ty::TypeWithMutability {
mt: ty::TypeAndMut {
ty: f,
mutbl: ast::MutImmutable
}
......@@ -1994,7 +1994,7 @@ pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>,
}
match (t_in.builtin_deref(true), t_out.builtin_deref(true)) {
(Some(ty::TypeWithMutability{ ty: t_in, .. }), Some(ty::TypeWithMutability{ ty: t_out, .. })) => {
(Some(ty::TypeAndMut{ ty: t_in, .. }), Some(ty::TypeAndMut{ ty: t_out, .. })) => {
t_in == t_out
}
_ => {
......@@ -2275,8 +2275,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ty::TyRawPtr(ty::TypeWithMutability { ty: content_ty, .. }) |
ty::TyRef(_, ty::TypeWithMutability { ty: content_ty, .. }) => {
ty::TyRawPtr(ty::TypeAndMut { ty: content_ty, .. }) |
ty::TyRef(_, ty::TypeAndMut { ty: content_ty, .. }) => {
if type_is_sized(bcx.tcx(), content_ty) {
let ptr = datum.to_llscalarish(bcx);
......
......@@ -315,7 +315,7 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
// Only used for pattern matching.
ty::TyBox(ty) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => {
let inner = if type_is_sized(bcx.tcx(), ty) {
Load(bcx, llval)
} else {
......
......@@ -193,7 +193,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
ty::TyUint(t) => Type::uint_from_ty(cx, t),
ty::TyFloat(t) => Type::float_from_ty(cx, t),
ty::TyBox(ty) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) | ty::TyRawPtr(ty::TypeWithMutability{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => {
if type_is_sized(cx.tcx(), ty) {
Type::i8p(cx)
} else {
......@@ -352,7 +352,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
adt::incomplete_type_of(cx, &*repr, "closure")
}
ty::TyBox(ty) | ty::TyRef(_, ty::TypeWithMutability{ty, ..}) | ty::TyRawPtr(ty::TypeWithMutability{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => {
if !type_is_sized(cx.tcx(), ty) {
if let ty::TyStr = ty.sty {
// This means we get a nicer name in the output (str is always
......
......@@ -1556,7 +1556,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
}
}
ast::TyPtr(ref mt) => {
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: ast_ty_to_ty(this, rscope, &*mt.ty),
mutbl: mt.mutbl
})
......@@ -1569,7 +1569,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
rscope,
ty::ObjectLifetimeDefault::Specific(r));
let t = ast_ty_to_ty(this, rscope1, &*mt.ty);
tcx.mk_ref(tcx.mk_region(r), ty::TypeWithMutability {ty: t, mutbl: mt.mutbl})
tcx.mk_ref(tcx.mk_region(r), ty::TypeAndMut {ty: t, mutbl: mt.mutbl})
}
ast::TyTup(ref fields) => {
let flds = fields.iter()
......@@ -1755,7 +1755,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
ty::ByReferenceExplicitSelfCategory(region, mutability) => {
(Some(this.tcx().mk_ref(
this.tcx().mk_region(region),
ty::TypeWithMutability {
ty::TypeAndMut {
ty: self_info.untransformed_self_ty,
mutbl: mutability
})),
......
......@@ -170,7 +170,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
// then `x` is assigned a value of type `&M T` where M is the mutability
// and T is the expected type.
let region_var = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
let mt = ty::TypeWithMutability { ty: expected, mutbl: mutbl };
let mt = ty::TypeAndMut { ty: expected, mutbl: mutbl };
let region_ty = tcx.mk_ref(tcx.mk_region(region_var), mt);
// `x` is assigned a value of type `&M T`, hence `&M T <: typeof(x)` is
......@@ -272,7 +272,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
ast::PatRegion(ref inner, mutbl) => {
let inner_ty = fcx.infcx().next_ty_var();
let mt = ty::TypeWithMutability { ty: inner_ty, mutbl: mutbl };
let mt = ty::TypeAndMut { ty: inner_ty, mutbl: mutbl };
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
let rptr_ty = tcx.mk_ref(tcx.mk_region(region), mt);
......@@ -301,7 +301,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
}),
_ => {
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
tcx.mk_ref(tcx.mk_region(region), ty::TypeWithMutability {
tcx.mk_ref(tcx.mk_region(region), ty::TypeAndMut {
ty: tcx.mk_slice(inner_ty),
mutbl: expected_ty.builtin_deref(true).map(|mt| mt.mutbl)
.unwrap_or(ast::MutImmutable)
......@@ -324,7 +324,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
let mutbl = expected_ty.builtin_deref(true)
.map_or(ast::MutImmutable, |mt| mt.mutbl);
let slice_ty = tcx.mk_ref(tcx.mk_region(region), ty::TypeWithMutability {
let slice_ty = tcx.mk_ref(tcx.mk_region(region), ty::TypeAndMut {
ty: tcx.mk_slice(inner_ty),
mutbl: mutbl
});
......
......@@ -272,8 +272,8 @@ fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
fn check_ptr_ptr_cast<'a>(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: &'tcx ty::TypeWithMutability<'tcx>,
m_cast: &'tcx ty::TypeWithMutability<'tcx>)
m_expr: &'tcx ty::TypeAndMut<'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError>
{
debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}",
......@@ -299,7 +299,7 @@ fn check_ptr_ptr_cast<'a>(&self,
fn check_fptr_ptr_cast<'a>(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: &'tcx ty::TypeWithMutability<'tcx>)
m_cast: &'tcx ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError>
{
// fptr-ptr cast. must be to sized ptr
......@@ -313,7 +313,7 @@ fn check_fptr_ptr_cast<'a>(&self,
fn check_ptr_addr_cast<'a>(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: &'tcx ty::TypeWithMutability<'tcx>)
m_expr: &'tcx ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError>
{
// ptr-addr cast. must be from sized ptr
......@@ -327,8 +327,8 @@ fn check_ptr_addr_cast<'a>(&self,
fn check_ref_cast<'a>(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_expr: &'tcx ty::TypeWithMutability<'tcx>,
m_cast: &'tcx ty::TypeWithMutability<'tcx>)
m_expr: &'tcx ty::TypeAndMut<'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError>
{
// array-ptr-cast.
......@@ -353,7 +353,7 @@ fn check_ref_cast<'a>(&self,
fn check_addr_ptr_cast<'a>(&self,
fcx: &FnCtxt<'a, 'tcx>,
m_cast: &'tcx ty::TypeWithMutability<'tcx>)
m_cast: &'tcx ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError>
{
// ptr-addr cast. pointer must be thin.
......
......@@ -66,7 +66,7 @@
use middle::traits::{self, ObligationCause};
use middle::traits::{predicate_for_trait_def, report_selection_error};
use middle::ty::{AutoDerefRef, AdjustDerefRef};
use middle::ty::{self, TypeWithMutability, Ty, TypeError};
use middle::ty::{self, TypeAndMut, Ty, TypeError};
use middle::ty_relate::RelateResult;
use util::common::indent;
......@@ -202,7 +202,7 @@ fn coerce_borrowed_pointer(&self,
return None;
}
let ty = self.tcx().mk_ref(r_borrow,
TypeWithMutability {ty: inner_ty, mutbl: mutbl_b});
TypeAndMut {ty: inner_ty, mutbl: mutbl_b});
if let Err(err) = self.subtype(ty, b) {
if first_error.is_none() {
first_error = Some(err);
......@@ -411,7 +411,7 @@ fn coerce_unsafe_ptr(&self,
};
// Check that the types which they point at are compatible.
let a_unsafe = self.tcx().mk_ptr(ty::TypeWithMutability{ mutbl: mutbl_b, ty: mt_a.ty });
let a_unsafe = self.tcx().mk_ptr(ty::TypeAndMut{ mutbl: mutbl_b, ty: mt_a.ty });
try!(self.subtype(a_unsafe, b));
try!(coerce_mutbls(mt_a.mutbl, mutbl_b));
......
......@@ -433,7 +433,7 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
};
match sig.0.inputs[0].sty {
ty::TyRef(_, ty::TypeWithMutability {
ty::TyRef(_, ty::TypeAndMut {
ty: _,
mutbl: ast::MutMutable,
}) => {}
......
......@@ -271,7 +271,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// Trait method is fn(&self) or fn(&mut self), need an
// autoref. Pull the region etc out of the type of first argument.
match transformed_self_ty.sty {
ty::TyRef(region, ty::TypeWithMutability { mutbl, ty: _ }) => {
ty::TyRef(region, ty::TypeAndMut { mutbl, ty: _ }) => {
fcx.write_adjustment(self_expr.id,
ty::AdjustDerefRef(ty::AutoDerefRef {
autoderefs: autoderefs,
......
......@@ -311,11 +311,11 @@ fn assemble_probe(&mut self, self_ty: Ty<'tcx>) {
let lang_def_id = self.tcx().lang_items.slice_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyRawPtr(ty::TypeWithMutability { ty: _, mutbl: ast::MutImmutable }) => {
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: ast::MutImmutable }) => {
let lang_def_id = self.tcx().lang_items.const_ptr_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyRawPtr(ty::TypeWithMutability { ty: _, mutbl: ast::MutMutable }) => {
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: ast::MutMutable }) => {
let lang_def_id = self.tcx().lang_items.mut_ptr_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
......@@ -951,7 +951,7 @@ fn pick_autorefd_method(&mut self,
// Search through mutabilities in order to find one where pick works:
[ast::MutImmutable, ast::MutMutable].iter().filter_map(|&m| {
let autoref_ty = tcx.mk_ref(region, ty::TypeWithMutability {
let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut {
ty: step.self_ty,
mutbl: m
});
......
......@@ -1030,7 +1030,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
format!("cast to unsized type: `{}` as `{}`", actual, tstr)
}, t_expr, None);
match t_expr.sty {
ty::TyRef(_, ty::TypeWithMutability { mutbl: mt, .. }) => {
ty::TyRef(_, ty::TypeAndMut { mutbl: mt, .. }) => {
let mtstr = match mt {
ast::MutMutable => "mut ",
ast::MutImmutable => ""
......@@ -1895,7 +1895,7 @@ fn try_overloaded_deref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
base_expr: Option<&ast::Expr>,
base_ty: Ty<'tcx>,
lvalue_pref: LvaluePreference)
-> Option<ty::TypeWithMutability<'tcx>>
-> Option<ty::TypeAndMut<'tcx>>
{
// Try DerefMut first, if preferred.
let method = match (lvalue_pref, fcx.tcx().lang_items.deref_mut_trait()) {
......@@ -1926,7 +1926,7 @@ fn try_overloaded_deref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
method_call: Option<MethodCall>,
method: Option<MethodCallee<'tcx>>)
-> Option<ty::TypeWithMutability<'tcx>>
-> Option<ty::TypeAndMut<'tcx>>
{
match method {
Some(method) => {
......@@ -3111,7 +3111,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
hint,
lvalue_pref);
let tm = ty::TypeWithMutability { ty: fcx.expr_ty(&**oprnd), mutbl: mutbl };
let tm = ty::TypeAndMut { ty: fcx.expr_ty(&**oprnd), mutbl: mutbl };
let oprnd_t = if tm.ty.references_error() {
tcx.types.err
} else {
......@@ -4909,13 +4909,13 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"offset" | "arith_offset" => {
(1,
vec!(
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutImmutable
}),
ccx.tcx.types.isize
),
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutImmutable
}))
......@@ -4923,11 +4923,11 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"copy" | "copy_nonoverlapping" => {
(1,
vec!(
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutImmutable
}),
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutMutable
}),
......@@ -4938,11 +4938,11 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"volatile_copy_memory" | "volatile_copy_nonoverlapping_memory" => {
(1,
vec!(
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutMutable
}),
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutImmutable
}),
......@@ -4953,7 +4953,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"write_bytes" | "volatile_set_memory" => {
(1,
vec!(
tcx.mk_ptr(ty::TypeWithMutability {
tcx.mk_ptr(ty::TypeAndMut {
ty: param(ccx, 0),
mutbl: ast::MutMutable
}),
......
......@@ -450,7 +450,7 @@ fn check_implementations_of_coerce_unsized(&self) {
let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env), true);
let check_mutbl = |mt_a: ty::TypeWithMutability<'tcx>, mt_b: ty::TypeWithMutability<'tcx>,
let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>,
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
if (mt_a.mutbl, mt_b.mutbl) == (ast::MutImmutable, ast::MutMutable) {
infcx.report_mismatched_types(span, mk_ptr(mt_b.ty),
......
......@@ -100,14 +100,14 @@ fn check_item(&self, item: &ast::Item) {
"[T]",
item.span);
}
ty::TyRawPtr(ty::TypeWithMutability { ty: _, mutbl: ast::MutImmutable }) => {
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: ast::MutImmutable }) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.const_ptr_impl(),
"const_ptr",
"*const T",
item.span);
}
ty::TyRawPtr(ty::TypeWithMutability { ty: _, mutbl: ast::MutMutable }) => {
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: ast::MutMutable }) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.mut_ptr_impl(),
"mut_ptr",
......
......@@ -1074,7 +1074,7 @@ fn add_constraints_from_region(&mut self,
/// appearing in a context with ambient variance `variance`
fn add_constraints_from_mt(&mut self,
generics: &ty::Generics<'tcx>,
mt: &ty::TypeWithMutability<'tcx>,
mt: &ty::TypeAndMut<'tcx>,
variance: VarianceTermPtr<'a>) {
match mt.mutbl {
ast::MutMutable => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册