Skip to content

Commit 206947a

Browse files
author
Grigoriy
committed
---
yaml --- r: 80980 b: refs/heads/snap-stage3 c: eb519b9 h: refs/heads/master v: v3
1 parent 11c5edf commit 206947a

File tree

17 files changed

+65
-364
lines changed

17 files changed

+65
-364
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: a95604fcaacf9cbad5f57b8c08e1b3e871462e9c
4+
refs/heads/snap-stage3: eb519b952d2cc2b2af6b3be38377daa431983929
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ endif
102102

103103
ifdef CFG_ENABLE_DEBUG
104104
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
105+
CFG_RUSTC_FLAGS += --cfg debug
105106
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
106107
else
107-
CFG_RUSTC_FLAGS += --cfg ndebug
108108
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
109109
endif
110110

branches/snap-stage3/RELEASES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Version 0.8 (October 2013)
1010
* Many trait inheritance bugs fixed.
1111
* Owned and borrowed trait objects work more reliably.
1212
* `copy` is no longer a keyword. It has been replaced by the `Clone` trait.
13-
* rustc can omit emission of code for the `debug!` macro if it is passed
14-
`--cfg ndebug`
13+
* rustc no longer emits code for the `debug!` macro unless it is passed
14+
`--cfg debug`
1515
* mod.rs is now "blessed". When loading `mod foo;`, rustc will now look
1616
for foo.rs, then foo/mod.rs, and will generate an error when both are
1717
present.

branches/snap-stage3/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ opt optimize-cxx 1 "build optimized C++ code"
373373
opt optimize-llvm 1 "build optimized LLVM"
374374
opt optimize-tests 1 "build tests with optimizations"
375375
opt llvm-assertions 1 "build LLVM with assertions"
376-
opt debug 1 "build with extra debug fun"
376+
opt debug 0 "build with extra debug fun"
377377
opt ratchet-bench 0 "ratchet benchmarks"
378378
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
379379
opt manage-submodules 1 "let the build manage the git submodules"

branches/snap-stage3/doc/rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,8 +3428,8 @@ sign (`=`) followed by the log level, from 1 to 4, inclusive. Level 1
34283428
is the error level, 2 is warning, 3 info, and 4 debug. You can also
34293429
use the symbolic constants `error`, `warn`, `info`, and `debug`. Any
34303430
logs less than or equal to the specified level will be output. If not
3431-
specified then log level 4 is assumed. Debug messages can be omitted
3432-
by passing `--cfg ndebug` to `rustc`.
3431+
specified then log level 4 is assumed. However, debug messages are
3432+
only available if `--cfg=debug` is passed to `rustc`.
34333433

