Skip to content

Commit 50a370a

Browse files
committed
Remove dead code related to old closures.
1 parent ab9c773 commit 50a370a

File tree

4 files changed

+16
-113
lines changed

4 files changed

+16
-113
lines changed

src/librustc/middle/mem_categorization.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ pub enum categorization<'tcx> {
104104
#[derive(Clone, Copy, PartialEq, Show)]
105105
pub struct Upvar {
106106
pub id: ty::UpvarId,
107-
// Unboxed closure kinds are used even for old-style closures for simplicity
108-
pub kind: ty::ClosureKind,
109-
// Is this from an unboxed closure? Used only for diagnostics.
110-
pub is_unboxed: bool
107+
pub kind: ty::ClosureKind
111108
}
112109

113110
// different kinds of pointers:
@@ -599,7 +596,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
599596
ty::ty_closure(closure_id, _, _) => {
600597
let kind = self.typer.closure_kind(closure_id);
601598
let mode = self.typer.capture_mode(fn_node_id);
602-
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, true)
599+
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode)
603600
}
604601
_ => {
605602
self.tcx().sess.span_bug(
@@ -632,8 +629,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
632629
var_id: ast::NodeId,
633630
fn_node_id: ast::NodeId,
634631
kind: ty::ClosureKind,
635-
mode: ast::CaptureClause,
636-
is_unboxed: bool)
632+
mode: ast::CaptureClause)
637633
-> McResult<cmt<'tcx>> {
638634
// An upvar can have up to 3 components. The base is a
639635
// `cat_upvar`. Next, we add a deref through the implicit
@@ -654,8 +650,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
654650
// Fn | copied -> &'env | upvar -> &'env -> &'up bk
655651
// FnMut | copied -> &'env mut | upvar -> &'env mut -> &'up bk
656652
// FnOnce | copied | upvar -> &'up bk
657-
// old stack | N/A | upvar -> &'env mut -> &'up bk
658-
// old proc/once | copied | N/A
659653
let var_ty = try!(self.node_ty(var_id));
660654

661655
let upvar_id = ty::UpvarId { var_id: var_id,
@@ -711,8 +705,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
711705
span: span,
712706
cat: cat_upvar(Upvar {
713707
id: upvar_id,
714-
kind: kind,
715-
is_unboxed: is_unboxed
708+
kind: kind
716709
}),
717710
mutbl: var_mutbl,
718711
ty: var_ty,
@@ -751,8 +744,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
751744
span: span,
752745
cat: cat_upvar(Upvar {
753746
id: upvar_id,
754-
kind: kind,
755-
is_unboxed: is_unboxed
747+
kind: kind
756748
}),
757749
mutbl: McImmutable,
758750
ty: self.tcx().types.err,

src/librustc_trans/trans/base.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1763,12 +1763,6 @@ pub fn build_return_block<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
17631763
}
17641764
}
17651765

1766-
#[derive(Clone, Copy, Eq, PartialEq)]
1767-
pub enum IsUnboxedClosureFlag {
1768-
NotUnboxedClosure,
1769-
IsUnboxedClosure,
1770-
}
1771-
17721766
// trans_closure: Builds an LLVM function out of a source function.
17731767
// If the function closes over its environment a closure will be
17741768
// returned.

src/libsyntax/ast.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1237,16 +1237,6 @@ impl fmt::Display for Onceness {
12371237
}
12381238
}
12391239

