ty: Add (but do not yet use) AutoBorrowObject option to adjustments
Note: some portions of this commit written by @Sodel-the-Vociferous (Daniel Ralston)
This commit is contained in:
parent
38357ebef4
commit
6f319812d6
|
@ -226,7 +226,10 @@ pub enum AutoRef {
|
|||
AutoBorrowFn(Region),
|
||||
|
||||
/// Convert from T to *T
|
||||
AutoUnsafe(ast::mutability)
|
||||
AutoUnsafe(ast::mutability),
|
||||
|
||||
/// Convert from @Trait/~Trait/&Trait to &Trait
|
||||
AutoBorrowObj(Region, ast::mutability),
|
||||
}
|
||||
|
||||
pub type ctxt = @ctxt_;
|
||||
|
@ -1004,7 +1007,13 @@ fn mk_t(cx: ctxt, st: sty) -> t {
|
|||
&ty_self(_) => flags |= has_self as uint,
|
||||
&ty_enum(_, ref substs) | &ty_struct(_, ref substs) |
|
||||
&ty_trait(_, ref substs, _, _, _) => {
|
||||
flags |= sflags(substs);
|
||||
flags |= sflags(substs);
|
||||
match st {
|
||||
ty_trait(_, _, RegionTraitStore(r), _, _) => {
|
||||
flags |= rflags(r);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
&ty_box(ref m) | &ty_uniq(ref m) | &ty_evec(ref m, _) |
|
||||
&ty_ptr(ref m) | &ty_unboxed_vec(ref m) => {
|
||||
|
@ -3009,6 +3018,10 @@ pub fn adjust_ty(cx: ctxt,
|
|||
AutoUnsafe(m) => {
|
||||
mk_ptr(cx, mt {ty: adjusted_ty, mutbl: m})
|
||||
}
|
||||
|
||||
AutoBorrowObj(r, m) => {
|
||||
borrow_obj(cx, span, r, m, adjusted_ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3054,6 +3067,22 @@ pub fn adjust_ty(cx: ctxt,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn borrow_obj(cx: ctxt, span: span, r: Region,
|
||||
m: ast::mutability, ty: ty::t) -> ty::t {
|
||||
match get(ty).sty {
|
||||
ty_trait(trt_did, ref trt_substs, _, _, b) => {
|
||||
ty::mk_trait(cx, trt_did, trt_substs.clone(),
|
||||
RegionTraitStore(r), m, b)
|
||||
}
|
||||
ref s => {
|
||||
cx.sess.span_bug(
|
||||
span,
|
||||
fmt!("borrow-trait-obj associated with bad sty: %?",
|
||||
s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AutoRef {
|
||||
|
@ -3064,6 +3093,7 @@ impl AutoRef {
|
|||
ty::AutoBorrowVecRef(r, m) => ty::AutoBorrowVecRef(f(r), m),
|
||||
ty::AutoBorrowFn(r) => ty::AutoBorrowFn(f(r)),
|
||||
ty::AutoUnsafe(m) => ty::AutoUnsafe(m),
|
||||
ty::AutoBorrowObj(r, m) => ty::AutoBorrowObj(f(r), m),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue