1
Fork 0

Insert fields from TypeAndMut into TyRef to allow layout optimization

This commit is contained in:
John Kåre Alsaker 2018-05-02 15:21:05 +02:00
parent 710b4ad2a5
commit c9d9c249ec
60 changed files with 242 additions and 241 deletions

View file

@ -888,9 +888,10 @@ for ty::TypeVariants<'gcx>
TyRawPtr(pointee_ty) => { TyRawPtr(pointee_ty) => {
pointee_ty.hash_stable(hcx, hasher); pointee_ty.hash_stable(hcx, hasher);
} }
TyRef(region, pointee_ty) => { TyRef(region, pointee_ty, mutbl) => {
region.hash_stable(hcx, hasher); region.hash_stable(hcx, hasher);
pointee_ty.hash_stable(hcx, hasher); pointee_ty.hash_stable(hcx, hasher);
mutbl.hash_stable(hcx, hasher);
} }
TyFnDef(def_id, substs) => { TyFnDef(def_id, substs) => {
def_id.hash_stable(hcx, hasher); def_id.hash_stable(hcx, hasher);

View file

@ -665,7 +665,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn push_ty_ref<'tcx>( fn push_ty_ref<'tcx>(
r: &ty::Region<'tcx>, r: &ty::Region<'tcx>,
tnm: &ty::TypeAndMut<'tcx>, ty: Ty<'tcx>,
mutbl: hir::Mutability,
s: &mut DiagnosticStyledString, s: &mut DiagnosticStyledString,
) { ) {
let r = &format!("{}", r); let r = &format!("{}", r);
@ -673,13 +674,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
"&{}{}{}", "&{}{}{}",
r, r,
if r == "" { "" } else { " " }, if r == "" { "" } else { " " },
if tnm.mutbl == hir::MutMutable { if mutbl == hir::MutMutable {
"mut " "mut "
} else { } else {
"" ""
} }
)); ));
s.push_normal(format!("{}", tnm.ty)); s.push_normal(format!("{}", ty));
} }
match (&t1.sty, &t2.sty) { match (&t1.sty, &t2.sty) {
@ -803,24 +804,25 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
// When finding T != &T, highlight only the borrow // When finding T != &T, highlight only the borrow
(&ty::TyRef(r1, ref tnm1), _) if equals(&tnm1.ty, &t2) => { (&ty::TyRef(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
push_ty_ref(&r1, tnm1, &mut values.0); push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
values.1.push_normal(format!("{}", t2)); values.1.push_normal(format!("{}", t2));
values values
} }
(_, &ty::TyRef(r2, ref tnm2)) if equals(&t1, &tnm2.ty) => { (_, &ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
values.0.push_normal(format!("{}", t1)); values.0.push_normal(format!("{}", t1));
push_ty_ref(&r2, tnm2, &mut values.1); push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1);
values values
} }
// When encountering &T != &mut T, highlight only the borrow // When encountering &T != &mut T, highlight only the borrow
(&ty::TyRef(r1, ref tnm1), &ty::TyRef(r2, ref tnm2)) if equals(&tnm1.ty, &tnm2.ty) => { (&ty::TyRef(r1, ref_ty1, mutbl1),
&ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => {
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
push_ty_ref(&r1, tnm1, &mut values.0); push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
push_ty_ref(&r2, tnm2, &mut values.1); push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1);
values values
} }

View file

@ -456,7 +456,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
// make sure that the thing we are pointing out stays valid // make sure that the thing we are pointing out stays valid
// for the lifetime `scope_r` of the resulting ptr: // for the lifetime `scope_r` of the resulting ptr:
let expr_ty = return_if_err!(self.mc.expr_ty(expr)); let expr_ty = return_if_err!(self.mc.expr_ty(expr));
if let ty::TyRef(r, _) = expr_ty.sty { if let ty::TyRef(r, _, _) = expr_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m); let bk = ty::BorrowKind::from_mutbl(m);
self.borrow_expr(&base, r, bk, AddrOf); self.borrow_expr(&base, r, bk, AddrOf);
} }
@ -859,7 +859,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
// It is also a borrow or copy/move of the value being matched. // It is also a borrow or copy/move of the value being matched.
match bm { match bm {
ty::BindByReference(m) => { ty::BindByReference(m) => {
if let ty::TyRef(r, _) = pat_ty.sty { if let ty::TyRef(r, _, _) = pat_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m); let bk = ty::BorrowKind::from_mutbl(m);
delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding); delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding);
} }

View file