1240-
/// Represents the type of a closure
1241-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
1242-
pub struct ClosureTy {
1243-
pub lifetimes: Vec<LifetimeDef>,
1244-
pub unsafety: Unsafety,
1245-
pub onceness: Onceness,
1246-
pub decl: P<FnDecl>,
1247-
pub bounds: TyParamBounds,
1248-
}
1249-
12501240
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
12511241
pub struct BareFnTy {
12521242
pub unsafety: Unsafety,

src/libsyntax/print/pprust.rs

+11-84
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,11 @@ impl<'a> State<'a> {
703703
predicates: Vec::new(),
704704
},
705705
};
706-
try!(self.print_ty_fn(Some(f.abi),
707-
None,
706+
try!(self.print_ty_fn(f.abi,
708707
f.unsafety,
709-
ast::Many,
710708
&*f.decl,
711709
None,
712-
&OwnedSlice::empty(),
713-
Some(&generics),
710+
&generics,
714711
None));
715712
}
716713
ast::TyPath(ref path, _) => {
@@ -1215,14 +1212,11 @@ impl<'a> State<'a> {
12151212
try!(self.hardbreak_if_not_bol());
12161213
try!(self.maybe_print_comment(m.span.lo));
12171214
try!(self.print_outer_attributes(&m.attrs[]));
1218-
try!(self.print_ty_fn(None,
1219-
None,
1215+
try!(self.print_ty_fn(m.abi,
12201216
m.unsafety,
1221-
ast::Many,
12221217
&*m.decl,
12231218
Some(m.ident),
1224-
&OwnedSlice::empty(),
1225-
Some(&m.generics),
1219+
&m.generics,
12261220
Some(&m.explicit_self.node)));
12271221
word(&mut self.s, ";")
12281222
}
@@ -2300,7 +2294,7 @@ impl<'a> State<'a> {
23002294
opt_explicit_self: Option<&ast::ExplicitSelf_>,
23012295
vis: ast::Visibility) -> IoResult<()> {
23022296
try!(self.head(""));
2303-
try!(self.print_fn_header_info(opt_explicit_self, unsafety, abi, vis));
2297+
try!(self.print_fn_header_info(unsafety, abi, vis));
23042298
try!(self.nbsp());
23052299
try!(self.print_ident(name));
23062300
try!(self.print_generics(generics));
@@ -2396,31 +2390,6 @@ impl<'a> State<'a> {
23962390
}
23972391
}
23982392

2399-
pub fn print_proc_args(&mut self, decl: &ast::FnDecl) -> IoResult<()> {
2400-
try!(word(&mut self.s, "proc"));
2401-
try!(word(&mut self.s, "("));
2402-
try!(self.print_fn_args(decl, None));
2403-
try!(word(&mut self.s, ")"));
2404-
2405-
if let ast::DefaultReturn(..) = decl.output {
2406-
return Ok(());
2407-
}
2408-
2409-
try!(self.space_if_not_bol());
2410-
try!(self.word_space("->"));
2411-
match decl.output {
2412-
ast::Return(ref ty) => {
2413-
try!(self.print_type(&**ty));
2414-
self.maybe_print_comment(ty.span.lo)
2415-
}
2416-
ast::DefaultReturn(..) => unreachable!(),
2417-
ast::NoReturn(span) => {
2418-
try!(self.word_nbsp("!"));
2419-
self.maybe_print_comment(span.lo)
2420-
}
2421-
}
2422-
}
2423-
24242393
pub fn print_bounds(&mut self,
24252394
prefix: &str,
24262395
bounds: &[ast::TyParamBound])
@@ -2696,31 +2665,15 @@ impl<'a> State<'a> {
26962665
}
26972666

26982667
pub fn print_ty_fn(&mut self,
2699-
opt_abi: Option<abi::Abi>,
2700-
opt_sigil: Option<char>,
2668+
abi: abi::Abi,
27012669
unsafety: ast::Unsafety,
2702-
onceness: ast::Onceness,
27032670
decl: &ast::FnDecl,
27042671
id: Option<ast::Ident>,
2705-
bounds: &OwnedSlice<ast::TyParamBound>,
2706-
generics: Option<&ast::Generics>,
2672+
generics: &ast::Generics,
27072673
opt_explicit_self: Option<&ast::ExplicitSelf_>)
27082674
-> IoResult<()> {
27092675
try!(self.ibox(indent_unit));
2710-
2711-
// Duplicates the logic in `print_fn_header_info()`. This is because that
2712-
// function prints the sigil in the wrong place. That should be fixed.
2713-
if opt_sigil == Some('~') && onceness == ast::Once {
2714-
try!(word(&mut self.s, "proc"));
2715-
} else if opt_sigil == Some('&') {
2716-
try!(self.print_unsafety(unsafety));
2717-
try!(self.print_extern_opt_abi(opt_abi));
2718-
} else {
2719-
assert!(opt_sigil.is_none());
2720-
try!(self.print_unsafety(unsafety));
2721-
try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
2722-
try!(word(&mut self.s, "fn"));
2723-
}
2676+
try!(self.print_fn_header_info(Some(unsafety), abi, ast::Inherited));
27242677

27252678
match id {
27262679
Some(id) => {
@@ -2730,35 +2683,10 @@ impl<'a> State<'a> {
27302683
_ => ()
27312684
}
27322685

2733-
match generics { Some(g) => try!(self.print_generics(g)), _ => () }
2686+
try!(self.print_generics(generics));
27342687
try!(zerobreak(&mut self.s));
2735-
2736-
if opt_sigil == Some('&') {
2737-
try!(word(&mut self.s, "|"));
2738-
} else {
2739-
try!(self.popen());
2740-
}
2741-
2742-
try!(self.print_fn_args(decl, opt_explicit_self));
2743-
2744-
if opt_sigil == Some('&') {
2745-
try!(word(&mut self.s, "|"));
2746-
} else {
2747-
if decl.variadic {
2748-
try!(word(&mut self.s, ", ..."));
2749-
}
2750-
try!(self.pclose());
2751-
}
2752-
2753-
try!(self.print_bounds(":", &bounds[]));
2754-
2755-
try!(self.print_fn_output(decl));
2756-
2757-
match generics {
2758-
Some(generics) => try!(self.print_where_clause(generics)),
2759-
None => {}
2760-
}
2761-
2688+
try!(self.print_fn_args_and_ret(decl, opt_explicit_self));
2689+
try!(self.print_where_clause(generics));
27622690
self.end()
27632691
}
27642692

@@ -3015,7 +2943,6 @@ impl<'a> State<'a> {
30152943
}
30162944

30172945
pub fn print_fn_header_info(&mut self,
3018-
_opt_explicit_self: Option<&ast::ExplicitSelf_>,
30192946
opt_unsafety: Option<ast::Unsafety>,
30202947
abi: abi::Abi,
30212948
vis: ast::Visibility) -> IoResult<()> {

0 commit comments

Comments
 (0)