Skip to content

Commit f915b46

Browse files
committed
Remove the unboxed closure |:| notation from types and trait references completely.
1 parent 339c675 commit f915b46

File tree

17 files changed

+29
-348
lines changed

17 files changed

+29
-348
lines changed

src/librustc/middle/resolve.rs

+1-36
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
4040
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt};
4141
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyProc, TyQPath};
4242
use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
43-
use syntax::ast::{TypeImplItem, UnboxedFnTyParamBound, UnnamedField};
43+
use syntax::ast::{TypeImplItem, UnnamedField};
4444
use syntax::ast::{Variant, ViewItem, ViewItemExternCrate};
4545
use syntax::ast::{ViewItemUse, ViewPathGlob, ViewPathList, ViewPathSimple};
4646
use syntax::ast::{Visibility};
@@ -4523,41 +4523,6 @@ impl<'a> Resolver<'a> {
45234523
TraitTyParamBound(ref tref) => {
45244524
self.resolve_trait_reference(id, tref, reference_type)
45254525
}
4526-
UnboxedFnTyParamBound(ref unboxed_function) => {
4527-
match self.resolve_path(unboxed_function.ref_id,
4528-
&unboxed_function.path,
4529-
TypeNS,
4530-
true) {
4531-
None => {
4532-
let path_str = self.path_names_to_string(
4533-
&unboxed_function.path);
4534-
self.resolve_error(unboxed_function.path.span,
4535-
format!("unresolved trait `{}`",
4536-
path_str).as_slice())
4537-
}
4538-
Some(def) => {
4539-
match def {
4540-
(DefTrait(_), _) => {
4541-
self.record_def(unboxed_function.ref_id, def);
4542-
}
4543-
_ => {
4544-
let msg =
4545-
format!("`{}` is not a trait",
4546-
self.path_names_to_string(
4547-
&unboxed_function.path));
4548-
self.resolve_error(unboxed_function.path.span,
4549-
msg.as_slice());
4550-
}
4551-
}
4552-
}
4553-
}
4554-
4555-
for argument in unboxed_function.decl.inputs.iter() {
4556-
self.resolve_type(&*argument.ty);
4557-
}
4558-
4559-
self.resolve_type(&*unboxed_function.decl.output);
4560-
}
45614526
RegionTyParamBound(..) => {}
45624527
}
45634528
}

src/librustc/middle/resolve_lifetime.rs

-15
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ impl<'a> LifetimeContext<'a> {
204204
ast::TraitTyParamBound(ref trait_ref) => {
205205
self.visit_trait_ref(trait_ref);
206206
}
207-
ast::UnboxedFnTyParamBound(ref fn_decl) => {
208-
self.visit_unboxed_fn_ty_param_bound(&**fn_decl);
209-
}
210207
ast::RegionTyParamBound(ref lifetime) => {
211208
self.visit_lifetime_ref(lifetime);
212209
}
@@ -226,18 +223,6 @@ impl<'a> LifetimeContext<'a> {
226223
})
227224
}
228225