@ -1012,7 +1012,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let base_ty = self.expr_ty_adjusted(base)?; let base_ty = self.expr_ty_adjusted(base)?;
let (region, mutbl) = match base_ty.sty { let (region, mutbl) = match base_ty.sty {
ty::TyRef(region, mt) => (region, mt.mutbl), ty::TyRef(region, _, mutbl) => (region, mutbl),
_ => { _ => {
span_bug!(expr.span, "cat_overloaded_place: base is not a reference") span_bug!(expr.span, "cat_overloaded_place: base is not a reference")
} }
@ -1046,8 +1046,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let ptr = match base_cmt.ty.sty { let ptr = match base_cmt.ty.sty {
ty::TyAdt(def, ..) if def.is_box() => Unique, ty::TyAdt(def, ..) if def.is_box() => Unique,
ty::TyRawPtr(ref mt) => UnsafePtr(mt.mutbl), ty::TyRawPtr(ref mt) => UnsafePtr(mt.mutbl),
ty::TyRef(r, mt) => { ty::TyRef(r, _, mutbl) => {
let bk = ty::BorrowKind::from_mutbl(mt.mutbl); let bk = ty::BorrowKind::from_mutbl(mutbl);
if implicit { Implicit(bk, r) } else { BorrowedPtr(bk, r) } if implicit { Implicit(bk, r) } else { BorrowedPtr(bk, r) }
} }
ref ty => bug!("unexpected type in cat_deref: {:?}", ty) ref ty => bug!("unexpected type in cat_deref: {:?}", ty)

View file

@ -29,7 +29,6 @@ use mir::interpret::{Value, PrimVal, EvalErrorKind};
use ty::subst::{Subst, Substs}; use ty::subst::{Subst, Substs};
use ty::{self, AdtDef, CanonicalTy, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt}; use ty::{self, AdtDef, CanonicalTy, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use ty::TypeAndMut;
use util::ppaux; use util::ppaux;
use std::slice; use std::slice;
use hir::{self, InlineAsm}; use hir::{self, InlineAsm};
@ -1905,9 +1904,8 @@ pub fn print_miri_value<W: Write>(value: Value, ty: Ty, f: &mut W) -> fmt::Resul
write!(f, "{:?}", ::std::char::from_u32(n as u32).unwrap()), write!(f, "{:?}", ::std::char::from_u32(n as u32).unwrap()),
(Value::ByVal(PrimVal::Undef), &TyFnDef(did, _)) => (Value::ByVal(PrimVal::Undef), &TyFnDef(did, _)) =>
write!(f, "{}", item_path_str(did)), write!(f, "{}", item_path_str(did)),
(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(len)), &TyRef(_, TypeAndMut { (Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(len)),
ty: &ty::TyS { sty: TyStr, .. }, .. &TyRef(_, &ty::TyS { sty: TyStr, .. }, _)) => {
})) => {
ty::tls::with(|tcx| { ty::tls::with(|tcx| {
let alloc = tcx let alloc = tcx
.interpret_interner .interpret_interner

View file

@ -878,9 +878,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut trait_type = trait_ref.self_ty(); let mut trait_type = trait_ref.self_ty();
for refs_remaining in 0..refs_number { for refs_remaining in 0..refs_number {
if let ty::TypeVariants::TyRef(_, ty::TypeAndMut{ ty: t_type, mutbl: _ }) = if let ty::TypeVariants::TyRef(_, t_type, _) = trait_type.sty {
trait_type.sty {
trait_type = t_type; trait_type = t_type;
let substs = self.tcx.mk_substs_trait(trait_type, &[]); let substs = self.tcx.mk_substs_trait(trait_type, &[]);

View file

@ -2167,14 +2167,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
ty::TyChar | ty::TyRawPtr(..) | ty::TyNever | ty::TyChar | ty::TyRawPtr(..) | ty::TyNever |
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { ty::TyRef(_, _, hir::MutImmutable) => {
// Implementations provided in libcore // Implementations provided in libcore
None None
} }
ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) |
ty::TyGenerator(..) | ty::TyGeneratorWitness(..) | ty::TyForeign(..) | ty::TyGenerator(..) | ty::TyGeneratorWitness(..) | ty::TyForeign(..) |
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { ty::TyRef(_, _, hir::MutMutable) => {
Never Never
} }
@ -2263,7 +2263,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
} }
ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) | ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) |
ty::TyRef(_, ty::TypeAndMut { ty: element_ty, ..}) => { ty::TyRef(_, element_ty, _) => {
vec![element_ty] vec![element_ty]
}, },

View file

@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
/// Function Pointers /// Function Pointers
FnPtr, FnPtr,
/// Raw pointers /// Raw pointers
Ptr(&'tcx ty::TypeAndMut<'tcx>), Ptr(ty::TypeAndMut<'tcx>),
/// References /// References
RPtr(&'tcx ty::TypeAndMut<'tcx>), RPtr(ty::TypeAndMut<'tcx>),
} }
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs) /// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
@ -69,8 +69,8 @@ impl<'tcx> CastTy<'tcx> {
ty::TyFloat(_) => Some(CastTy::Float), ty::TyFloat(_) => Some(CastTy::Float),
ty::TyAdt(d,_) if d.is_enum() && d.is_payloadfree() => ty::TyAdt(d,_) if d.is_enum() && d.is_payloadfree() =>
Some(CastTy::Int(IntTy::CEnum)), Some(CastTy::Int(IntTy::CEnum)),
ty::TyRawPtr(ref mt) => Some(CastTy::Ptr(mt)), ty::TyRawPtr(mt) => Some(CastTy::Ptr(mt)),
ty::TyRef(_, ref mt) => Some(CastTy::RPtr(mt)), ty::TyRef(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })),
ty::TyFnPtr(..) => Some(CastTy::FnPtr), ty::TyFnPtr(..) => Some(CastTy::FnPtr),
_ => None, _ => None,
} }

View file

@ -2351,7 +2351,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> { pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
self.mk_ty(TyRef(r, tm)) self.mk_ty(TyRef(r, tm.ty, tm.mutbl))
} }
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {

View file

@ -189,20 +189,17 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
} }
ty::TySlice(_) => "slice".to_string(), ty::TySlice(_) => "slice".to_string(),
ty::TyRawPtr(_) => "*-ptr".to_string(), ty::TyRawPtr(_) => "*-ptr".to_string(),
ty::TyRef(region, tymut) => { ty::TyRef(region, ty, mutbl) => {
let tymut = ty::TypeAndMut { ty, mutbl };
let tymut_string = tymut.to_string(); let tymut_string = tymut.to_string();
if tymut_string == "_" || //unknown type name, if tymut_string == "_" || //unknown type name,
tymut_string.len() > 10 || //name longer than saying "reference", tymut_string.len() > 10 || //name longer than saying "reference",
region.to_string() != "" //... or a complex type region.to_string() != "" //... or a complex type
{ {
match tymut { format!("{}reference", match mutbl {
ty::TypeAndMut{mutbl, ..} => { hir::Mutability::MutMutable => "mutable ",
format!("{}reference", match mutbl { _ => ""
hir::Mutability::MutMutable => "mutable ", })
_ => ""
})
}
}
} else { } else {
format!("&{}", tymut_string) format!("&{}", tymut_string)
} }

View file

@ -80,11 +80,11 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
ty::TyDynamic(ref trait_info, ..) => { ty::TyDynamic(ref trait_info, ..) => {
trait_info.principal().map(|p| TraitSimplifiedType(p.def_id())) trait_info.principal().map(|p| TraitSimplifiedType(p.def_id()))
} }
ty::TyRef(_, mt) => { ty::TyRef(_, ty, _) => {
// since we introduce auto-refs during method lookup, we // since we introduce auto-refs during method lookup, we
// just treat &T and T as equivalent from the point of // just treat &T and T as equivalent from the point of
// view of possibly unifying // view of possibly unifying
simplify_type(tcx, mt.ty, can_simplify_params) simplify_type(tcx, ty, can_simplify_params)
} }
ty::TyFnDef(def_id, _) | ty::TyFnDef(def_id, _) |
ty::TyClosure(def_id, _) => { ty::TyClosure(def_id, _) => {

View file

@ -173,9 +173,9 @@ impl FlagComputation {
self.add_ty(m.ty); self.add_ty(m.ty);
} }
&ty::TyRef(r, ref m) => { &ty::TyRef(r, ty, _) => {
self.add_region(r); self.add_region(r);
self.add_ty(m.ty); self.add_ty(ty);
} }
&ty::TyTuple(ref ts) => { &ty::TyTuple(ref ts) => {

View file

@ -269,8 +269,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
_ => DefIdForest::empty() _ => DefIdForest::empty()
} }
} }
TyRef(_, ref tm) => { TyRef(_, ty, _) => {
tm.ty.uninhabited_from(visited, tcx) ty.uninhabited_from(visited, tcx)
} }
_ => DefIdForest::empty(), _ => DefIdForest::empty(),

View file

@ -360,8 +360,9 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
ty::TyArray(subty, _) | ty::TyArray(subty, _) |
ty::TySlice(subty) => characteristic_def_id_of_type(subty), ty::TySlice(subty) => characteristic_def_id_of_type(subty),
ty::TyRawPtr(mt) | ty::TyRawPtr(mt) => characteristic_def_id_of_type(mt.ty),
ty::TyRef(_, mt) => characteristic_def_id_of_type(mt.ty),
ty::TyRef(_, ty, _) => characteristic_def_id_of_type(ty),
ty::TyTuple(ref tys) => tys.iter() ty::TyTuple(ref tys) => tys.iter()
.filter_map(|ty| characteristic_def_id_of_type(ty)) .filter_map(|ty| characteristic_def_id_of_type(ty))

View file

@ -501,7 +501,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
} }
// Potentially-fat pointers. // Potentially-fat pointers.
ty::TyRef(_, ty::TypeAndMut { ty: pointee, .. }) | ty::TyRef(_, pointee, _) |
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
let mut data_ptr = scalar_unit(Pointer); let mut data_ptr = scalar_unit(Pointer);
if !ty.is_unsafe_ptr() { if !ty.is_unsafe_ptr() {
@ -1262,7 +1262,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
}; };
match ty.sty { match ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty: pointee, .. }) | ty::TyRef(_, pointee, _) |
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
let non_zero = !ty.is_unsafe_ptr(); let non_zero = !ty.is_unsafe_ptr();
let tail = tcx.struct_tail(pointee); let tail = tcx.struct_tail(pointee);
@ -1560,7 +1560,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
} }
// Potentially-fat pointers. // Potentially-fat pointers.
ty::TyRef(_, ty::TypeAndMut { ty: pointee, .. }) | ty::TyRef(_, pointee, _) |
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
assert!(i < 2); assert!(i < 2);

View file

@ -514,7 +514,7 @@ impl<'tcx> TyS<'tcx> {
TypeVariants::TyInfer(InferTy::FloatVar(_)) | TypeVariants::TyInfer(InferTy::FloatVar(_)) |
TypeVariants::TyInfer(InferTy::FreshIntTy(_)) | TypeVariants::TyInfer(InferTy::FreshIntTy(_)) |
TypeVariants::TyInfer(InferTy::FreshFloatTy(_)) => true, TypeVariants::TyInfer(InferTy::FreshFloatTy(_)) => true,
TypeVariants::TyRef(_, x) => x.ty.is_primitive_ty(), TypeVariants::TyRef(_, x, _) => x.is_primitive_ty(),
_ => false, _ => false,
} }
} }

View file

@ -454,10 +454,12 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
Ok(tcx.mk_ptr(mt)) Ok(tcx.mk_ptr(mt))
} }
(&ty::TyRef(a_r, ref a_mt), &ty::TyRef(b_r, ref b_mt)) => (&ty::TyRef(a_r, a_ty, a_mutbl), &ty::TyRef(b_r, b_ty, b_mutbl)) =>
{ {
let r = relation.relate_with_variance(ty::Contravariant, &a_r, &b_r)?; let r = relation.relate_with_variance(ty::Contravariant, &a_r, &b_r)?;
let mt = relation.relate(a_mt, b_mt)?; let a_mt = ty::TypeAndMut { ty: a_ty, mutbl: a_mutbl };
let b_mt = ty::TypeAndMut { ty: b_ty, mutbl: b_mutbl };
let mt = relation.relate(&a_mt, &b_mt)?;
Ok(tcx.mk_ref(r, mt)) Ok(tcx.mk_ref(r, mt))
} }

View file

