Remove dead code related to old closures.

This commit is contained in:
Eduard Burtescu 2015-01-24 22:06:31 +02:00
parent ab9c773cdb
commit 50a370aa2d
4 changed files with 16 additions and 113 deletions

View file

@ -104,10 +104,7 @@ pub enum categorization<'tcx> {
#[derive(Clone, Copy, PartialEq, Show)]
pub struct Upvar {
pub id: ty::UpvarId,
// Unboxed closure kinds are used even for old-style closures for simplicity
pub kind: ty::ClosureKind,
// Is this from an unboxed closure? Used only for diagnostics.
pub is_unboxed: bool
pub kind: ty::ClosureKind
}
// different kinds of pointers:
@ -599,7 +596,7 @@ pub fn cat_def(&self,
ty::ty_closure(closure_id, _, _) => {
let kind = self.typer.closure_kind(closure_id);
let mode = self.typer.capture_mode(fn_node_id);
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, true)
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode)
}
_ => {
self.tcx().sess.span_bug(
@ -632,8 +629,7 @@ fn cat_upvar(&self,
var_id: ast::NodeId,
fn_node_id: ast::NodeId,
kind: ty::ClosureKind,
mode: ast::CaptureClause,
is_unboxed: bool)
mode: ast::CaptureClause)
-> McResult<cmt<'tcx>> {
// An upvar can have up to 3 components. The base is a
// `cat_upvar`. Next, we add a deref through the implicit
@ -654,8 +650,6 @@ fn cat_upvar(&self,
// Fn | copied -> &'env | upvar -> &'env -> &'up bk
// FnMut | copied -> &'env mut | upvar -> &'env mut -> &'up bk
// FnOnce | copied | upvar -> &'up bk
// old stack | N/A | upvar -> &'env mut -> &'up bk
// old proc/once | copied | N/A
let var_ty = try!(self.node_ty(var_id));
let upvar_id = ty::UpvarId { var_id: var_id,
@ -711,8 +705,7 @@ fn cat_upvar(&self,
span: span,
cat: cat_upvar(Upvar {
id: upvar_id,
kind: kind,
is_unboxed: is_unboxed
kind: kind
}),
mutbl: var_mutbl,
ty: var_ty,
@ -751,8 +744,7 @@ fn cat_upvar(&self,
span: span,
cat: cat_upvar(Upvar {
id: upvar_id,
kind: kind,
is_unboxed: is_unboxed
kind: kind
}),
mutbl: McImmutable,
ty: self.tcx().types.err,

View file

@ -1763,12 +1763,6 @@ pub fn build_return_block<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
}
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum IsUnboxedClosureFlag {
NotUnboxedClosure,
IsUnboxedClosure,
}
// trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be
// returned.

View file

@ -1237,16 +1237,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
/// Represents the type of a closure
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ClosureTy {
pub lifetimes: Vec<LifetimeDef>,
pub unsafety: Unsafety,
pub onceness: Onceness,
pub decl: P<FnDecl>,
pub bounds: TyParamBounds,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct BareFnTy {
pub unsafety: Unsafety,

View file

@ -703,14 +703,11 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> {
predicates: Vec::new(),
},
};
try!(self.print_ty_fn(Some(f.abi),
None,
try!(self.print_ty_fn(f.abi,
f.unsafety,
ast::Many,
&*f.decl,
None,
&OwnedSlice::empty(),
Some(&generics),
&generics,
None));
}
ast::TyPath(ref path, _) => {
@ -1215,14 +1212,11 @@ pub fn print_ty_method(&mut self, m: &ast::TypeMethod) -> IoResult<()> {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(m.span.lo));
try!(self.print_outer_attributes(&m.attrs[]));
try!(self.print_ty_fn(None,
None,
try!(self.print_ty_fn(m.abi,
m.unsafety,
ast::Many,
&*m.decl,
Some(m.ident),
&OwnedSlice::empty(),
Some(&m.generics),
&m.generics,
Some(&m.explicit_self.node)));
word(&mut self.s, ";")
}
@ -2300,7 +2294,7 @@ pub fn print_fn(&mut self,
opt_explicit_self: Option<&ast::ExplicitSelf_>,
vis: ast::Visibility) -> IoResult<()> {
try!(self.head(""));
try!(self.print_fn_header_info(opt_explicit_self, unsafety, abi, vis));
try!(self.print_fn_header_info(unsafety, abi, vis));
try!(self.nbsp());
try!(self.print_ident(name));
try!(self.print_generics(generics));
@ -2396,31 +2390,6 @@ pub fn print_capture_clause(&mut self, capture_clause: ast::CaptureClause)
}
}
pub fn print_proc_args(&mut self, decl: &ast::FnDecl) -> IoResult<()> {
try!(word(&mut self.s, "proc"));
try!(word(&mut self.s, "("));
try!(self.print_fn_args(decl, None));
try!(word(&mut self.s, ")"));
if let ast::DefaultReturn(..) = decl.output {
return Ok(());
}
try!(self.space_if_not_bol());
try!(self.word_space("->"));
match decl.output {
ast::Return(ref ty) => {
try!(self.print_type(&**ty));
self.maybe_print_comment(ty.span.lo)
}
ast::DefaultReturn(..) => unreachable!(),
ast::NoReturn(span) => {
try!(self.word_nbsp("!"));
self.maybe_print_comment(span.lo)
}
}
}
pub fn print_bounds(&mut self,
prefix: &str,
bounds: &[ast::TyParamBound])
@ -2696,31 +2665,15 @@ pub fn print_fn_output(&mut self, decl: &ast::FnDecl) -> IoResult<()> {
}
pub fn print_ty_fn(&mut self,
opt_abi: Option<abi::Abi>,
opt_sigil: Option<char>,
abi: abi::Abi,
unsafety: ast::Unsafety,
onceness: ast::Onceness,
decl: &ast::FnDecl,
id: Option<ast::Ident>,
bounds: &OwnedSlice<ast::TyParamBound>,
generics: Option<&ast::Generics>,
generics: &ast::Generics,
opt_explicit_self: Option<&ast::ExplicitSelf_>)
-> IoResult<()> {
try!(self.ibox(indent_unit));
// Duplicates the logic in `print_fn_header_info()`. This is because that
// function prints the sigil in the wrong place. That should be fixed.
if opt_sigil == Some('~') && onceness == ast::Once {
try!(word(&mut self.s, "proc"));
} else if opt_sigil == Some('&') {
try!(self.print_unsafety(unsafety));
try!(self.print_extern_opt_abi(opt_abi));
} else {
assert!(opt_sigil.is_none());
try!(self.print_unsafety(unsafety));
try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
try!(word(&mut self.s, "fn"));
}
try!(self.print_fn_header_info(Some(unsafety), abi, ast::Inherited));
match id {
Some(id) => {
@ -2730,35 +2683,10 @@ pub fn print_ty_fn(&mut self,
_ => ()
}
match generics { Some(g) => try!(self.print_generics(g)), _ => () }
try!(self.print_generics(generics));
try!(zerobreak(&mut self.s));
if opt_sigil == Some('&') {
try!(word(&mut self.s, "|"));
} else {
try!(self.popen());
}
try!(self.print_fn_args(decl, opt_explicit_self));
if opt_sigil == Some('&') {
try!(word(&mut self.s, "|"));
} else {
if decl.variadic {
try!(word(&mut self.s, ", ..."));
}
try!(self.pclose());
}
try!(self.print_bounds(":", &bounds[]));
try!(self.print_fn_output(decl));
match generics {
Some(generics) => try!(self.print_where_clause(generics)),
None => {}
}
try!(self.print_fn_args_and_ret(decl, opt_explicit_self));
try!(self.print_where_clause(generics));
self.end()
}
@ -3015,7 +2943,6 @@ pub fn print_extern_opt_abi(&mut self,
}
pub fn print_fn_header_info(&mut self,
_opt_explicit_self: Option<&ast::ExplicitSelf_>,
opt_unsafety: Option<ast::Unsafety>,
abi: abi::Abi,
vis: ast::Visibility) -> IoResult<()> {