diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2015-01-24 22:06:31 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2015-01-26 04:15:09 +0200 |
| commit | 50a370aa2d98ea2f50153a3007734f8d6fb473e0 (patch) | |
| tree | 8b80d4193c5090ec464125a152bb83029473602b /src | |
| parent | ab9c773cdb17404dd5982add2980a35921b844b8 (diff) | |
| download | rust-50a370aa2d98ea2f50153a3007734f8d6fb473e0.tar.gz rust-50a370aa2d98ea2f50153a3007734f8d6fb473e0.zip | |
Remove dead code related to old closures.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/mem_categorization.rs | 18 | ||||
| -rw-r--r-- | src/librustc_trans/trans/base.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 95 |
4 files changed, 16 insertions, 113 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index fa49196e6c5..9954aa39226 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -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 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { 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 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { 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 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { // 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 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { 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 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { span: span, cat: cat_upvar(Upvar { id: upvar_id, - kind: kind, - is_unboxed: is_unboxed + kind: kind }), mutbl: McImmutable, ty: self.tcx().types.err, diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index a73af16d7ec..230a4c5d427 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -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. diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 909a719c691..233197ccb5b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1237,16 +1237,6 @@ impl fmt::Display for Onceness { } } -/// 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, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7cbc701995e..d06ac50920e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -703,14 +703,11 @@ impl<'a> State<'a> { 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 @@ impl<'a> State<'a> { 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 @@ impl<'a> State<'a> { 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 @@ impl<'a> State<'a> { } } - 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 @@ impl<'a> State<'a> { } 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 @@ impl<'a> State<'a> { _ => () } - 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 @@ impl<'a> State<'a> { } 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<()> { |
