Skip to content

Commit f0c0c2a

Browse files
committed
rustc: remove proc -> once || coercions.
1 parent 402d946 commit f0c0c2a

File tree

6 files changed

+10
-101
lines changed

6 files changed

+10
-101
lines changed

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,8 @@ impl<'a> GatherLoanCtxt<'a> {
451451
r,
452452
AutoRef)
453453
}
454-
ty::AutoBorrowFn(r) => {
455-
let cmt_deref = mc.cat_deref_fn_or_obj(expr, cmt, 0);
456-
self.guarantee_valid(expr.id,
457-
expr.span,
458-
cmt_deref,
459-
ast::MutImmutable,
460-
r,
461-
AutoRef)
462-
}
463454
ty::AutoBorrowObj(r, m) => {
464-
let cmt_deref = mc.cat_deref_fn_or_obj(expr, cmt, 0);
455+
let cmt_deref = mc.cat_deref_obj(expr, cmt);
465456
self.guarantee_valid(expr.id,
466457
expr.span,
467458
cmt_deref,

src/librustc/middle/mem_categorization.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -686,19 +686,8 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
686686
}
687687
}
688688

689-
pub fn cat_deref_fn_or_obj<N:ast_node>(&mut self,
690-
node: &N,
691-
base_cmt: cmt,
692-
deref_cnt: uint)
693-
-> cmt {
694-
// Bit of a hack: the "dereference" of a function pointer like
695-
// `@fn()` is a mere logical concept. We interpret it as
696-
// dereferencing the environment pointer; of course, we don't
697-
// know what type lies at the other end, so we just call it
698-
// `()` (the empty tuple).
699-
700-
let opaque_ty = ty::mk_tup(self.tcx(), Vec::new());
701-
self.cat_deref_common(node, base_cmt, deref_cnt, opaque_ty)
689+
pub fn cat_deref_obj<N:ast_node>(&mut self, node: &N, base_cmt: cmt) -> cmt {
690+
self.cat_deref_common(node, base_cmt, 0, ty::mk_nil())
702691
}
703692

704693
fn cat_deref<N:ast_node>(&mut self,

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use middle::trans::type_of;
6262
use middle::trans::write_guard;
6363
use middle::ty::struct_fields;
6464
use middle::ty::{AutoBorrowObj, AutoDerefRef, AutoAddEnv, AutoObject, AutoUnsafe};
65-
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn};
65+
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef};
6666
use middle::ty;
6767
use middle::typeck::MethodCall;
6868
use util::common::indenter;
@@ -200,14 +200,6 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
200200
Some(AutoBorrowVecRef(..)) => {
201201
unpack_datum!(bcx, auto_slice_and_ref(bcx, expr, datum))
202202
}
203-
Some(AutoBorrowFn(..)) => {
204-
let adjusted_ty = ty::adjust_ty(bcx.tcx(), expr.span, expr.id, datum.ty,
205-
Some(adjustment), |method_call| {
206-
bcx.ccx().maps.method_map.borrow()
207-
.find(&method_call).map(|method| method.ty)
208-
});
209-
unpack_datum!(bcx, auto_borrow_fn(bcx, adjusted_ty, datum))
210-
}
211203
Some(AutoBorrowObj(..)) => {
212204
unpack_datum!(bcx, auto_borrow_obj(bcx, expr, datum))
213205
}
@@ -225,20 +217,6 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
225217
debug!("after adjustments, datum={}", datum.to_str(bcx.ccx()));
226218
return DatumBlock {bcx: bcx, datum: datum};
227219

228-
fn auto_borrow_fn<'a>(
229-
bcx: &'a Block<'a>,
230-
adjusted_ty: ty::t,
231-
datum: Datum<Expr>)
232-
-> DatumBlock<'a, Expr> {
233-
// Currently, all closure types are represented precisely the
234-
// same, so no runtime adjustment is required, but we still
235-
// must patchup the type.
236-
DatumBlock {bcx: bcx,
237-
datum: Datum {val: datum.val,
238-
ty: adjusted_ty,
239-
kind: datum.kind}}
240-
}
241-
242220
fn auto_slice<'a>(
243221
bcx: &'a Block<'a>,
244222
expr: &ast::Expr,

src/librustc/middle/ty.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ pub enum AutoRef {
239239
/// Convert from ~[]/&[] to &&[] (or str)
240240
AutoBorrowVecRef(Region, ast::Mutability),
241241

242-
/// Convert from @fn()/~fn()/|| to ||
243-
AutoBorrowFn(Region),
244-
245242
/// Convert from T to *T
246243
AutoUnsafe(ast::Mutability),
247244

@@ -2906,10 +2903,6 @@ pub fn adjust_ty(cx: &ctxt,
29062903
})
29072904
}
29082905

