Skip to content

Commit f5676a1

Browse files
committed
---
yaml --- r: 83160 b: refs/heads/auto c: 88ab38c h: refs/heads/master v: v3
1 parent abdf67b commit f5676a1

File tree

15 files changed

+47
-111
lines changed

15 files changed

+47
-111
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 5d8e494a8c7d668eaac80fea59091a6e8fd70368
16+
refs/heads/auto: 88ab38cf060b794f3c4c3572cee7ca25354946d6
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/rust.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,10 @@ The currently implemented features of the compiler are:
20672067
For now this style of variant is hidden behind a feature
20682068
flag.
20692069

2070+
* `once_fns` - Onceness guarantees a closure is only executed once. Defining a
2071+
closure as `once` is unlikely to be supported going forward. So
2072+
they are hidden behind this feature until they are to be removed.
2073+
20702074
If a feature is promoted to a language feature, then all existing programs will
20712075
start to receive compilation warnings about #[feature] directives which enabled
20722076
the new feature (because the directive is no longer necessary). However, if

branches/auto/src/librustc/driver/session.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -74,12 +74,11 @@ pub static statik: uint = 1 << 21;
7474
pub static print_link_args: uint = 1 << 22;
7575
pub static no_debug_borrows: uint = 1 << 23;
7676
pub static lint_llvm: uint = 1 << 24;
77-
pub static once_fns: uint = 1 << 25;
78-
pub static print_llvm_passes: uint = 1 << 26;
79-
pub static no_vectorize_loops: uint = 1 << 27;
80-
pub static no_vectorize_slp: uint = 1 << 28;
81-
pub static no_prepopulate_passes: uint = 1 << 29;
82-
pub static use_softfp: uint = 1 << 30;
77+
pub static print_llvm_passes: uint = 1 << 25;
78+
pub static no_vectorize_loops: uint = 1 << 26;
79+
pub static no_vectorize_slp: uint = 1 << 27;
80+
pub static no_prepopulate_passes: uint = 1 << 28;
81+
pub static use_softfp: uint = 1 << 29;
8382