@ -864,8 +864,8 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::TyFnDef(def_id, substs.fold_with(folder)) ty::TyFnDef(def_id, substs.fold_with(folder))
} }
ty::TyFnPtr(f) => ty::TyFnPtr(f.fold_with(folder)), ty::TyFnPtr(f) => ty::TyFnPtr(f.fold_with(folder)),
ty::TyRef(ref r, tm) => { ty::TyRef(ref r, ty, mutbl) => {
ty::TyRef(r.fold_with(folder), tm.fold_with(folder)) ty::TyRef(r.fold_with(folder), ty.fold_with(folder), mutbl)
} }
ty::TyGenerator(did, substs, movability) => { ty::TyGenerator(did, substs, movability) => {
ty::TyGenerator( ty::TyGenerator(
@ -904,7 +904,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::TyTuple(ts) => ts.visit_with(visitor), ty::TyTuple(ts) => ts.visit_with(visitor),
ty::TyFnDef(_, substs) => substs.visit_with(visitor), ty::TyFnDef(_, substs) => substs.visit_with(visitor),
ty::TyFnPtr(ref f) => f.visit_with(visitor), ty::TyFnPtr(ref f) => f.visit_with(visitor),
ty::TyRef(r, ref tm) => r.visit_with(visitor) || tm.visit_with(visitor), ty::TyRef(r, ty, _) => r.visit_with(visitor) || ty.visit_with(visitor),
ty::TyGenerator(_did, ref substs, _) => { ty::TyGenerator(_did, ref substs, _) => {
substs.visit_with(visitor) substs.visit_with(visitor)
} }

View file

@ -121,7 +121,7 @@ pub enum TypeVariants<'tcx> {
/// A reference; a pointer with an associated lifetime. Written as /// A reference; a pointer with an associated lifetime. Written as
/// `&'a mut T` or `&'a T`. /// `&'a mut T` or `&'a T`.
TyRef(Region<'tcx>, TypeAndMut<'tcx>), TyRef(Region<'tcx>, Ty<'tcx>, hir::Mutability),
/// The anonymous type of a function declaration/definition. Each /// The anonymous type of a function declaration/definition. Each
/// function has a unique type. /// function has a unique type.
@ -1392,7 +1392,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
pub fn is_slice(&self) -> bool { pub fn is_slice(&self) -> bool {
match self.sty { match self.sty {
TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty { TyRawPtr(TypeAndMut { ty, .. }) | TyRef(_, ty, _) => match ty.sty {
TySlice(_) | TyStr => true, TySlice(_) | TyStr => true,
_ => false, _ => false,
}, },
@ -1441,11 +1441,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
pub fn is_mutable_pointer(&self) -> bool { pub fn is_mutable_pointer(&self) -> bool {
match self.sty { match self.sty {
TyRawPtr(tnm) | TyRef(_, tnm) => if let hir::Mutability::MutMutable = tnm.mutbl { TyRawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) |
true TyRef(_, _, hir::Mutability::MutMutable) => true,
} else {
false
},
_ => false _ => false
} }
} }
@ -1598,7 +1595,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
mutbl: hir::MutImmutable, mutbl: hir::MutImmutable,
}) })
}, },
TyRef(_, mt) => Some(mt), TyRef(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl }),
TyRawPtr(mt) if explicit => Some(mt), TyRawPtr(mt) if explicit => Some(mt),
_ => None, _ => None,
} }
@ -1652,7 +1649,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
/// ignores late-bound regions binders. /// ignores late-bound regions binders.
pub fn regions(&self) -> Vec<ty::Region<'tcx>> { pub fn regions(&self) -> Vec<ty::Region<'tcx>> {
match self.sty { match self.sty {
TyRef(region, _) => { TyRef(region, _, _) => {
vec![region] vec![region]
} }
TyDynamic(ref obj, region) => { TyDynamic(ref obj, region) => {

View file

@ -201,7 +201,7 @@ impl<'tcx> ty::ParamEnv<'tcx> {
// Now libcore provides that impl. // Now libcore provides that impl.
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
ty::TyChar | ty::TyRawPtr(..) | ty::TyNever | ty::TyChar | ty::TyRawPtr(..) | ty::TyNever |
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => return Ok(()), ty::TyRef(_, _, hir::MutImmutable) => return Ok(()),
ty::TyAdt(adt, substs) => (adt, substs), ty::TyAdt(adt, substs) => (adt, substs),
@ -664,8 +664,8 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W>
_ => bug!("arrays should not have {:?} as length", n) _ => bug!("arrays should not have {:?} as length", n)
} }
} }
TyRawPtr(m) | TyRawPtr(m) => self.hash(m.mutbl),
TyRef(_, m) => self.hash(m.mutbl), TyRef(_, _, mutbl) => self.hash(mutbl),
TyClosure(def_id, _) | TyClosure(def_id, _) |
TyGenerator(def_id, _, _) | TyGenerator(def_id, _, _) |
TyAnon(def_id, _) | TyAnon(def_id, _) |
@ -1141,7 +1141,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
match self_arg_ty.sty { match self_arg_ty.sty {
_ if is_self_ty(self_arg_ty) => ByValue, _ if is_self_ty(self_arg_ty) => ByValue,
ty::TyRef(region, ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => { ty::TyRef(region, ty, mutbl) if is_self_ty(ty) => {
ByReference(region, mutbl) ByReference(region, mutbl)
} }
ty::TyRawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => { ty::TyRawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => {

View file

@ -92,9 +92,12 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
ty::TySlice(ty) => { ty::TySlice(ty) => {
stack.push(ty); stack.push(ty);
} }
ty::TyRawPtr(ref mt) | ty::TyRef(_, ref mt) => { ty::TyRawPtr(ref mt) => {
stack.push(mt.ty); stack.push(mt.ty);
} }
ty::TyRef(_, ty, _) => {
stack.push(ty);
}
ty::TyProjection(ref data) => { ty::TyProjection(ref data) => {
stack.extend(data.substs.types().rev()); stack.extend(data.substs.types().rev());
} }

View file

@ -298,9 +298,9 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
self.out.extend(obligations); self.out.extend(obligations);
} }
ty::TyRef(r, mt) => { ty::TyRef(r, rty, _) => {
// WfReference // WfReference
if !r.has_escaping_regions() && !mt.ty.has_escaping_regions() { if !r.has_escaping_regions() && !rty.has_escaping_regions() {
let cause = self.cause(traits::ReferenceOutlivesReferent(ty)); let cause = self.cause(traits::ReferenceOutlivesReferent(ty));
self.out.push( self.out.push(
traits::Obligation::new( traits::Obligation::new(
@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
param_env, param_env,
ty::Predicate::TypeOutlives( ty::Predicate::TypeOutlives(
ty::Binder::dummy( ty::Binder::dummy(
ty::OutlivesPredicate(mt.ty, r))))); ty::OutlivesPredicate(rty, r)))));
} }
} }

View file

@ -1011,14 +1011,14 @@ define_print! {
})?; })?;
tm.ty.print(f, cx) tm.ty.print(f, cx)
} }
TyRef(r, ref tm) => { TyRef(r, ty, mutbl) => {
write!(f, "&")?; write!(f, "&")?;
let s = r.print_to_string(cx); let s = r.print_to_string(cx);
write!(f, "{}", s)?; write!(f, "{}", s)?;
if !s.is_empty() { if !s.is_empty() {
write!(f, " ")?; write!(f, " ")?;
} }
tm.print(f, cx) ty::TypeAndMut { ty, mutbl }.print(f, cx)
} }
TyNever => write!(f, "!"), TyNever => write!(f, "!"),
TyTuple(ref tys) => { TyTuple(ref tys) => {

View file

@ -1173,9 +1173,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
consider instead using an UnsafeCell"; consider instead using an UnsafeCell";
match get_transmute_from_to(cx, expr) { match get_transmute_from_to(cx, expr) {
Some((&ty::TyRef(_, from_mt), &ty::TyRef(_, to_mt))) => { Some((&ty::TyRef(_, _, from_mt), &ty::TyRef(_, _, to_mt))) => {
if to_mt.mutbl == hir::Mutability::MutMutable && if to_mt == hir::Mutability::MutMutable &&
from_mt.mutbl == hir::Mutability::MutImmutable { from_mt == hir::Mutability::MutImmutable {
cx.span_lint(MUTABLE_TRANSMUTES, expr.span, msg); cx.span_lint(MUTABLE_TRANSMUTES, expr.span, msg);
} }
} }

View file

@ -662,8 +662,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
help: Some("consider using a struct instead"), help: Some("consider using a struct instead"),
}, },
ty::TyRawPtr(ref m) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
ty::TyRef(_, ref m) => self.check_type_for_ffi(cache, m.ty), ty::TyRef(_, ty, _) => self.check_type_for_ffi(cache, ty),
ty::TyArray(ty, _) => self.check_type_for_ffi(cache, ty), ty::TyArray(ty, _) => self.check_type_for_ffi(cache, ty),

View file

@ -773,8 +773,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
format!("{}", def.non_enum_variant().fields[field.index()].name) format!("{}", def.non_enum_variant().fields[field.index()].name)
}, },
ty::TyTuple(_) => format!("{}", field.index()), ty::TyTuple(_) => format!("{}", field.index()),
ty::TyRef(_, tnm) | ty::TyRawPtr(tnm) => { ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => {
self.describe_field_from_ty(&tnm.ty, field) self.describe_field_from_ty(&ty, field)
} }
ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field), ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field),
ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => {

View file

@ -1913,8 +1913,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
// Check the kind of deref to decide // Check the kind of deref to decide
match base_ty.sty { match base_ty.sty {
ty::TyRef(_, tnm) => { ty::TyRef(_, _, mutbl) => {
match tnm.mutbl { match mutbl {
// Shared borrowed data is never mutable // Shared borrowed data is never mutable
hir::MutImmutable => Err(place), hir::MutImmutable => Err(place),
// Mutably borrowed data is mutable, but only if we have a // Mutably borrowed data is mutable, but only if we have a
@ -2348,13 +2348,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
} }
( (
ProjectionElem::Deref, ProjectionElem::Deref,
ty::TyRef( ty::TyRef( _, _, hir::MutImmutable),
_,
ty::TypeAndMut {
ty: _,
mutbl: hir::MutImmutable,
},
),
_, _,
) => { ) => {
// the borrow goes through a dereference of a shared reference. // the borrow goes through a dereference of a shared reference.

View file

@ -270,7 +270,7 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
debug!("add_reborrow_constraint - base_ty = {:?}", base_ty); debug!("add_reborrow_constraint - base_ty = {:?}", base_ty);
match base_ty.sty { match base_ty.sty {
ty::TyRef(ref_region, ty::TypeAndMut { ty: _, mutbl }) => { ty::TyRef(ref_region, _, mutbl) => {
let span = self.mir.source_info(location).span; let span = self.mir.source_info(location).span;
self.regioncx.add_outlives( self.regioncx.add_outlives(
span, span,

View file

@ -156,10 +156,8 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
ty::TyRawPtr(_) | ty::TyRawPtr(_) |
ty::TyRef( ty::TyRef(
_, /*rgn*/ _, /*rgn*/
ty::TypeAndMut { _, /*ty*/
ty: _, hir::MutImmutable
mutbl: hir::MutImmutable,
},
) => { ) => {
// don't continue traversing over derefs of raw pointers or shared borrows. // don't continue traversing over derefs of raw pointers or shared borrows.
self.next = None; self.next = None;
@ -168,10 +166,8 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
ty::TyRef( ty::TyRef(
_, /*rgn*/ _, /*rgn*/
ty::TypeAndMut { _, /*ty*/
ty: _, hir::MutMutable,
mutbl: hir::MutMutable,
},
) => { ) => {
self.next = Some(&proj.base); self.next = Some(&proj.base);
return Some(cursor); return Some(cursor);

View file

@ -276,7 +276,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
// array, so we can call `<[u8]>::eq` rather than having to find an // array, so we can call `<[u8]>::eq` rather than having to find an
// `<[u8; N]>::eq`. // `<[u8; N]>::eq`.
let unsize = |ty: Ty<'tcx>| match ty.sty { let unsize = |ty: Ty<'tcx>| match ty.sty {
ty::TyRef(region, tam) => match tam.ty.sty { ty::TyRef(region, rty, _) => match rty.sty {
ty::TyArray(inner_ty, n) => Some((region, inner_ty, n)), ty::TyArray(inner_ty, n) => Some((region, inner_ty, n)),
_ => None, _ => None,
}, },

View file

@ -283,7 +283,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
hir::ExprAddrOf(mutbl, ref expr) => { hir::ExprAddrOf(mutbl, ref expr) => {
let region = match expr_ty.sty { let region = match expr_ty.sty {
ty::TyRef(r, _) => r, ty::TyRef(r, _, _) => r,
_ => span_bug!(expr.span, "type of & not region"), _ => span_bug!(expr.span, "type of & not region"),
}; };
ExprKind::Borrow { ExprKind::Borrow {
@ -987,13 +987,13 @@ fn overloaded_place<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
// Reconstruct the output assuming it's a reference with the // Reconstruct the output assuming it's a reference with the
// same region and mutability as the receiver. This holds for // same region and mutability as the receiver. This holds for
// `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`. // `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`.
let (region, mt) = match recv_ty.sty { let (region, mutbl) = match recv_ty.sty {
ty::TyRef(region, mt) => (region, mt), ty::TyRef(region, _, mutbl) => (region, mutbl),
_ => span_bug!(expr.span, "overloaded_place: receiver is not a reference"), _ => span_bug!(expr.span, "overloaded_place: receiver is not a reference"),
}; };
let ref_ty = cx.tcx.mk_ref(region, ty::TypeAndMut { let ref_ty = cx.tcx.mk_ref(region, ty::TypeAndMut {
ty: place_ty, ty: place_ty,
mutbl: mt.mutbl, mutbl,
}); });
// construct the complete expression `foo()` for the overloaded call, // construct the complete expression `foo()` for the overloaded call,

View file

@ -46,13 +46,13 @@ struct LiteralExpander;
impl<'tcx> PatternFolder<'tcx> for LiteralExpander { impl<'tcx> PatternFolder<'tcx> for LiteralExpander {
fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> { fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
match (&pat.ty.sty, &*pat.kind) { match (&pat.ty.sty, &*pat.kind) {
(&ty::TyRef(_, mt), &PatternKind::Constant { ref value }) => { (&ty::TyRef(_, rty, _), &PatternKind::Constant { ref value }) => {
Pattern { Pattern {
ty: pat.ty, ty: pat.ty,
span: pat.span, span: pat.span,
kind: box PatternKind::Deref { kind: box PatternKind::Deref {
subpattern: Pattern { subpattern: Pattern {
ty: mt.ty, ty: rty,
span: pat.span, span: pat.span,
kind: box PatternKind::Constant { value: value.clone() }, kind: box PatternKind::Constant { value: value.clone() },
} }
@ -907,7 +907,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
ConstantValue(_) => vec![], ConstantValue(_) => vec![],
_ => bug!("bad slice pattern {:?} {:?}", ctor, ty) _ => bug!("bad slice pattern {:?} {:?}", ctor, ty)
}, },
ty::TyRef(_, ref ty_and_mut) => vec![ty_and_mut.ty], ty::TyRef(_, rty, _) => vec![rty],
ty::TyAdt(adt, substs) => { ty::TyAdt(adt, substs) => {
if adt.is_box() { if adt.is_box() {
// Use T as the sub pattern type of Box<T>. // Use T as the sub pattern type of Box<T>.

View file

@ -238,9 +238,9 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
PatternKind::Deref { ref subpattern } => { PatternKind::Deref { ref subpattern } => {
match self.ty.sty { match self.ty.sty {
ty::TyAdt(def, _) if def.is_box() => write!(f, "box ")?, ty::TyAdt(def, _) if def.is_box() => write!(f, "box ")?,
ty::TyRef(_, mt) => { ty::TyRef(_, _, mutbl) => {
write!(f, "&")?; write!(f, "&")?;
if mt.mutbl == hir::MutMutable { if mutbl == hir::MutMutable {
write!(f, "mut ")?; write!(f, "mut ")?;
} }
} }
@ -424,13 +424,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatKind::Slice(ref prefix, ref slice, ref suffix) => { PatKind::Slice(ref prefix, ref slice, ref suffix) => {
let ty = self.tables.node_id_to_type(pat.hir_id); let ty = self.tables.node_id_to_type(pat.hir_id);
match ty.sty { match ty.sty {
ty::TyRef(_, mt) => ty::TyRef(_, ty, _) =>
PatternKind::Deref { PatternKind::Deref {
subpattern: Pattern { subpattern: Pattern {
ty: mt.ty, ty,
span: pat.span, span: pat.span,
kind: Box::new(self.slice_or_array_pattern( kind: Box::new(self.slice_or_array_pattern(
pat.span, mt.ty, prefix, slice, suffix)) pat.span, ty, prefix, slice, suffix))
}, },
}, },
@ -469,7 +469,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatKind::Binding(_, id, ref name, ref sub) => { PatKind::Binding(_, id, ref name, ref sub) => {
let var_ty = self.tables.node_id_to_type(pat.hir_id); let var_ty = self.tables.node_id_to_type(pat.hir_id);
let region = match var_ty.sty { let region = match var_ty.sty {
ty::TyRef(r, _) => Some(r), ty::TyRef(r, _, _) => Some(r),
_ => None, _ => None,
}; };
let bm = *self.tables.pat_binding_modes().get(pat.hir_id) let bm = *self.tables.pat_binding_modes().get(pat.hir_id)
@ -490,8 +490,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
// A ref x pattern is the same node used for x, and as such it has // A ref x pattern is the same node used for x, and as such it has
// x's type, which is &T, where we want T (the type being matched). // x's type, which is &T, where we want T (the type being matched).
if let ty::BindByReference(_) = bm { if let ty::BindByReference(_) = bm {
if let ty::TyRef(_, mt) = ty.sty { if let ty::TyRef(_, rty, _) = ty.sty {
ty = mt.ty; ty = rty;
} else { } else {
bug!("`ref {}` has wrong type {}", name.node, ty); bug!("`ref {}` has wrong type {}", name.node, ty);
} }

View file

@ -7,7 +7,7 @@ use rustc::middle::const_val::{ConstVal, ErrKind};
use rustc::mir; use rustc::mir;
use rustc::ty::layout::{self, Size, Align, HasDataLayout, IntegerExt, LayoutOf, TyLayout}; use rustc::ty::layout::{self, Size, Align, HasDataLayout, IntegerExt, LayoutOf, TyLayout};
use rustc::ty::subst::{Subst, Substs}; use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::{self, Ty, TyCtxt, TypeAndMut};
use rustc::ty::maps::TyCtxtAt; use rustc::ty::maps::TyCtxtAt;
use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc::middle::const_val::FrameInfo; use rustc::middle::const_val::FrameInfo;
@ -775,8 +775,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
pub(super) fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool { pub(super) fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool {
match ty.sty { match ty.sty {
ty::TyRawPtr(ref tam) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
ty::TyRef(_, ref tam) => !self.type_is_sized(tam.ty), ty::TyRef(_, ty, _) => !self.type_is_sized(ty),
ty::TyAdt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()), ty::TyAdt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()),
_ => false, _ => false,
} }
@ -1259,8 +1259,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
ty::TyFnPtr(_) => PrimValKind::FnPtr, ty::TyFnPtr(_) => PrimValKind::FnPtr,
ty::TyRef(_, ref tam) | ty::TyRef(_, ty, _) |
ty::TyRawPtr(ref tam) if self.type_is_sized(tam.ty) => PrimValKind::Ptr, ty::TyRawPtr(ty::TypeAndMut { ty, .. }) if self.type_is_sized(ty) => {
PrimValKind::Ptr
}
ty::TyAdt(def, _) if def.is_box() => PrimValKind::Ptr, ty::TyAdt(def, _) if def.is_box() => PrimValKind::Ptr,
@ -1400,8 +1402,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
} }
ty::TyFnPtr(_) => self.memory.read_ptr_sized(ptr, ptr_align)?, ty::TyFnPtr(_) => self.memory.read_ptr_sized(ptr, ptr_align)?,
ty::TyRef(_, ref tam) | ty::TyRef(_, rty, _) |
ty::TyRawPtr(ref tam) => return self.read_ptr(ptr, ptr_align, tam.ty).map(Some), ty::TyRawPtr(ty::TypeAndMut { ty: rty, .. }) => {
return self.read_ptr(ptr, ptr_align, rty).map(Some)
}
ty::TyAdt(def, _) => { ty::TyAdt(def, _) => {
if def.is_box() { if def.is_box() {
@ -1501,10 +1505,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
dst_layout: TyLayout<'tcx>, dst_layout: TyLayout<'tcx>,
) -> EvalResult<'tcx> { ) -> EvalResult<'tcx> {
match (&src_layout.ty.sty, &dst_layout.ty.sty) { match (&src_layout.ty.sty, &dst_layout.ty.sty) {
(&ty::TyRef(_, ref s), &ty::TyRef(_, ref d)) | (&ty::TyRef(_, s, _), &ty::TyRef(_, d, _)) |
(&ty::TyRef(_, ref s), &ty::TyRawPtr(ref d)) | (&ty::TyRef(_, s, _), &ty::TyRawPtr(TypeAndMut { ty: d, .. })) |
(&ty::TyRawPtr(ref s), &ty::TyRawPtr(ref d)) => { (&ty::TyRawPtr(TypeAndMut { ty: s, .. }),
self.unsize_into_ptr(src, src_layout.ty, dst, dst_layout.ty, s.ty, d.ty) &ty::TyRawPtr(TypeAndMut { ty: d, .. })) => {
self.unsize_into_ptr(src, src_layout.ty, dst, dst_layout.ty, s, d)
} }
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => { (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => {
assert_eq!(def_a, def_b); assert_eq!(def_a, def_b);

View file

@ -369,8 +369,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
let val = self.read_place(base)?; let val = self.read_place(base)?;
let pointee_type = match base_ty.sty { let pointee_type = match base_ty.sty {
ty::TyRawPtr(ref tam) | ty::TyRawPtr(ref tam) => tam.ty,
ty::TyRef(_, ref tam) => tam.ty, ty::TyRef(_, ty, _) => ty,
ty::TyAdt(def, _) if def.is_box() => base_ty.boxed_ty(), ty::TyAdt(def, _) if def.is_box() => base_ty.boxed_ty(),
_ => bug!("can only deref pointer types"), _ => bug!("can only deref pointer types"),
}; };

View file

@ -199,7 +199,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
// mutability of raw pointers. // mutability of raw pointers.
// TODO: Should not be allowed when fat pointers are involved. // TODO: Should not be allowed when fat pointers are involved.
(&ty::TyRawPtr(_), &ty::TyRawPtr(_)) => true, (&ty::TyRawPtr(_), &ty::TyRawPtr(_)) => true,
(&ty::TyRef(_, _), &ty::TyRef(_, _)) => { (&ty::TyRef(_, _, _), &ty::TyRef(_, _, _)) => {
ty.is_mutable_pointer() == real_ty.is_mutable_pointer() ty.is_mutable_pointer() == real_ty.is_mutable_pointer()
} }
// rule out everything else // rule out everything else

View file

@ -844,9 +844,9 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}; };
match (&source_ty.sty, &target_ty.sty) { match (&source_ty.sty, &target_ty.sty) {
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), (&ty::TyRef(_, a, _),
&ty::TyRef(_, ty::TypeAndMut { ty: b, .. })) | &ty::TyRef(_, b, _)) |
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), (&ty::TyRef(_, a, _),
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) |
(&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }),
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => {

View file

@ -302,7 +302,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
self.push_type_name(inner_type, output); self.push_type_name(inner_type, output);
}, },
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => { ty::TyRef(_, inner_type, mutbl) => {
output.push('&'); output.push('&');
if mutbl == hir::MutMutable { if mutbl == hir::MutMutable {
output.push_str("mut "); output.push_str("mut ");

View file

@ -44,14 +44,14 @@ fn place_context<'a, 'tcx, D>(
// A Deref projection may restrict the context, this depends on the type // A Deref projection may restrict the context, this depends on the type
// being deref'd. // being deref'd.
let context = match ty.sty { let context = match ty.sty {
ty::TyRef(re, tam) => { ty::TyRef(re, _, mutbl) => {
let re = match re { let re = match re {
&RegionKind::ReScope(ce) => Some(ce), &RegionKind::ReScope(ce) => Some(ce),
&RegionKind::ReErased => &RegionKind::ReErased =>
bug!("AddValidation pass must be run before erasing lifetimes"), bug!("AddValidation pass must be run before erasing lifetimes"),
_ => None _ => None
}; };
(re, tam.mutbl) (re, mutbl)
} }
ty::TyRawPtr(_) => ty::TyRawPtr(_) =>
// There is no guarantee behind even a mutable raw pointer, // There is no guarantee behind even a mutable raw pointer,

View file

@ -228,9 +228,9 @@ pub fn unsize_thin_ptr<'a, 'tcx>(
) -> (ValueRef, ValueRef) { ) -> (ValueRef, ValueRef) {
debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty); debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty);
match (&src_ty.sty, &dst_ty.sty) { match (&src_ty.sty, &dst_ty.sty) {
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), (&ty::TyRef(_, a, _),
&ty::TyRef(_, ty::TypeAndMut { ty: b, .. })) | &ty::TyRef(_, b, _)) |
(&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), (&ty::TyRef(_, a, _),
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) |
(&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }),
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => {

View file

@ -555,7 +555,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
false) false)
} }
ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) |
ty::TyRef(_, ty::TypeAndMut{ty, ..}) => { ty::TyRef(_, ty, _) => {
match ptr_metadata(ty) { match ptr_metadata(ty) {
Ok(res) => res, Ok(res) => res,
Err(metadata) => return metadata, Err(metadata) => return metadata,

View file

@ -80,7 +80,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.push('*'); output.push('*');
} }
}, },
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => { ty::TyRef(_, inner_type, mutbl) => {
if !cpp_like_names { if !cpp_like_names {
output.push('&'); output.push('&');
} }

View file

@ -571,7 +571,8 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
// Or is it the closure environment? // Or is it the closure environment?
let (closure_layout, env_ref) = match arg.layout.ty.sty { let (closure_layout, env_ref) = match arg.layout.ty.sty {
ty::TyRef(_, mt) | ty::TyRawPtr(mt) => (bx.cx.layout_of(mt.ty), true), ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
ty::TyRef(_, ty, _) => (bx.cx.layout_of(ty), true),
_ => (arg.layout, false) _ => (arg.layout, false)
}; };
@ -615,8 +616,8 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
// a pointer in an alloca for debuginfo atm. // a pointer in an alloca for debuginfo atm.
let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] }; let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] };
let ty = if let (true, &ty::TyRef(_, mt)) = (decl.by_ref, &ty.sty) { let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
mt.ty ty
} else { } else {
ops = &ops[..ops.len() - 1]; ops = &ops[..ops.len() - 1];
ty ty

View file

@ -250,7 +250,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
return llty; return llty;
} }
let llty = match self.ty.sty { let llty = match self.ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) | ty::TyRef(_, ty, _) |
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => { ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => {
cx.layout_of(ty).llvm_type(cx).ptr_to() cx.layout_of(ty).llvm_type(cx).ptr_to()
} }
@ -418,11 +418,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
}); });
} }
ty::TyRef(_, mt) if offset.bytes() == 0 => { ty::TyRef(_, ty, mt) if offset.bytes() == 0 => {
let (size, align) = cx.size_and_align_of(mt.ty); let (size, align) = cx.size_and_align_of(ty);
let kind = match mt.mutbl { let kind = match mt {
hir::MutImmutable => if cx.type_is_freeze(mt.ty) { hir::MutImmutable => if cx.type_is_freeze(ty) {
PointerKind::Frozen PointerKind::Frozen
} else { } else {
PointerKind::Shared PointerKind::Shared

View file

@ -84,9 +84,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expected = loop { expected = loop {
debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty); debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty);
match exp_ty.sty { match exp_ty.sty {
ty::TypeVariants::TyRef(_, ty::TypeAndMut{ ty::TypeVariants::TyRef(_, inner_ty, inner_mutability) => {
ty: inner_ty, mutbl: inner_mutability,
}) => {
debug!("current discriminant is TyRef, inserting implicit deref"); debug!("current discriminant is TyRef, inserting implicit deref");
// Preserve the reference type. We'll need it later during HAIR lowering. // Preserve the reference type. We'll need it later during HAIR lowering.
pat_adjustments.push(exp_ty); pat_adjustments.push(exp_ty);
@ -152,8 +150,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let hir::ExprLit(ref lt) = lt.node { if let hir::ExprLit(ref lt) = lt.node {
if let ast::LitKind::ByteStr(_) = lt.node { if let ast::LitKind::ByteStr(_) = lt.node {
let expected_ty = self.structurally_resolved_type(pat.span, expected); let expected_ty = self.structurally_resolved_type(pat.span, expected);
if let ty::TyRef(_, mt) = expected_ty.sty { if let ty::TyRef(_, r_ty, _) = expected_ty.sty {
if let ty::TySlice(_) = mt.ty.sty { if let ty::TySlice(_) = r_ty.sty {
pat_ty = tcx.mk_imm_ref(tcx.types.re_static, pat_ty = tcx.mk_imm_ref(tcx.types.re_static,
tcx.mk_slice(tcx.types.u8)) tcx.mk_slice(tcx.types.u8))
} }
@ -334,8 +332,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// hack detailed in (*) below. // hack detailed in (*) below.
debug!("check_pat_walk: expected={:?}", expected); debug!("check_pat_walk: expected={:?}", expected);
let (rptr_ty, inner_ty) = match expected.sty { let (rptr_ty, inner_ty) = match expected.sty {
ty::TyRef(_, mt) if mt.mutbl == mutbl => { ty::TyRef(_, r_ty, r_mutbl) if r_mutbl == mutbl => {
(expected, mt.ty) (expected, r_ty)
} }
_ => { _ => {
let inner_ty = self.next_ty_var( let inner_ty = self.next_ty_var(
@ -408,7 +406,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
tcx.sess, pat.span, E0529, tcx.sess, pat.span, E0529,
"expected an array or slice, found `{}`", "expected an array or slice, found `{}`",
expected_ty); expected_ty);
if let ty::TyRef(_, ty::TypeAndMut { mutbl: _, ty }) = expected_ty.sty { if let ty::TyRef(_, ty, _) = expected_ty.sty {
match ty.sty { match ty.sty {
ty::TyArray(..) | ty::TySlice(..) => { ty::TyArray(..) | ty::TySlice(..) => {
err.help("the semantics of slice patterns changed \ err.help("the semantics of slice patterns changed \

View file

@ -177,10 +177,10 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
self.fcx.try_overloaded_deref(self.span, source, needs) self.fcx.try_overloaded_deref(self.span, source, needs)
.and_then(|InferOk { value: method, obligations: o }| { .and_then(|InferOk { value: method, obligations: o }| {
obligations.extend(o); obligations.extend(o);
if let ty::TyRef(region, mt) = method.sig.output().sty { if let ty::TyRef(region, _, mutbl) = method.sig.output().sty {
Some(OverloadedDeref { Some(OverloadedDeref {
region, region,
mutbl: mt.mutbl, mutbl,
}) })
} else { } else {
None None

View file

@ -175,8 +175,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let method = self.register_infer_ok_obligations(ok); let method = self.register_infer_ok_obligations(ok);
let mut autoref = None; let mut autoref = None;
if borrow { if borrow {
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty {
let mutbl = match mt.mutbl { let mutbl = match mutbl {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// For initial two-phase borrow // For initial two-phase borrow

View file

@ -46,7 +46,7 @@ use lint;
use rustc::hir; use rustc::hir;
use rustc::session::Session; use rustc::session::Session;
use rustc::traits; use rustc::traits;
use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::{self, Ty, TypeFoldable, TypeAndMut};
use rustc::ty::adjustment::AllowTwoPhase; use rustc::ty::adjustment::AllowTwoPhase;
use rustc::ty::cast::{CastKind, CastTy}; use rustc::ty::cast::{CastKind, CastTy};
use rustc::ty::subst::Substs; use rustc::ty::subst::Substs;
@ -319,7 +319,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fcx.resolve_type_vars_if_possible(&self.expr_ty), fcx.resolve_type_vars_if_possible(&self.expr_ty),
tstr); tstr);
match self.expr_ty.sty { match self.expr_ty.sty {
ty::TyRef(_, ty::TypeAndMut { mutbl: mt, .. }) => { ty::TyRef(_, _, mt) => {
let mtstr = match mt { let mtstr = match mt {
hir::MutMutable => "mut ", hir::MutMutable => "mut ",
hir::MutImmutable => "", hir::MutImmutable => "",
@ -511,8 +511,8 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fn check_ptr_ptr_cast(&self, fn check_ptr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>, fcx: &FnCtxt<'a, 'gcx, 'tcx>,
m_expr: &'tcx ty::TypeAndMut<'tcx>, m_expr: ty::TypeAndMut<'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>) m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> { -> Result<CastKind, CastError> {
debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast); debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast);
// ptr-ptr cast. vtables must match. // ptr-ptr cast. vtables must match.
@ -552,7 +552,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fn check_fptr_ptr_cast(&self, fn check_fptr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>, fcx: &FnCtxt<'a, 'gcx, 'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>) m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> { -> Result<CastKind, CastError> {
// fptr-ptr cast. must be to thin ptr // fptr-ptr cast. must be to thin ptr
@ -565,7 +565,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fn check_ptr_addr_cast(&self, fn check_ptr_addr_cast(&self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>, fcx: &FnCtxt<'a, 'gcx, 'tcx>,
m_expr: &'tcx ty::TypeAndMut<'tcx>) m_expr: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> { -> Result<CastKind, CastError> {
// ptr-addr cast. must be from thin ptr // ptr-addr cast. must be from thin ptr
@ -578,8 +578,8 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fn check_ref_cast(&self, fn check_ref_cast(&self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>, fcx: &FnCtxt<'a, 'gcx, 'tcx>,
m_expr: &'tcx ty::TypeAndMut<'tcx>, m_expr: ty::TypeAndMut<'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>) m_cast: ty::TypeAndMut<'tcx>)
-> Result<CastKind, CastError> { -> Result<CastKind, CastError> {
// array-ptr-cast. // array-ptr-cast.
@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
fn check_addr_ptr_cast(&self, fn check_addr_ptr_cast(&self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>, fcx: &FnCtxt<'a, 'gcx, 'tcx>,
m_cast: &'tcx ty::TypeAndMut<'tcx>) m_cast: TypeAndMut<'tcx>)
-> Result<CastKind, CastError> { -> Result<CastKind, CastError> {
// ptr-addr cast. pointer must be thin. // ptr-addr cast. pointer must be thin.
match fcx.pointer_kind(m_cast.ty, self.span)? { match fcx.pointer_kind(m_cast.ty, self.span)? {

View file

@ -214,7 +214,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
return self.coerce_unsafe_ptr(a, b, mt_b.mutbl); return self.coerce_unsafe_ptr(a, b, mt_b.mutbl);
} }
ty::TyRef(r_b, mt_b) => { ty::TyRef(r_b, ty, mutbl) => {
let mt_b = ty::TypeAndMut { ty, mutbl };
return self.coerce_borrowed_pointer(a, b, r_b, mt_b); return self.coerce_borrowed_pointer(a, b, r_b, mt_b);
} }
@ -266,7 +267,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
// yield. // yield.
let (r_a, mt_a) = match a.sty { let (r_a, mt_a) = match a.sty {
ty::TyRef(r_a, mt_a) => { ty::TyRef(r_a, ty, mutbl) => {
let mt_a = ty::TypeAndMut { ty, mutbl };
coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?; coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?;
(r_a, mt_a) (r_a, mt_a)
} }
@ -427,7 +429,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
// Now apply the autoref. We have to extract the region out of // Now apply the autoref. We have to extract the region out of
// the final ref type we got. // the final ref type we got.
let r_borrow = match ty.sty { let r_borrow = match ty.sty {
ty::TyRef(r_borrow, _) => r_borrow, ty::TyRef(r_borrow, _, _) => r_borrow,
_ => span_bug!(span, "expected a ref type, got {:?}", ty), _ => span_bug!(span, "expected a ref type, got {:?}", ty),
}; };
let mutbl = match mt_b.mutbl { let mutbl = match mt_b.mutbl {
@ -471,12 +473,12 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
// Handle reborrows before selecting `Source: CoerceUnsized<Target>`. // Handle reborrows before selecting `Source: CoerceUnsized<Target>`.
let reborrow = match (&source.sty, &target.sty) { let reborrow = match (&source.sty, &target.sty) {
(&ty::TyRef(_, mt_a), &ty::TyRef(_, mt_b)) => { (&ty::TyRef(_, ty_a, mutbl_a), &ty::TyRef(_, _, mutbl_b)) => {
coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?; coerce_mutbls(mutbl_a, mutbl_b)?;
let coercion = Coercion(self.cause.span); let coercion = Coercion(self.cause.span);
let r_borrow = self.next_region_var(coercion); let r_borrow = self.next_region_var(coercion);
let mutbl = match mt_b.mutbl { let mutbl = match mutbl_b {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// We don't allow two-phase borrows here, at least for initial // We don't allow two-phase borrows here, at least for initial
@ -487,26 +489,26 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
}; };
Some((Adjustment { Some((Adjustment {
kind: Adjust::Deref(None), kind: Adjust::Deref(None),
target: mt_a.ty target: ty_a
}, Adjustment { }, Adjustment {
kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)),
target: self.tcx.mk_ref(r_borrow, ty::TypeAndMut { target: self.tcx.mk_ref(r_borrow, ty::TypeAndMut {
mutbl: mt_b.mutbl, mutbl: mutbl_b,
ty: mt_a.ty ty: ty_a
}) })
})) }))
} }
(&ty::TyRef(_, mt_a), &ty::TyRawPtr(mt_b)) => { (&ty::TyRef(_, ty_a, mt_a), &ty::TyRawPtr(ty::TypeAndMut { mutbl: mt_b, .. })) => {
coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?; coerce_mutbls(mt_a, mt_b)?;
Some((Adjustment { Some((Adjustment {
kind: Adjust::Deref(None), kind: Adjust::Deref(None),
target: mt_a.ty target: ty_a
}, Adjustment { }, Adjustment {
kind: Adjust::Borrow(AutoBorrow::RawPtr(mt_b.mutbl)), kind: Adjust::Borrow(AutoBorrow::RawPtr(mt_b)),
target: self.tcx.mk_ptr(ty::TypeAndMut { target: self.tcx.mk_ptr(ty::TypeAndMut {
mutbl: mt_b.mutbl, mutbl: mt_b,
ty: mt_a.ty ty: ty_a
}) })
})) }))
} }
@ -719,7 +721,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b);
let (is_ref, mt_a) = match a.sty { let (is_ref, mt_a) = match a.sty {
ty::TyRef(_, mt) => (true, mt), ty::TyRef(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
ty::TyRawPtr(mt) => (false, mt), ty::TyRawPtr(mt) => (false, mt),
_ => { _ => {
return self.unify_and(a, b, identity); return self.unify_and(a, b, identity);
@ -886,12 +888,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. } Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }
] => { ] => {
match self.node_ty(expr.hir_id).sty { match self.node_ty(expr.hir_id).sty {
ty::TyRef(_, mt_orig) => { ty::TyRef(_, _, mt_orig) => {
let mutbl_adj: hir::Mutability = mutbl_adj.into(); let mutbl_adj: hir::Mutability = mutbl_adj.into();
// Reborrow that we can safely ignore, because // Reborrow that we can safely ignore, because
// the next adjustment can only be a Deref // the next adjustment can only be a Deref
// which will be merged into it. // which will be merged into it.
mutbl_adj == mt_orig.mutbl mutbl_adj == mt_orig
} }
_ => false, _ => false,
} }

View file

@ -216,7 +216,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expected: Ty<'tcx>) expected: Ty<'tcx>)
-> Option<(&'static str, String)> { -> Option<(&'static str, String)> {
match (&expected.sty, &checked_ty.sty) { match (&expected.sty, &checked_ty.sty) {
(&ty::TyRef(_, exp), &ty::TyRef(_, check)) => match (&exp.ty.sty, &check.ty.sty) { (&ty::TyRef(_, exp, _), &ty::TyRef(_, check, _)) => match (&exp.sty, &check.sty) {
(&ty::TyStr, &ty::TyArray(arr, _)) | (&ty::TyStr, &ty::TyArray(arr, _)) |
(&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => { (&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => {
if let hir::ExprLit(_) = expr.node { if let hir::ExprLit(_) = expr.node {
@ -241,7 +241,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} }
_ => None, _ => None,
}, },
(&ty::TyRef(_, mutability), _) => { (&ty::TyRef(_, _, mutability), _) => {
// Check if it can work when put into a ref. For example: // Check if it can work when put into a ref. For example:
// //
// ``` // ```
@ -250,7 +250,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// let x = 0u32; // let x = 0u32;
// bar(&x); // error, expected &mut // bar(&x); // error, expected &mut
// ``` // ```
let ref_ty = match mutability.mutbl { let ref_ty = match mutability {
hir::Mutability::MutMutable => self.tcx.mk_mut_ref( hir::Mutability::MutMutable => self.tcx.mk_mut_ref(
self.tcx.mk_region(ty::ReStatic), self.tcx.mk_region(ty::ReStatic),
checked_ty), checked_ty),
@ -266,7 +266,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::ExprCast(_, _) | hir::ExprBinary(_, _, _) => format!("({})", src), hir::ExprCast(_, _) | hir::ExprBinary(_, _, _) => format!("({})", src),
_ => src, _ => src,
}; };
return Some(match mutability.mutbl { return Some(match mutability {
hir::Mutability::MutMutable => { hir::Mutability::MutMutable => {
("consider mutably borrowing here", format!("&mut {}", sugg_expr)) ("consider mutably borrowing here", format!("&mut {}", sugg_expr))
} }
@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} }
None None
} }
(_, &ty::TyRef(_, checked)) => { (_, &ty::TyRef(_, checked, _)) => {
// We have `&T`, check if what was expected was `T`. If so, // We have `&T`, check if what was expected was `T`. If so,
// we may want to suggest adding a `*`, or removing // we may want to suggest adding a `*`, or removing
// a `&`. // a `&`.
@ -286,7 +286,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// (But, also check check the `expn_info()` to see if this is // (But, also check check the `expn_info()` to see if this is
// a macro; if so, it's hard to extract the text and make a good // a macro; if so, it's hard to extract the text and make a good
// suggestion, so don't bother.) // suggestion, so don't bother.)
if self.infcx.can_sub(self.param_env, checked.ty, &expected).is_ok() && if self.infcx.can_sub(self.param_env, checked, &expected).is_ok() &&
expr.span.ctxt().outer().expn_info().is_none() { expr.span.ctxt().outer().expn_info().is_none() {
match expr.node { match expr.node {
// Maybe remove `&`? // Maybe remove `&`?
@ -299,7 +299,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// Maybe add `*`? Only if `T: Copy`. // Maybe add `*`? Only if `T: Copy`.
_ => { _ => {
if !self.infcx.type_moves_by_default(self.param_env, if !self.infcx.type_moves_by_default(self.param_env,
checked.ty, checked,
expr.span) { expr.span) {
let sp = self.sess().codemap().call_span_if_macro(expr.span); let sp = self.sess().codemap().call_span_if_macro(expr.span);
if let Ok(code) = self.tcx.sess.codemap().span_to_snippet(sp) { if let Ok(code) = self.tcx.sess.codemap().span_to_snippet(sp) {

View file

@ -462,10 +462,10 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind { if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind {
if let Some(ok) = self.try_overloaded_deref(expr.span, source, needs) { if let Some(ok) = self.try_overloaded_deref(expr.span, source, needs) {
let method = self.register_infer_ok_obligations(ok); let method = self.register_infer_ok_obligations(ok);
if let ty::TyRef(region, mt) = method.sig.output().sty { if let ty::TyRef(region, _, mutbl) = method.sig.output().sty {
*deref = OverloadedDeref { *deref = OverloadedDeref {
region, region,
mutbl: mt.mutbl mutbl,
}; };
} }
} }
@ -521,8 +521,8 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
debug!("convert_place_op_to_mutable: method={:?}", method); debug!("convert_place_op_to_mutable: method={:?}", method);
self.write_method_call(expr.hir_id, method); self.write_method_call(expr.hir_id, method);
let (region, mutbl) = if let ty::TyRef(r, mt) = method.sig.inputs()[0].sty { let (region, mutbl) = if let ty::TyRef(r, _, mutbl) = method.sig.inputs()[0].sty {
(r, mt.mutbl) (r, mutbl)
} else { } else {
span_bug!(expr.span, "input to place op is not a ref?"); span_bug!(expr.span, "input to place op is not a ref?");
}; };

View file

@ -917,9 +917,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
pick.autoderefs = step.autoderefs; pick.autoderefs = step.autoderefs;
// Insert a `&*` or `&mut *` if this is a reference type: // Insert a `&*` or `&mut *` if this is a reference type:
if let ty::TyRef(_, mt) = step.self_ty.sty { if let ty::TyRef(_, _, mutbl) = step.self_ty.sty {
pick.autoderefs += 1; pick.autoderefs += 1;
pick.autoref = Some(mt.mutbl); pick.autoref = Some(mutbl);
} }
pick pick

View file

@ -2393,8 +2393,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let method = self.register_infer_ok_obligations(ok); let method = self.register_infer_ok_obligations(ok);
let mut adjustments = autoderef.adjust_steps(needs); let mut adjustments = autoderef.adjust_steps(needs);
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { if let ty::TyRef(region, _, r_mutbl) = method.sig.inputs()[0].sty {
let mutbl = match mt.mutbl { let mutbl = match r_mutbl {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// Indexing can be desugared to a method call, // Indexing can be desugared to a method call,
@ -2407,7 +2407,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
adjustments.push(Adjustment { adjustments.push(Adjustment {
kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: self.tcx.mk_ref(region, ty::TypeAndMut { target: self.tcx.mk_ref(region, ty::TypeAndMut {
mutbl: mt.mutbl, mutbl: r_mutbl,
ty: adjusted_ty ty: adjusted_ty
}) })
}); });
@ -3615,8 +3615,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else if let Some(ok) = self.try_overloaded_deref( } else if let Some(ok) = self.try_overloaded_deref(
expr.span, oprnd_t, needs) { expr.span, oprnd_t, needs) {
let method = self.register_infer_ok_obligations(ok); let method = self.register_infer_ok_obligations(ok);
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty {
let mutbl = match mt.mutbl { let mutbl = match mutbl {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// (It shouldn't actually matter for unary ops whether // (It shouldn't actually matter for unary ops whether
@ -3660,14 +3660,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::ExprAddrOf(mutbl, ref oprnd) => { hir::ExprAddrOf(mutbl, ref oprnd) => {
let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| {
match ty.sty { match ty.sty {
ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => { ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => {
if self.is_place_expr(&oprnd) { if self.is_place_expr(&oprnd) {
// Places may legitimately have unsized types. // Places may legitimately have unsized types.
// For example, dereferences of a fat pointer and // For example, dereferences of a fat pointer and
// the last field of a struct can be unsized. // the last field of a struct can be unsized.
ExpectHasType(mt.ty) ExpectHasType(ty)
} else { } else {
Expectation::rvalue_hint(self, mt.ty) Expectation::rvalue_hint(self, ty)
} }
} }
_ => NoExpectation _ => NoExpectation

View file

@ -197,8 +197,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Ok(method) => { Ok(method) => {
let by_ref_binop = !op.node.is_by_value(); let by_ref_binop = !op.node.is_by_value();
if is_assign == IsAssign::Yes || by_ref_binop { if is_assign == IsAssign::Yes || by_ref_binop {
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty {
let mutbl = match mt.mutbl { let mutbl = match mutbl {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// Allow two-phase borrows for binops in initial deployment // Allow two-phase borrows for binops in initial deployment
@ -214,8 +214,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} }
} }
if by_ref_binop { if by_ref_binop {
if let ty::TyRef(region, mt) = method.sig.inputs()[1].sty { if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[1].sty {
let mutbl = match mt.mutbl { let mutbl = match mutbl {
hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutImmutable => AutoBorrowMutability::Immutable,
hir::MutMutable => AutoBorrowMutability::Mutable { hir::MutMutable => AutoBorrowMutability::Mutable {
// Allow two-phase borrows for binops in initial deployment // Allow two-phase borrows for binops in initial deployment
@ -262,12 +262,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
op.node.as_str(), op.node.as_str(),
lhs_ty); lhs_ty);
if let TypeVariants::TyRef(_, ref ty_mut) = lhs_ty.sty { if let TypeVariants::TyRef(_, rty, _) = lhs_ty.sty {
if { if {
!self.infcx.type_moves_by_default(self.param_env, !self.infcx.type_moves_by_default(self.param_env,
ty_mut.ty, rty,
lhs_expr.span) && lhs_expr.span) &&
self.lookup_op_method(ty_mut.ty, self.lookup_op_method(rty,
&[rhs_ty], &[rhs_ty],
Op::Binary(op, is_assign)) Op::Binary(op, is_assign))
.is_ok() .is_ok()
@ -341,8 +341,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// If this function returns true it means a note was printed, so we don't need // If this function returns true it means a note was printed, so we don't need
// to print the normal "implementation of `std::ops::Add` might be missing" note // to print the normal "implementation of `std::ops::Add` might be missing" note
match (&lhs_ty.sty, &rhs_ty.sty) { match (&lhs_ty.sty, &rhs_ty.sty) {
(&TyRef(_, ref l_ty), &TyRef(_, ref r_ty)) (&TyRef(_, l_ty, _), &TyRef(_, r_ty, _))
if l_ty.ty.sty == TyStr && r_ty.ty.sty == TyStr => { if l_ty.sty == TyStr && r_ty.sty == TyStr => {
err.span_label(expr.span, err.span_label(expr.span,
"`+` can't be used to concatenate two `&str` strings"); "`+` can't be used to concatenate two `&str` strings");
match codemap.span_to_snippet(lhs_expr.span) { match codemap.span_to_snippet(lhs_expr.span) {
@ -353,8 +353,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}; };
true true
} }
(&TyRef(_, ref l_ty), &TyAdt(..)) (&TyRef(_, l_ty, _), &TyAdt(..))
if l_ty.ty.sty == TyStr && &format!("{:?}", rhs_ty) == "std::string::String" => { if l_ty.sty == TyStr && &format!("{:?}", rhs_ty) == "std::string::String" => {
err.span_label(expr.span, err.span_label(expr.span,
"`+` can't be used to concatenate a `&str` with a `String`"); "`+` can't be used to concatenate a `&str` with a `String`");
match codemap.span_to_snippet(lhs_expr.span) { match codemap.span_to_snippet(lhs_expr.span) {

View file

@ -588,7 +588,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
// For overloaded derefs, base_ty is the input to `Deref::deref`, // For overloaded derefs, base_ty is the input to `Deref::deref`,
// but it's a reference type uing the same region as the output. // but it's a reference type uing the same region as the output.
let base_ty = self.resolve_expr_type_adjusted(base); let base_ty = self.resolve_expr_type_adjusted(base);
if let ty::TyRef(r_ptr, _) = base_ty.sty { if let ty::TyRef(r_ptr, _, _) = base_ty.sty {
self.mk_subregion_due_to_dereference(expr.span, expr_region, r_ptr); self.mk_subregion_due_to_dereference(expr.span, expr_region, r_ptr);
} }
@ -701,11 +701,11 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
from_ty, from_ty,
to_ty); to_ty);
match (&from_ty.sty, &to_ty.sty) { match (&from_ty.sty, &to_ty.sty) {
/*From:*/ (&ty::TyRef(from_r, ref from_mt), /*From:*/ (&ty::TyRef(from_r, from_ty, _),
/*To: */ &ty::TyRef(to_r, ref to_mt)) => { /*To: */ &ty::TyRef(to_r, to_ty, _)) => {
// Target cannot outlive source, naturally. // Target cannot outlive source, naturally.
self.sub_regions(infer::Reborrow(cast_expr.span), to_r, from_r); self.sub_regions(infer::Reborrow(cast_expr.span), to_r, from_r);
self.walk_cast(cast_expr, from_mt.ty, to_mt.ty); self.walk_cast(cast_expr, from_ty, to_ty);
} }
/*From:*/ (_, /*From:*/ (_,
@ -913,8 +913,8 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
self.ty_to_string(indexed_ty)); self.ty_to_string(indexed_ty));
let r_index_expr = ty::ReScope(region::Scope::Node(index_expr.hir_id.local_id)); let r_index_expr = ty::ReScope(region::Scope::Node(index_expr.hir_id.local_id));
if let ty::TyRef(r_ptr, mt) = indexed_ty.sty { if let ty::TyRef(r_ptr, r_ty, _) = indexed_ty.sty {
match mt.ty.sty { match r_ty.sty {
ty::TySlice(_) | ty::TyStr => { ty::TySlice(_) | ty::TyStr => {
self.sub_regions(infer::IndexSlice(index_expr.span), self.sub_regions(infer::IndexSlice(index_expr.span),
self.tcx.mk_region(r_index_expr), r_ptr); self.tcx.mk_region(r_index_expr), r_ptr);
@ -1086,7 +1086,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
id, mutbl, cmt_borrowed); id, mutbl, cmt_borrowed);
let rptr_ty = self.resolve_node_type(id); let rptr_ty = self.resolve_node_type(id);
if let ty::TyRef(r, _) = rptr_ty.sty { if let ty::TyRef(r, _, _) = rptr_ty.sty {
debug!("rptr_ty={}", rptr_ty); debug!("rptr_ty={}", rptr_ty);
self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed);
} }

View file

@ -172,7 +172,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
match tables.expr_ty_adjusted(&base).sty { match tables.expr_ty_adjusted(&base).sty {
// All valid indexing looks like this // All valid indexing looks like this
ty::TyRef(_, ty::TypeAndMut { ty: ref base_ty, .. }) => { ty::TyRef(_, base_ty, _) => {
let index_ty = tables.expr_ty_adjusted(&index); let index_ty = tables.expr_ty_adjusted(&index);
let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty); let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty);

View file

@ -223,12 +223,18 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
(mt_a.ty, mt_b.ty, unsize_trait, None) (mt_a.ty, mt_b.ty, unsize_trait, None)
}; };
let (source, target, trait_def_id, kind) = match (&source.sty, &target.sty) { let (source, target, trait_def_id, kind) = match (&source.sty, &target.sty) {
(&ty::TyRef(r_a, mt_a), &ty::TyRef(r_b, mt_b)) => { (&ty::TyRef(r_a, ty_a, mutbl_a), &ty::TyRef(r_b, ty_b, mutbl_b)) => {
infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a);
let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a };
let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b };
check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ref(r_b, ty)) check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ref(r_b, ty))
} }
(&ty::TyRef(_, mt_a), &ty::TyRawPtr(mt_b)) | (&ty::TyRef(_, ty_a, mutbl_a), &ty::TyRawPtr(mt_b)) => {
let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a };
check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty))
}
(&ty::TyRawPtr(mt_a), &ty::TyRawPtr(mt_b)) => { (&ty::TyRawPtr(mt_a), &ty::TyRawPtr(mt_b)) => {
check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty)) check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty))
} }

View file

@ -149,8 +149,8 @@ fn insert_required_predicates_to_be_wf<'tcx>(
// a predicate requirement of T: 'a (T outlives 'a). // a predicate requirement of T: 'a (T outlives 'a).
// //
// We also want to calculate potential predicates for the T // We also want to calculate potential predicates for the T
ty::TyRef(region, mt) => { ty::TyRef(region, rty, _) => {
insert_outlives_predicate(tcx, mt.ty.into(), region, required_predicates); insert_outlives_predicate(tcx, rty.into(), region, required_predicates);
} }
// For each TyAdt (struct/enum/union) type `Foo<'a, T>`, we // For each TyAdt (struct/enum/union) type `Foo<'a, T>`, we

View file

@ -272,10 +272,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
bug!("Unexpected closure type in variance computation"); bug!("Unexpected closure type in variance computation");
} }
ty::TyRef(region, ref mt) => { ty::TyRef(region, ty, mutbl) => {
let contra = self.contravariant(variance); let contra = self.contravariant(variance);
self.add_constraints_from_region(current, region, contra); self.add_constraints_from_region(current, region, contra);
self.add_constraints_from_mt(current, mt, variance); self.add_constraints_from_mt(current, &ty::TypeAndMut { ty, mutbl }, variance);
} }
ty::TyArray(typ, _) | ty::TyArray(typ, _) |

View file

@ -1484,7 +1484,7 @@ impl<'a, 'tcx> Clean<TyParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
for ty_s in trait_ref.input_types().skip(1) { for ty_s in trait_ref.input_types().skip(1) {
if let ty::TyTuple(ts) = ty_s.sty { if let ty::TyTuple(ts) = ty_s.sty {
for &ty_s in ts { for &ty_s in ts {
if let ty::TyRef(ref reg, _) = ty_s.sty { if let ty::TyRef(ref reg, _, _) = ty_s.sty {
if let &ty::RegionKind::ReLateBound(..) = *reg { if let &ty::RegionKind::ReLateBound(..) = *reg {
debug!(" hit an ReLateBound {:?}", reg); debug!(" hit an ReLateBound {:?}", reg);
if let Some(lt) = reg.clean(cx) { if let Some(lt) = reg.clean(cx) {
@ -2235,8 +2235,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
let self_arg_ty = *sig.input(0).skip_binder(); let self_arg_ty = *sig.input(0).skip_binder();
if self_arg_ty == self_ty { if self_arg_ty == self_ty {
decl.inputs.values[0].type_ = Generic(String::from("Self")); decl.inputs.values[0].type_ = Generic(String::from("Self"));
} else if let ty::TyRef(_, mt) = self_arg_ty.sty { } else if let ty::TyRef(_, ty, _) = self_arg_ty.sty {
if mt.ty == self_ty { if ty == self_ty {
match decl.inputs.values[0].type_ { match decl.inputs.values[0].type_ {
BorrowedRef{ref mut type_, ..} => { BorrowedRef{ref mut type_, ..} => {
**type_ = Generic(String::from("Self")) **type_ = Generic(String::from("Self"))
@ -2790,10 +2790,10 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
Array(box ty.clean(cx), n) Array(box ty.clean(cx), n)
} }
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)), ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
ty::TyRef(r, mt) => BorrowedRef { ty::TyRef(r, ty, mutbl) => BorrowedRef {
lifetime: r.clean(cx), lifetime: r.clean(cx),
mutability: mt.mutbl.clean(cx), mutability: mutbl.clean(cx),
type_: box mt.ty.clean(cx), type_: box ty.clean(cx),
}, },
ty::TyFnDef(..) | ty::TyFnDef(..) |
ty::TyFnPtr(_) => { ty::TyFnPtr(_) => {