34343434
As an example, to see all the logs generated by the compiler, you would set
34353435
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link`

branches/snap-stage3/man/rustpkg.1

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ Remove all generated files from the \fIbuild\fR directory in the target's worksp
2727
Builds the specified target, and all its dependencies, and then installs the
2828
build products into the \fIlib\fR and \fIbin\fR directories of their respective
2929
workspaces.
30-
.TP
31-
\fBinit\fR
32-
Initializes the current working directory into a workspace.
3330

3431
.SS "BUILD COMMAND"
3532

@@ -62,17 +59,6 @@ Examples:
6259
$ rustpkg install github.com/mozilla/servo.git#1.2
6360
$ rustpkg install rust-glfw
6461

65-
.SS "INIT COMMAND"
66-
67-
rustpkg init
68-
69-
This will turn the current working directory into a workspace. The first
70-
command you run when starting off a new project.
71-
72-
Example:
73-
74-
$ rustpkg init
75-
7662
.SH "ENVIRONMENT"
7763

7864
.TP

branches/snap-stage3/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
575575

576576
# The tests select when to use debug configuration on their own;
577577
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
578-
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
578+
CTEST_RUSTC_FLAGS := $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS))
579579

580580
# The tests can not be optimized while the rest of the compiler is optimized, so
581581
# filter out the optimization (if any) from rustc and then figure out if we need

branches/snap-stage3/src/libstd/c_str.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
12-
13-
C-string manipulation and management
14-
15-
This modules provides the basic methods for creating and manipulating
16-
null-terminated strings for use with FFI calls (back to C). Most C APIs require
17-
that the string being passed to them is null-terminated, and by default rust's
18-
string types are *not* null terminated.
19-
20-
The other problem with translating Rust strings to C strings is that Rust
21-
strings can validly contain a null-byte in the middle of the string (0 is a
22-
valid unicode codepoint). This means that not all Rust strings can actually be
23-
translated to C strings.
24-
25-
# Creation of a C string
26-
27-
A C string is managed through the `CString` type defined in this module. It
28-
"owns" the internal buffer of characters and will automatically deallocate the
29-
buffer when the string is dropped. The `ToCStr` trait is implemented for `&str`
30-
and `&[u8]`, but the conversions can fail due to some of the limitations
31-
explained above.
32-
33-
This also means that currently whenever a C string is created, an allocation
34-
must be performed to place the data elsewhere (the lifetime of the C string is
35-
not tied to the lifetime of the original string/data buffer). If C strings are
36-
heavily used in applications, then caching may be advisable to prevent
37-
unnecessary amounts of allocations.
38-
39-
An example of creating and using a C string would be:
40-
41-
~~~{.rust}
42-
use std::libc;
43-
externfn!(fn puts(s: *libc::c_char))
44-
45-
let my_string = "Hello, world!";
46-
47-
// Allocate the C string with an explicit local that owns the string. The
48-
// `c_buffer` pointer will be deallocated when `my_c_string` goes out of scope.
49-
let my_c_string = my_string.to_c_str();
50-
do my_c_string.with_ref |c_buffer| {
51-
unsafe { puts(c_buffer); }
52-
}
53-
54-
// Don't save off the allocation of the C string, the `c_buffer` will be
55-
// deallocated when this block returns!
56-
do my_string.with_c_str |c_buffer| {
57-
unsafe { puts(c_buffer); }
58-
}
59-
~~~
60-
61-
*/
62-
6311
use cast;
6412
use iter::{Iterator, range};
6513
use libc;

branches/snap-stage3/src/libstd/condition.rs

Lines changed: 33 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -8,179 +8,71 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
11+
/*! Condition handling */
1212

13-
Condition handling
14-
15-
Conditions are a utility used to deal with handling error conditions. The syntax
16-
of a condition handler strikes a resemblance to try/catch blocks in other
17-
languages, but condition handlers are *not* a form of exception handling in the
18-
same manner.
19-
20-
A condition is declared through the `condition!` macro provided by the compiler:
21-
22-
~~~{.rust}
23-
condition! {
24-
pub my_error: int -> ~str;
25-
}
26-
~~~
27-
28-
This macro declares an inner module called `my_error` with one static variable,
29-
`cond` that is a static `Condition` instance. To help understand what the other
30-
parameters are used for, an example usage of this condition would be:
31-
32-
~~~{.rust}
33-
do my_error::cond.trap(|raised_int| {
34-
35-
// the condition `my_error` was raised on, and the value it raised is stored
36-
// in `raised_int`. This closure must return a `~str` type (as specified in
37-
// the declaration of the condition
38-
if raised_int == 3 { ~"three" } else { ~"oh well" }
39-
40-
}).inside {
41-
42-
// The condition handler above is installed for the duration of this block.
43-
// That handler will override any previous handler, but the previous handler
44-
// is restored when this block returns (handlers nest)
45-
//
46-
// If any code from this block (or code from another block) raises on the
47-
// condition, then the above handler will be invoked (so long as there's no
48-
// other nested handler).
49-
50-
println(my_error::cond.raise(3)); // prints "three"
51-
println(my_error::cond.raise(4)); // prints "oh well"
52-
53-
}
54-
~~~
55-
56-
Condition handling is useful in cases where propagating errors is either to
57-
cumbersome or just not necessary in the first place. It should also be noted,
58-
though, that if there is not handler installed when a condition is raised, then
59-
the task invokes `fail!()` and will terminate.
60-
61-
## More Info
62-
63-
Condition handlers as an error strategy is well explained in the [conditions
64-
tutorial](http://static.rust-lang.org/doc/master/tutorial-conditions.html),
65-
along with comparing and contrasting it with other error handling strategies.
66-
67-
*/
13+
#[allow(missing_doc)];
6814

6915
use local_data;
7016
use prelude::*;
71-
use unstable::raw::Closure;
7217

73-
#[doc(hidden)]
18+
// helper for transmutation, shown below.
19+
type RustClosure = (int, int);
20+
7421
pub struct Handler<T, U> {
75-
priv handle: Closure,
76-
priv prev: Option<@Handler<T, U>>,
22+
handle: RustClosure,
23+
prev: Option<@Handler<T, U>>,
7724
}
7825

79-
/// This struct represents the state of a condition handler. It contains a key
80-
/// into TLS which holds the currently install handler, along with the name of
81-
/// the condition (useful for debugging).
82-
///
83-
/// This struct should never be created directly, but rather only through the
84-
/// `condition!` macro provided to all libraries using libstd.
8526
pub struct Condition<T, U> {
86-
/// Name of the condition handler
8727
name: &'static str,
88-
/// TLS key used to insert/remove values in TLS.
8928
key: local_data::Key<@Handler<T, U>>
9029
}
9130

9231
impl<T, U> Condition<T, U> {
93-
/// Creates an object which binds the specified handler. This will also save
94-
/// the current handler *on creation* such that when the `Trap` is consumed,
95-
/// it knows which handler to restore.
96-
///
97-
/// # Example
98-
///
99-
/// ~~~{.rust}
100-
/// condition! { my_error: int -> int; }
101-
///
102-
/// let trap = my_error::cond.trap(|error| error + 3);
103-
///
104-
/// // use `trap`'s inside method to register the handler and then run a
105-
/// // block of code with the handler registered
106-
/// ~~~
10732
pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
108-
let h: Closure = unsafe { ::cast::transmute(h) };
109-
let prev = local_data::get(self.key, |k| k.map(|&x| *x));
110-
let h = @Handler { handle: h, prev: prev };
111-
Trap { cond: self, handler: h }
33+
unsafe {
34+
let p : *RustClosure = ::cast::transmute(&h);
35+
let prev = local_data::get(self.key, |k| k.map(|&x| *x));
36+
let h = @Handler { handle: *p, prev: prev };
37+
Trap { cond: self, handler: h }
38+
}
11239
}
11340

114-
/// Raises on this condition, invoking any handler if one has been
115-
/// registered, or failing the current task otherwise.
116-
///
117-
/// While a condition handler is being run, the condition will have no
118-
/// handler listed, so a task failure will occur if the condition is
119-
/// re-raised during the handler.
120-
///
121-
/// # Arguments
122-
///
123-
/// * t - The argument to pass along to the condition handler.
124-
///
125-
/// # Return value
126-
///
127-
/// If a handler is found, its return value is returned, otherwise this
128-
/// function will not return.
12941
pub fn raise(&self, t: T) -> U {
13042
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
13143
self.raise_default(t, || fail!(msg.clone()))
13244
}
13345

134-
/// Performs the same functionality as `raise`, except that when no handler
135-
/// is found the `default` argument is called instead of failing the task.
13646
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
137-
match local_data::pop(self.key) {
138-
None => {
139-
debug!("Condition.raise: found no handler");
140-
default()
141-
}
142-
Some(handler) => {
143-
debug!("Condition.raise: found handler");
144-
match handler.prev {
145-
None => {}
146-
Some(hp) => local_data::set(self.key, hp)
47+
unsafe {
48+
match local_data::pop(self.key) {
49+
None => {
50+
debug!("Condition.raise: found no handler");
51+
default()
52+
}
53+
Some(handler) => {
54+
debug!("Condition.raise: found handler");
55+
match handler.prev {
56+
None => {}
57+
Some(hp) => local_data::set(self.key, hp)
58+
}
59+
let handle : &fn(T) -> U =
60+
::cast::transmute(handler.handle);
61+
let u = handle(t);
62+
local_data::set(self.key, handler);
63+
u
14764
}
148-
let handle : &fn(T) -> U = unsafe {
149-
::cast::transmute(handler.handle)
150-
};
151-
let u = handle(t);
152-
local_data::set(self.key, handler);
153-
u
15465
}
15566
}
15667
}
15768
}
15869

159-
/// A `Trap` is created when the `trap` method is invoked on a `Condition`, and
160-
/// it is used to actually bind a handler into the TLS slot reserved for this
161-
/// condition.
162-
///
163-
/// Normally this object is not dealt with directly, but rather it's directly
164-
/// used after being returned from `trap`
16570
struct Trap<'self, T, U> {
166-
priv cond: &'self Condition<T, U>,
167-
priv handler: @Handler<T, U>
71+
cond: &'self Condition<T, U>,
72+
handler: @Handler<T, U>
16873
}
16974

17075
impl<'self, T, U> Trap<'self, T, U> {
171-
/// Execute a block of code with this trap handler's exception handler
172-
/// registered.
173-
///
174-
/// # Example
175-
///
176-
/// ~~~{.rust}
177-
/// condition! { my_error: int -> int; }
178-
///
179-
/// let result = do my_error::cond.trap(|error| error + 3).inside {
180-
/// my_error::cond.raise(4)
181-
/// };
182-
/// assert_eq!(result, 7);
183-
/// ~~~
18476
pub fn inside<V>(&self, inner: &'self fn() -> V) -> V {
18577
let _g = Guard { cond: self.cond };
18678
debug!("Trap: pushing handler to TLS");
@@ -189,9 +81,8 @@ impl<'self, T, U> Trap<'self, T, U> {
18981
}
19082
}
19183

192-
#[doc(hidden)]
19384
struct Guard<'self, T, U> {
194-
priv cond: &'self Condition<T, U>
85+
cond: &'self Condition<T, U>
19586
}
19687

19788
#[unsafe_destructor]

branches/snap-stage3/src/libstd/fmt/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@
1010

1111
/*!
1212
13-
The Formatting Module
13+
# The Formatting Module
1414
15-
This module contains the runtime support for the `format!` syntax extension.
16-
This macro is implemented in the compiler to emit calls to this module in order
17-
to format arguments at runtime into strings and streams.
15+
This module contains the runtime support for the `format!` syntax extension. This
16+
macro is implemented in the compiler to emit calls to this module in order to
17+
format arguments at runtime into strings and streams.
1818
1919
The functions contained in this module should not normally be used in everyday
20-
use cases of `format!`. The assumptions made by these functions are unsafe for
21-
all inputs, and the compiler performs a large amount of validation on the
22-
arguments to `format!` in order to ensure safety at runtime. While it is
23-
possible to call these functions directly, it is not recommended to do so in the
24-
general case.
20+
use cases of `format!`. The assumptions made by these functions are unsafe for all
21+
inputs, and the compiler performs a large amount of validation on the arguments
22+
to `format!` in order to ensure safety at runtime. While it is possible to call
23+
these functions directly, it is not recommended to do so in the general case.
2524
2625
## Usage
2726

0 commit comments

Comments
 (0)