8483
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
8584
~[("verbose", "in general, enable more debug printouts", verbose),
@@ -118,9 +117,6 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] {
118117
("lint-llvm",
119118
"Run the LLVM lint pass on the pre-optimization IR",
120119
lint_llvm),
121-
("once-fns",
122-
"Allow 'once fn' closures to deinitialize captured variables",
123-
once_fns),
124120
("print-llvm-passes",
125121
"Prints the llvm optimization passes being run",
126122
print_llvm_passes),
@@ -326,7 +322,6 @@ impl Session_ {
326322
pub fn debug_borrows(&self) -> bool {
327323
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
328324
}
329-
pub fn once_fns(&self) -> bool { self.debugging_opt(once_fns) }
330325
pub fn print_llvm_passes(&self) -> bool {
331326
self.debugging_opt(print_llvm_passes)
332327
}

branches/auto/src/librustc/front/feature_gate.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
3333
("globs", Active),
3434
("macro_rules", Active),
3535
("struct_variant", Active),
36+
("once_fns", Active),
3637

3738
// These are used to test this portion of the compiler, they don't actually
3839
// mean anything
@@ -126,6 +127,20 @@ impl Visitor<()> for Context {
126127

127128
visit::walk_item(self, i, ());
128129
}
130+
131+
fn visit_ty(&mut self, t: &ast::Ty, _: ()) {
132+
match t.node {
133+
ast::ty_closure(closure) if closure.onceness == ast::Once => {
134+
self.gate_feature("once_fns", t.span,
135+
"once functions are \
136+
experimental and likely to be removed");
137+
138+
},
139+
_ => {}
140+
}
141+
142+
visit::walk_ty(self, t, ());
143+
}
129144
}
130145

131146
pub fn check_crate(sess: Session, crate: &ast::Crate) {

branches/auto/src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -102,25 +102,13 @@ fn check_is_legal_to_move_from(bccx: &BorrowckCtxt,
102102
match cmt.cat {
103103
mc::cat_deref(_, _, mc::region_ptr(*)) |
104104
mc::cat_deref(_, _, mc::gc_ptr(*)) |
105-
mc::cat_deref(_, _, mc::unsafe_ptr(*)) => {
106-
bccx.span_err(
107-
cmt0.span,
108-
format!("cannot move out of {}",
109-
bccx.cmt_to_str(cmt)));
110-
false
111-
}
112-
113-
// These are separate from the above cases for a better error message.
105+
mc::cat_deref(_, _, mc::unsafe_ptr(*)) |
114106
mc::cat_stack_upvar(*) |
115107
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, _ }) => {
116-
let once_hint = if bccx.tcx.sess.once_fns() {
117-
" (unless the destination closure type is `once fn')"
118-
} else {
119-
""
120-
};
121108
bccx.span_err(
122109
cmt0.span,
123-
format!("cannot move out of {}{}", bccx.cmt_to_str(cmt), once_hint));
110+
format!("cannot move out of {}",
111+
bccx.cmt_to_str(cmt)));
124112
false
125113
}
126114

branches/auto/src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -508,12 +508,10 @@ impl mem_categorization_ctxt {
508508
let var_is_refd = match (closure_ty.sigil, closure_ty.onceness) {
509509
// Many-shot stack closures can never move out.
510510
(ast::BorrowedSigil, ast::Many) => true,
511-
// 1-shot stack closures can move out with "-Z once-fns".
512-
(ast::BorrowedSigil, ast::Once)
513-
if self.tcx.sess.once_fns() => false,
514-
(ast::BorrowedSigil, ast::Once) => true,
511+
// 1-shot stack closures can move out.
512+
(ast::BorrowedSigil, ast::Once) => false,
515513
// Heap closures always capture by copy/move, and can
516-
// move out iff they are once.
514+
// move out if they are once.
517515
(ast::OwnedSigil, _) |
518516
(ast::ManagedSigil, _) => false,
519517

branches/auto/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3645,7 +3645,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
36453645
let fty = ty::mk_closure(ccx.tcx, ty::ClosureTy {
36463646
purity: ast::impure_fn,
36473647
sigil: ast::BorrowedSigil,
3648-
onceness: ast::Once,
3648+
onceness: ast::Many,
36493649
region: ty::re_bound(ty::br_anon(0)),
36503650
bounds: ty::EmptyBuiltinBounds(),
36513651
sig: ty::FnSig {

branches/auto/src/libstd/num/num.rs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,21 @@ pub trait Orderable: Ord {
4242
fn clamp(&self, mn: &Self, mx: &Self) -> Self;
4343
}
4444

45-
/// Return the smaller number.
4645
#[inline(always)] pub fn min<T: Orderable>(x: T, y: T) -> T { x.min(&y) }
47-
/// Return the larger number.
4846
#[inline(always)] pub fn max<T: Orderable>(x: T, y: T) -> T { x.max(&y) }
49-
/// Returns the number constrained within the range `mn <= self <= mx`.
5047
#[inline(always)] pub fn clamp<T: Orderable>(value: T, mn: T, mx: T) -> T { value.clamp(&mn, &mx) }
5148

5249
pub trait Zero {
5350
fn zero() -> Self; // FIXME (#5527): This should be an associated constant
5451
fn is_zero(&self) -> bool;
5552
}
5653

57-
/// Returns `0` of appropriate type.
5854
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }
5955

6056
pub trait One {
6157
fn one() -> Self; // FIXME (#5527): This should be an associated constant
6258
}
6359

64-
/// Returns `1` of appropriate type.
6560
#[inline(always)] pub fn one<T: One>() -> T { One::one() }
6661

6762
pub trait Signed: Num
@@ -74,26 +69,8 @@ pub trait Signed: Num
7469
fn is_negative(&self) -> bool;
7570
}
7671

77-
/// Computes the absolute value.
78-
///
79-
/// For float, f32, and f64, `NaN` will be returned if the number is `NaN`
8072
#[inline(always)] pub fn abs<T: Signed>(value: T) -> T { value.abs() }
81-
/// The positive difference of two numbers.
82-
///
83-
/// Returns `zero` if the number is less than or equal to `other`,
84-
/// otherwise the difference between `self` and `other` is returned.
8573
#[inline(always)] pub fn abs_sub<T: Signed>(x: T, y: T) -> T { x.abs_sub(&y) }
86-
/// Returns the sign of the number.
87-
///
88-
/// For float, f32, f64:
89-
/// - `1.0` if the number is positive, `+0.0` or `infinity`
90-
/// - `-1.0` if the number is negative, `-0.0` or `neg_infinity`
91-
/// - `NaN` if the number is `NaN`
92-
///
93-
/// For int:
94-
/// - `0` if the number is zero
95-
/// - `1` if the number is positive
96-
/// - `-1` if the number is negative
9774
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
9875

9976
pub trait Unsigned: Num {}
@@ -129,11 +106,7 @@ pub trait Integer: Num
129106
fn is_odd(&self) -> bool;
130107
}
131108

132-
/// Calculates the Greatest Common Divisor (GCD) of the number and `other`.
133-
///
134-
/// The result is always positive.
135109
#[inline(always)] pub fn gcd<T: Integer>(x: T, y: T) -> T { x.gcd(&y) }
136-
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
137110
#[inline(always)] pub fn lcm<T: Integer>(x: T, y: T) -> T { x.lcm(&y) }
138111

139112
pub trait Round {
@@ -159,23 +132,10 @@ pub trait Algebraic {
159132
fn hypot(&self, other: &Self) -> Self;
160133
}
161134

162-
/// Raise a number to a power.
163-
///
164-
/// # Example
165-
///
166-
/// ```rust
167-
/// let sixteen: float = num::pow(2.0, 4.0);
168-
/// assert_eq!(sixteen, 16.0);
169-
/// ```
170135
#[inline(always)] pub fn pow<T: Algebraic>(value: T, n: T) -> T { value.pow(&n) }
171-
/// Take the squre root of a number.
172136
#[inline(always)] pub fn sqrt<T: Algebraic>(value: T) -> T { value.sqrt() }
173-
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
174137
#[inline(always)] pub fn rsqrt<T: Algebraic>(value: T) -> T { value.rsqrt() }
175-
/// Take the cubic root of a number.
176138
#[inline(always)] pub fn cbrt<T: Algebraic>(value: T) -> T { value.cbrt() }
177-
/// Calculate the length of the hypotenuse of a right-angle triangle given legs of length `x` and
178-
/// `y`.
179139
#[inline(always)] pub fn hypot<T: Algebraic>(x: T, y: T) -> T { x.hypot(&y) }
180140

181141
pub trait Trigonometric {
@@ -191,23 +151,15 @@ pub trait Trigonometric {
191151
fn sin_cos(&self) -> (Self, Self);
192152
}
193153

194-
/// Sine function.
195154
#[inline(always)] pub fn sin<T: Trigonometric>(value: T) -> T { value.sin() }
196-
/// Cosine function.
197155
#[inline(always)] pub fn cos<T: Trigonometric>(value: T) -> T { value.cos() }
198-
/// Tangent function.
199156
#[inline(always)] pub fn tan<T: Trigonometric>(value: T) -> T { value.tan() }
200157

201-
/// Compute the arcsine of the number.
202158
#[inline(always)] pub fn asin<T: Trigonometric>(value: T) -> T { value.asin() }
203-
/// Compute the arccosine of the number.
204159
#[inline(always)] pub fn acos<T: Trigonometric>(value: T) -> T { value.acos() }
205-
/// Compute the arctangent of the number.
206160
#[inline(always)] pub fn atan<T: Trigonometric>(value: T) -> T { value.atan() }
207161

208-
/// Compute the arctangent with 2 arguments.
209162
#[inline(always)] pub fn atan2<T: Trigonometric>(x: T, y: T) -> T { x.atan2(&y) }
210-
/// Simultaneously computes the sine and cosine of the number.
211163
#[inline(always)] pub fn sin_cos<T: Trigonometric>(value: T) -> (T, T) { value.sin_cos() }
212164

213165
pub trait Exponential {
@@ -220,18 +172,12 @@ pub trait Exponential {
220172
fn log10(&self) -> Self;
221173
}
222174

223-
/// Returns `e^(value)`, (the exponential function).
224175
#[inline(always)] pub fn exp<T: Exponential>(value: T) -> T { value.exp() }
225-
/// Returns 2 raised to the power of the number, `2^(value)`.
226176
#[inline(always)] pub fn exp2<T: Exponential>(value: T) -> T { value.exp2() }
227177

228-
/// Returns the natural logarithm of the number.
229178
#[inline(always)] pub fn ln<T: Exponential>(value: T) -> T { value.ln() }
230-
/// Returns the logarithm of the number with respect to an arbitrary base.
231179
#[inline(always)] pub fn log<T: Exponential>(value: T, base: T) -> T { value.log(&base) }
232-
/// Returns the base 2 logarithm of the number.
233180
#[inline(always)] pub fn log2<T: Exponential>(value: T) -> T { value.log2() }
234-
/// Returns the base 10 logarithm of the number.
235181
#[inline(always)] pub fn log10<T: Exponential>(value: T) -> T { value.log10() }
236182

237183
pub trait Hyperbolic: Exponential {
@@ -244,18 +190,12 @@ pub trait Hyperbolic: Exponential {
244190
fn atanh(&self) -> Self;
245191
}
246192

247-
/// Hyperbolic cosine function.
248193
#[inline(always)] pub fn sinh<T: Hyperbolic>(value: T) -> T { value.sinh() }
249-
/// Hyperbolic sine function.
250194
#[inline(always)] pub fn cosh<T: Hyperbolic>(value: T) -> T { value.cosh() }
251-
/// Hyperbolic tangent function.
252195
#[inline(always)] pub fn tanh<T: Hyperbolic>(value: T) -> T { value.tanh() }
253196

254-
/// Inverse hyperbolic sine function.
255197
#[inline(always)] pub fn asinh<T: Hyperbolic>(value: T) -> T { value.asinh() }
256-
/// Inverse hyperbolic cosine function.
257198
#[inline(always)] pub fn acosh<T: Hyperbolic>(value: T) -> T { value.acosh() }
258-
/// Inverse hyperbolic tangent function.
259199
#[inline(always)] pub fn atanh<T: Hyperbolic>(value: T) -> T { value.atanh() }
260200

261201
/// Defines constants and methods common to real numbers
@@ -405,16 +345,8 @@ pub trait Float: Real
405345
fn next_after(&self, other: Self) -> Self;
406346
}
407347

408-
/// Returns the exponential of the number, minus `1`, `exp(n) - 1`, in a way
409-
/// that is accurate even if the number is close to zero.
410348
#[inline(always)] pub fn exp_m1<T: Float>(value: T) -> T { value.exp_m1() }
411-
/// Returns the natural logarithm of the number plus `1`, `ln(n + 1)`, more
412-
/// accurately than if the operations were performed separately.
413349
#[inline(always)] pub fn ln_1p<T: Float>(value: T) -> T { value.ln_1p() }
414-
/// Fused multiply-add. Computes `(a * b) + c` with only one rounding error.
415-
///
416-
/// This produces a more accurate result with better performance (on some
417-
/// architectures) than a separate multiplication operation followed by an add.
418350
#[inline(always)] pub fn mul_add<T: Float>(a: T, b: T, c: T) -> T { a.mul_add(b, c) }
419351

420352
/// A generic trait for converting a value to a number.
@@ -856,7 +788,7 @@ impl_from_primitive!(u64, n.to_u64())
856788
impl_from_primitive!(f32, n.to_f32())
857789
impl_from_primitive!(f64, n.to_f64())
858790

859-
/// Cast from one machine scalar to another.
791+
/// Cast from one machine scalar to another
860792
///
861793
/// # Example
862794
///
@@ -909,7 +841,7 @@ pub trait FromStrRadix {
909841
fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
910842
}
911843

912-
/// A utility function that just calls FromStrRadix::from_str_radix.
844+
/// A utility function that just calls FromStrRadix::from_str_radix
913845
pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: uint) -> Option<T> {
914846
FromStrRadix::from_str_radix(str, radix)
915847
}

branches/auto/src/libstd/unstable/intrinsics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ extern "rust-intrinsic" {
331331

332332
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
333333

334-
pub fn frame_address(f: &once fn(*u8));
334+
#[cfg(not(stage0))]
335+
pub fn frame_address(f: &fn(*u8));
335336

336337
/// Get the address of the `__morestack` stack growth function.
337338
pub fn morestack_addr() -> *();

branches/auto/src/test/compile-fail/once-cant-call-twice-on-heap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// Testing guarantees provided by once functions.
1212
// This program would segfault if it were legal.
1313

14+
#[feature(once_fns)];
1415
extern mod extra;
1516
use extra::arc;
1617
use std::util;

branches/auto/src/test/compile-fail/once-cant-call-twice-on-stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Testing guarantees provided by once functions.
1212
// This program would segfault if it were legal.
1313

14-
// compile-flags:-Z once-fns
14+
#[feature(once_fns)];
1515
extern mod extra;
1616
use extra::arc;
1717
use std::util;

branches/auto/src/test/compile-fail/once-fn-subtyping.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(once_fns)];
1112
fn main() {
1213
let f: &once fn() = ||();
1314
let g: &fn() = f; //~ ERROR mismatched types

branches/auto/src/test/run-pass/intrinsic-frame-address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -12,7 +12,7 @@
1212

1313
mod rusti {
1414
extern "rust-intrinsic" {
15-
pub fn frame_address(f: &once fn(*u8));
15+
pub fn frame_address(f: &fn(*u8));
1616
}
1717
}
1818

0 commit comments

Comments
 (0)