2909-
AutoBorrowFn(r) => {
2910-
borrow_fn(cx, span, r, adjusted_ty)
2911-
}
2912-
29132906
AutoUnsafe(m) => {
29142907
mk_ptr(cx, mt {ty: adjusted_ty, mutbl: m})
29152908
}
@@ -2951,24 +2944,6 @@ pub fn adjust_ty(cx: &ctxt,
29512944
}
29522945
}
29532946

2954-
fn borrow_fn(cx: &ctxt, span: Span, r: Region, ty: ty::t) -> ty::t {
2955-
match get(ty).sty {
2956-
ty_closure(ref fty) => {
2957-
ty::mk_closure(cx, ClosureTy {
2958-
store: RegionTraitStore(r, ast::MutMutable),
2959-
..(**fty).clone()
2960-
})
2961-
}
2962-
2963-
ref s => {
2964-
cx.sess.span_bug(
2965-
span,
2966-
format!("borrow-fn associated with bad sty: {:?}",
2967-
s));
2968-
}
2969-
}
2970-
}
2971-
29722947
fn borrow_obj(cx: &ctxt, span: Span, r: Region,
29732948
m: ast::Mutability, ty: ty::t) -> ty::t {
29742949
match get(ty).sty {
@@ -2992,7 +2967,6 @@ impl AutoRef {
29922967
ty::AutoPtr(r, m) => ty::AutoPtr(f(r), m),
29932968
ty::AutoBorrowVec(r, m) => ty::AutoBorrowVec(f(r), m),
29942969
ty::AutoBorrowVecRef(r, m) => ty::AutoBorrowVecRef(f(r), m),
2995-
ty::AutoBorrowFn(r) => ty::AutoBorrowFn(f(r)),
29962970
ty::AutoUnsafe(m) => ty::AutoUnsafe(m),
29972971
ty::AutoBorrowObj(r, m) => ty::AutoBorrowObj(f(r), m),
29982972
}

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,13 +1123,8 @@ fn link_autoref(rcx: &mut Rcx,
11231123
link_region(mc.typer, expr.span, r, m, cmt_index);
11241124
}
11251125

1126-
ty::AutoBorrowFn(r) => {
1127-
let cmt_deref = mc.cat_deref_fn_or_obj(expr, expr_cmt, 0);
1128-
link_region(mc.typer, expr.span, r, ast::MutImmutable, cmt_deref);
1129-
}
1130-
11311126
ty::AutoBorrowObj(r, m) => {
1132-
let cmt_deref = mc.cat_deref_fn_or_obj(expr, expr_cmt, 0);
1127+
let cmt_deref = mc.cat_deref_obj(expr, expr_cmt);
11331128
link_region(mc.typer, expr.span, r, m, cmt_deref);
11341129
}
11351130

src/librustc/middle/typeck/infer/coercion.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ we may want to adjust precisely when coercions occur.
6565
*/
6666

6767

68-
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowFn, AutoBorrowObj};
69-
use middle::ty::{AutoDerefRef};
68+
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowObj, AutoDerefRef};
7069
use middle::ty::{VstoreSlice, VstoreUniq};
7170
use middle::ty::{mt};
7271
use middle::ty;
@@ -342,31 +341,14 @@ impl<'f> Coerce<'f> {
342341
a.inf_str(self.get_ref().infcx), sty_a,
343342
b.inf_str(self.get_ref().infcx));
344343

345-
let fn_ty = match *sty_a {
346-
ty::ty_closure(ref f) if f.store == ty::UniqTraitStore => {
347-
(*f).clone()
348-
}
344+
match *sty_a {
349345
ty::ty_bare_fn(ref f) => {
350-
return self.coerce_from_bare_fn(a, f, b);
346+
self.coerce_from_bare_fn(a, f, b)
351347
}
352348
_ => {
353-
return self.subtype(a, b);
349+
self.subtype(a, b)
354350
}
355-
};
356-
357-
let r_borrow = self.get_ref().infcx.next_region_var(Coercion(self.get_ref().trace));
358-
let a_borrowed = ty::mk_closure(
359-
self.get_ref().infcx.tcx,
360-
ty::ClosureTy {
361-
store: ty::RegionTraitStore(r_borrow, ast::MutMutable),
362-
.. *fn_ty
363-
});
364-
365-
if_ok!(self.subtype(a_borrowed, b));
366-
Ok(Some(@AutoDerefRef(AutoDerefRef {
367-
autoderefs: 0,
368-
autoref: Some(AutoBorrowFn(r_borrow))
369-
})))
351+
}
370352
}
371353

372354
fn coerce_from_bare_fn(&self, a: ty::t, fn_ty_a: &ty::BareFnTy, b: ty::t)

0 commit comments

Comments
 (0)