From 091dc6e98a483c164735e9a0b9c5b3750a94a95f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 7 Nov 2014 15:48:55 -0500 Subject: [PATCH] Purge the old `once_fns`, which are not coming back --- src/libsyntax/feature_gate.rs | 10 ++-- src/libsyntax/parse/token.rs | 59 +++++++++---------- src/libsyntax/print/pprust.rs | 9 --- .../once-cant-call-twice-on-stack.rs | 28 --------- ...once-cant-move-out-of-non-once-on-stack.rs | 27 --------- src/test/compile-fail/once-fn-subtyping.rs | 17 ------ src/test/run-pass/once-move-out-on-heap.rs | 1 - src/test/run-pass/once-move-out-on-stack.rs | 27 --------- 8 files changed, 33 insertions(+), 145 deletions(-) delete mode 100644 src/test/compile-fail/once-cant-call-twice-on-stack.rs delete mode 100644 src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs delete mode 100644 src/test/compile-fail/once-fn-subtyping.rs delete mode 100644 src/test/run-pass/once-move-out-on-stack.rs diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 80b158a54d3..c38fea9b3d5 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -38,7 +38,6 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("globs", Active), ("macro_rules", Active), ("struct_variant", Active), - ("once_fns", Active), ("asm", Active), ("managed_boxes", Removed), ("non_ascii_idents", Active), @@ -307,11 +306,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_ty(&mut self, t: &ast::Ty) { match t.node { - ast::TyClosure(ref closure) if closure.onceness == ast::Once => { - self.gate_feature("once_fns", t.span, - "once functions are \ - experimental and likely to be removed"); - + ast::TyClosure(ref closure) => { + // this used to be blocked by a feature gate, but it should just + // be plain impossible right now + assert!(closure.onceness != ast::Once); }, _ => {} } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b0cca5e14de..f501a5831d2 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -503,42 +503,41 @@ declare_special_idents_and_keywords! { (27, Mod, "mod"); (28, Move, "move"); (29, Mut, "mut"); - (30, Once, "once"); - (31, Pub, "pub"); - (32, Ref, "ref"); - (33, Return, "return"); + (30, Pub, "pub"); + (31, Ref, "ref"); + (32, Return, "return"); // Static and Self are also special idents (prefill de-dupes) (super::STATIC_KEYWORD_NAME_NUM, Static, "static"); (super::SELF_KEYWORD_NAME_NUM, Self, "self"); - (34, Struct, "struct"); + (33, Struct, "struct"); (super::SUPER_KEYWORD_NAME_NUM, Super, "super"); - (35, True, "true"); - (36, Trait, "trait"); - (37, Type, "type"); - (38, Unsafe, "unsafe"); - (39, Use, "use"); - (40, Virtual, "virtual"); - (41, While, "while"); - (42, Continue, "continue"); - (43, Proc, "proc"); - (44, Box, "box"); - (45, Const, "const"); - (46, Where, "where"); + (34, True, "true"); + (35, Trait, "trait"); + (36, Type, "type"); + (37, Unsafe, "unsafe"); + (38, Use, "use"); + (39, Virtual, "virtual"); + (40, While, "while"); + (41, Continue, "continue"); + (42, Proc, "proc"); + (43, Box, "box"); + (44, Const, "const"); + (45, Where, "where"); 'reserved: - (47, Alignof, "alignof"); - (48, Be, "be"); - (49, Offsetof, "offsetof"); - (50, Priv, "priv"); - (51, Pure, "pure"); - (52, Sizeof, "sizeof"); - (53, Typeof, "typeof"); - (54, Unsized, "unsized"); - (55, Yield, "yield"); - (56, Do, "do"); - (57, Abstract, "abstract"); - (58, Final, "final"); - (59, Override, "override"); + (46, Alignof, "alignof"); + (47, Be, "be"); + (48, Offsetof, "offsetof"); + (49, Priv, "priv"); + (50, Pure, "pure"); + (51, Sizeof, "sizeof"); + (52, Typeof, "typeof"); + (53, Unsized, "unsized"); + (54, Yield, "yield"); + (55, Do, "do"); + (56, Abstract, "abstract"); + (57, Final, "final"); + (58, Override, "override"); } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5b57a875c4a..c1515a36bec 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2663,12 +2663,10 @@ impl<'a> State<'a> { } else if opt_sigil == Some('&') { try!(self.print_fn_style(fn_style)); try!(self.print_extern_opt_abi(opt_abi)); - try!(self.print_onceness(onceness)); } else { assert!(opt_sigil.is_none()); try!(self.print_fn_style(fn_style)); try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi)); - try!(self.print_onceness(onceness)); try!(word(&mut self.s, "fn")); } @@ -2987,13 +2985,6 @@ impl<'a> State<'a> { ast::UnsafeFn => self.word_nbsp("unsafe"), } } - - pub fn print_onceness(&mut self, o: ast::Onceness) -> IoResult<()> { - match o { - ast::Once => self.word_nbsp("once"), - ast::Many => Ok(()) - } - } } #[cfg(test)] diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs deleted file mode 100644 index 17968195280..00000000000 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. - -#![feature(once_fns)] -use std::sync::Arc; - -fn foo(blk: once ||) { - blk(); - blk(); //~ ERROR use of moved value -} - -fn main() { - let x = Arc::new(true); - foo(|| { - assert!(*x); - drop(x); - }) -} diff --git a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs deleted file mode 100644 index 3efebf61844..00000000000 --- a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. - -use std::sync::Arc; - -fn foo(blk: ||) { - blk(); - blk(); -} - -fn main() { - let x = Arc::new(true); - foo(|| { - assert!(*x); - drop(x); //~ ERROR cannot move out of captured outer variable - }) -} diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs deleted file mode 100644 index 7594deda3b2..00000000000 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(once_fns)] -fn main() { - let f: once || = ||(); - let g: || = f; //~ ERROR mismatched types - let h: || = ||(); - let i: once || = h; // ok -} diff --git a/src/test/run-pass/once-move-out-on-heap.rs b/src/test/run-pass/once-move-out-on-heap.rs index dfd5992a406..e24e809ed01 100644 --- a/src/test/run-pass/once-move-out-on-heap.rs +++ b/src/test/run-pass/once-move-out-on-heap.rs @@ -11,7 +11,6 @@ // Testing guarantees provided by once functions. -#![feature(once_fns)] use std::sync::Arc; fn foo(blk: proc()) { diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs deleted file mode 100644 index 0419fc54add..00000000000 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing guarantees provided by once functions. - - -#![feature(once_fns)] -use std::sync::Arc; - -fn foo(blk: once ||) { - blk(); -} - -pub fn main() { - let x = Arc::new(true); - foo(|| { - assert!(*x); - drop(x); - }) -}