229-
fn visit_unboxed_fn_ty_param_bound(&mut self,
230-
bound: &ast::UnboxedFnBound) {
231-
self.with(|scope, f| {
232-
f(LateScope(bound.ref_id, &bound.lifetimes, scope))
233-
}, |v| {
234-
for argument in bound.decl.inputs.iter() {
235-
v.visit_ty(&*argument.ty);
236-
}
237-
v.visit_ty(&*bound.decl.output);
238-
})
239-
}
240-
241226
/// Visits self by adding a scope and handling recursive walk over the contents with `walk`.
242227
fn visit_fn_decl(&mut self,
243228
n: ast::NodeId,

src/librustc/middle/save/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
705705
ast::TraitTyParamBound(ref trait_ref) => {
706706
trait_ref
707707
}
708-
ast::UnboxedFnTyParamBound(..) | ast::RegionTyParamBound(..) => {
708+
ast::RegionTyParamBound(..) => {
709709
continue;
710710
}
711711
};

src/librustc/middle/typeck/astconv.rs

+1-54
Original file line numberDiff line numberDiff line change
@@ -620,15 +620,6 @@ enum PointerTy {
620620
Uniq
621621
}
622622

623-
impl PointerTy {
624-
fn default_region(&self) -> ty::Region {
625-
match *self {
626-
Uniq => ty::ReStatic,
627-
RPtr(r) => r,
628-
}
629-
}
630-
}
631-
632623
pub fn trait_ref_for_unboxed_function<'tcx, AC: AstConv<'tcx>,
633624
RS:RegionScope>(
634625
this: &AC,
@@ -687,31 +678,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
687678
let ty = ast_ty_to_ty(this, rscope, &**ty);
688679
return constr(ty::mk_vec(tcx, ty, None));
689680
}
690-
ast::TyUnboxedFn(ref unboxed_function) => {
691-
let ty::TraitRef {
692-
def_id,
693-
substs
694-
} = trait_ref_for_unboxed_function(this,
695-
rscope,
696-
unboxed_function.kind,
697-
&*unboxed_function.decl,
698-
None);
699-
let r = ptr_ty.default_region();
700-
let tr = ty::mk_trait(this.tcx(),
701-
def_id,
702-
substs,
703-
ty::region_existential_bound(r));
704-
match ptr_ty {
705-
Uniq => {
706-
return ty::mk_uniq(this.tcx(), tr);
707-
}
708-
RPtr(r) => {
709-
return ty::mk_rptr(this.tcx(),
710-
r,
711-
ty::mt {mutbl: a_seq_mutbl, ty: tr});
712-
}
713-
}
714-
}
715681
ast::TyPath(ref path, ref opt_bounds, id) => {
716682
// Note that the "bounds must be empty if path is not a trait"
717683
// restriction is enforced in the below case for ty_path, which
@@ -941,11 +907,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
941907

942908
ty::mk_closure(tcx, fn_decl)
943909
}
944-
ast::TyUnboxedFn(..) => {
945-
tcx.sess.span_err(ast_ty.span,
946-
"cannot use unboxed functions here");
947-
ty::mk_err()
948-
}
949910
ast::TyPath(ref path, ref bounds, id) => {
950911
let a_def = match tcx.def_map.borrow().find(&id) {
951912
None => {
@@ -1425,8 +1386,7 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
14251386

14261387
let PartitionedBounds { builtin_bounds,
14271388
trait_bounds,
1428-
region_bounds,
1429-
unboxed_fn_ty_bounds } =
1389+
region_bounds } =
14301390
partition_bounds(this.tcx(), span, ast_bound_refs.as_slice());
14311391

14321392
if !trait_bounds.is_empty() {
@@ -1437,13 +1397,6 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
14371397
as closure or object bounds").as_slice());
14381398
}
14391399

1440-
if !unboxed_fn_ty_bounds.is_empty() {
1441-
this.tcx().sess.span_err(
1442-
span,
1443-
format!("only the builtin traits can be used \
1444-
as closure or object bounds").as_slice());
1445-
}
1446-
14471400
// The "main trait refs", rather annoyingly, have no type
14481401
// specified for the `Self` parameter of the trait. The reason for
14491402
// this is that they are, after all, *existential* types, and
@@ -1572,7 +1525,6 @@ fn compute_region_bound<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
15721525
pub struct PartitionedBounds<'a> {
15731526
pub builtin_bounds: ty::BuiltinBounds,
15741527
pub trait_bounds: Vec<&'a ast::TraitRef>,
1575-
pub unboxed_fn_ty_bounds: Vec<&'a ast::UnboxedFnBound>,
15761528
pub region_bounds: Vec<&'a ast::Lifetime>,
15771529
}
15781530

@@ -1590,7 +1542,6 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
15901542
let mut builtin_bounds = ty::empty_builtin_bounds();
15911543
let mut region_bounds = Vec::new();
15921544
let mut trait_bounds = Vec::new();
1593-
let mut unboxed_fn_ty_bounds = Vec::new();
15941545
let mut trait_def_ids = HashMap::new();
15951546
for &ast_bound in ast_bounds.iter() {
15961547
match *ast_bound {
@@ -1635,17 +1586,13 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
16351586
ast::RegionTyParamBound(ref l) => {
16361587
region_bounds.push(l);
16371588
}
1638-
ast::UnboxedFnTyParamBound(ref unboxed_function) => {
1639-
unboxed_fn_ty_bounds.push(&**unboxed_function);
1640-
}
16411589
}
16421590
}
16431591

16441592
PartitionedBounds {
16451593
builtin_bounds: builtin_bounds,
16461594
trait_bounds: trait_bounds,
16471595
region_bounds: region_bounds,
1648-
unboxed_fn_ty_bounds: unboxed_fn_ty_bounds
16491596
}
16501597
}
16511598

src/librustc/middle/typeck/collect.rs

+2-55
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
652652
let mut bounds = bounds.chain(ty_param.unbound.iter());
653653
for bound in bounds {
654654
match *bound {
655-
ast::TraitTyParamBound(..) | ast::UnboxedFnTyParamBound(..) => {
655+
ast::TraitTyParamBound(..) => {
656656
// According to accepted RFC #XXX, we should
657657
// eventually accept these, but it will not be
658658
// part of this PR. Still, convert to warning to
@@ -1370,20 +1370,6 @@ pub fn instantiate_trait_ref<'tcx,AC>(this: &AC,
13701370
}
13711371
}
13721372

1373-
pub fn instantiate_unboxed_fn_ty<'tcx,AC>(this: &AC,
1374-
unboxed_function: &ast::UnboxedFnTy,
1375-
param_ty: ty::ParamTy)
1376-
-> Rc<ty::TraitRef>
1377-
where AC: AstConv<'tcx> {
1378-
let rscope = ExplicitRscope;
1379-
let param_ty = param_ty.to_ty(this.tcx());
1380-
Rc::new(astconv::trait_ref_for_unboxed_function(this,
1381-
&rscope,
1382-
unboxed_function.kind,
1383-
&*unboxed_function.decl,
1384-
Some(param_ty)))
1385-
}
1386-
13871373
fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc<ty::TraitDef> {
13881374
if trait_id.krate != ast::LOCAL_CRATE {
13891375
return ty::lookup_trait_def(ccx.tcx, trait_id)
@@ -1893,7 +1879,6 @@ fn ty_generics<'tcx,AC>(this: &AC,
18931879
// In the above example, `ast_trait_ref` is `Iterator`.
18941880
let ast_trait_ref = match *bound {
18951881
ast::TraitTyParamBound(ref r) => r,
1896-
ast::UnboxedFnTyParamBound(..) => { continue; }
18971882
ast::RegionTyParamBound(..) => { continue; }
18981883
};
18991884

@@ -2071,45 +2056,8 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
20712056
merge_param_bounds(this.tcx(), param_ty, ast_bounds, where_clause);
20722057
let astconv::PartitionedBounds { builtin_bounds,
20732058
trait_bounds,
2074-
region_bounds,
2075-
unboxed_fn_ty_bounds } =
2059+
region_bounds } =
20762060
astconv::partition_bounds(this.tcx(), span, all_bounds.as_slice());
2077-
2078-
let unboxed_fn_ty_bounds = unboxed_fn_ty_bounds.into_iter().map(|b| {
2079-
let trait_id = (*this.tcx().def_map.borrow())[b.ref_id].def_id();
2080-
let mut kind = None;
2081-
for &(lang_item, this_kind) in [
2082-
(this.tcx().lang_items.fn_trait(), ast::FnUnboxedClosureKind),
2083-
(this.tcx().lang_items.fn_mut_trait(),
2084-
ast::FnMutUnboxedClosureKind),
2085-
(this.tcx().lang_items.fn_once_trait(),
2086-
ast::FnOnceUnboxedClosureKind)
2087-
].iter() {
2088-
if Some(trait_id) == lang_item {
2089-
kind = Some(this_kind);
2090-
break
2091-
}
2092-
}
2093-
2094-
let kind = match kind {
2095-
Some(kind) => kind,
2096-
None => {
2097-
this.tcx().sess.span_err(b.path.span,
2098-
"unboxed function trait must be one \
2099-
of `Fn`, `FnMut`, or `FnOnce`");
2100-
ast::FnMutUnboxedClosureKind
2101-
}
2102-
};
2103-
2104-
let rscope = ExplicitRscope;
2105-
let param_ty = param_ty.to_ty(this.tcx());
2106-
Rc::new(astconv::trait_ref_for_unboxed_function(this,
2107-
&rscope,
2108-
kind,
2109-
&*b.decl,
2110-
Some(param_ty)))
2111-
});
2112-
21132061
let trait_bounds: Vec<Rc<ty::TraitRef>> =
21142062
trait_bounds.into_iter()
21152063
.map(|b| {
@@ -2118,7 +2066,6 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
21182066
param_ty.to_ty(this.tcx()),
21192067
Some(param_ty.to_ty(this.tcx())))
21202068
})
2121-
.chain(unboxed_fn_ty_bounds)
21222069
.collect();
21232070
let region_bounds: Vec<ty::Region> =
21242071
region_bounds.into_iter()

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

-3
Original file line numberDiff line numberDiff line change
@@ -1102,9 +1102,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11021102
// be passing down a map.
11031103
ast::RegionTyParamBound(lt)
11041104
}
1105-
&ast::UnboxedFnTyParamBound(ref unboxed_function_type) => {
1106-
ast::UnboxedFnTyParamBound((*unboxed_function_type).clone())
1107-
}
11081105
&ast::TraitTyParamBound(ref tr) => {
11091106
let last_seg = tr.path.segments.last().unwrap();
11101107
let mut insert = Vec::new();

src/librustdoc/clean/inline.rs

-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
323323
trait_: associated_trait.clean(cx).map(|bound| {
324324
match bound {
325325
clean::TraitBound(ty) => ty,
326-
clean::UnboxedFnBound(..) |
327326
clean::RegionBound(..) => unreachable!(),
328327
}
329328
}),

src/librustdoc/clean/mod.rs

-17
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,13 @@ impl Clean<TyParam> for ty::TypeParameterDef {
476476
#[deriving(Clone, Encodable, Decodable, PartialEq)]
477477
pub enum TyParamBound {
478478
RegionBound(Lifetime),
479-
UnboxedFnBound(UnboxedFnType),
480479
TraitBound(Type)
481480
}
482481

483482
impl Clean<TyParamBound> for ast::TyParamBound {
484483
fn clean(&self, cx: &DocContext) -> TyParamBound {
485484
match *self {
486485
ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
487-
ast::UnboxedFnTyParamBound(ref ty) => { UnboxedFnBound(ty.clean(cx)) },
488486
ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)),
489487
}
490488
}
@@ -599,21 +597,6 @@ impl Clean<Option<Vec<TyParamBound>>> for subst::Substs {
599597
}
600598
}
601599

602-
#[deriving(Clone, Encodable, Decodable, PartialEq)]
603-
pub struct UnboxedFnType {
604-
pub path: Path,
605-
pub decl: FnDecl
606-
}
607-
608-
impl Clean<UnboxedFnType> for ast::UnboxedFnBound {
609-
fn clean(&self, cx: &DocContext) -> UnboxedFnType {
610-
UnboxedFnType {
611-
path: self.path.clean(cx),
612-
decl: self.decl.clean(cx)
613-
}
614-
}
615-
}
616-
617600
#[deriving(Clone, Encodable, Decodable, PartialEq)]
618601
pub struct Lifetime(String);
619602

src/librustdoc/html/format.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ impl fmt::Show for clean::TyParamBound {
143143
clean::RegionBound(ref lt) => {
144144
write!(f, "{}", *lt)
145145
}
146-
clean::UnboxedFnBound(ref ty) => {
147-
write!(f, "{}{}", ty.path, ty.decl)
148-
}
149146
clean::TraitBound(ref ty) => {
150147
write!(f, "{}", *ty)
151148
}
@@ -404,8 +401,7 @@ impl fmt::Show for clean::Type {
404401
let mut ret = String::new();
405402
for bound in decl.bounds.iter() {
406403
match *bound {
407-
clean::RegionBound(..) |
408-
clean::UnboxedFnBound(..) => {}
404+
clean::RegionBound(..) => {}
409405
clean::TraitBound(ref t) => {
410406
if ret.len() == 0 {
411407
ret.push_str(": ");

0 commit comments

Comments
 (0)