Skip to content

Commit 6549646

Browse files
committed
---
yaml --- r: 114583 b: refs/heads/auto c: 0e8e0b2 h: refs/heads/master i: 114581: 8abd550 114579: 1d011e0 114575: 6280c33 v: v3
1 parent e8c4c13 commit 6549646

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+242
-515
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: f5bb16f76ea70c4fdefcbb307564be5c5c54c785
16+
refs/heads/auto: 0e8e0b2ede175be6a4874700674b259c8c63c2cc
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/LICENSE-MIT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Copyright (c) 2014 The Rust Project Developers
1+
Copyright (c) 2006-2009 Graydon Hoare
2+
Copyright (c) 2009-2014 Mozilla Foundation
23

34
Permission is hereby granted, free of charge, to any
45
person obtaining a copy of this software and associated

branches/auto/src/doc/guide-pointers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ enum List<T> {
186186
Nil,
187187
Cons(T, ~List<T>),
188188
}
189-
189+
190190
fn main() {
191191
let list: List<int> = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
192192
println!("{:?}", list);
@@ -251,7 +251,7 @@ struct.
251251

252252
> **Note**: the `@` form of managed pointers is deprecated and behind a
253253
> feature gate (it requires a `#![feature(managed_pointers)]` attribute on
254-
> the crate root). There are replacements, currently
254+
> the crate root; remember the semicolon!). There are replacements, currently
255255
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
256256
> counting and garbage collection respectively.
257257
@@ -266,7 +266,7 @@ struct Point {
266266
x: int,
267267
y: int,
268268
}
269-
269+
270270
fn main() {
271271
let a = ~Point { x: 10, y: 20 };
272272
let b = a;
@@ -297,7 +297,7 @@ struct Point {
297297
x: int,
298298
y: int,
299299
}
300-
300+
301301
fn main() {
302302
let a = @Point { x: 10, y: 20 };
303303
let b = a;
@@ -361,7 +361,7 @@ So how is this hard? Well, because we're ignoring ownership, the compiler needs
361361
to take great care to make sure that everything is safe. Despite their complete
362362
safety, a reference's representation at runtime is the same as that of
363363
an ordinary pointer in a C program. They introduce zero overhead. The compiler
364-
does all safety checks at compile time.
364+
does all safety checks at compile time.
365365

366366
This theory is called 'region pointers,' and involve a concept called
367367
'lifetimes'. Here's the simple explanation: would you expect this code to
@@ -477,7 +477,7 @@ fn main() {
477477
You may think that this gives us terrible performance: return a value and then
478478
immediately box it up?!?! Isn't that the worst of both worlds? Rust is smarter
479479
than that. There is no copy in this code. `main` allocates enough room for the
480-
`@int`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes
480+
`@int`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes
481481
the value straight into that pointer. This writes the return value directly into
482482
the allocated box.
483483

branches/auto/src/doc/guide-tasks.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ concurrency at this writing:
4848
* [`std::task`] - All code relating to tasks and task scheduling,
4949
* [`std::comm`] - The message passing interface,
5050
* [`sync::DuplexStream`] - An extension of `pipes::stream` that allows both sending and receiving,
51+
* [`sync::SyncSender`] - An extension of `pipes::stream` that provides synchronous message sending,
52+
* [`sync::SyncReceiver`] - An extension of `pipes::stream` that acknowledges each message received,
53+
* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the
54+
message is received.
5155
* [`sync::Arc`] - The Arc (atomically reference counted) type, for safely sharing immutable data,
56+
* [`sync::RWArc`] - A dual-mode Arc protected by a reader-writer lock,
57+
* [`sync::MutexArc`] - An Arc with mutable data protected by a blocking mutex,
5258
* [`sync::Semaphore`] - A counting, blocking, bounded-waiting semaphore,
5359
* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated
5460
FIFO condition variable,
@@ -64,8 +70,13 @@ concurrency at this writing:
6470
[`std::task`]: std/task/index.html
6571
[`std::comm`]: std/comm/index.html
6672
[`sync::DuplexStream`]: sync/struct.DuplexStream.html
73+
[`sync::SyncSender`]: sync/struct.SyncSender.html
74+
[`sync::SyncReceiver`]: sync/struct.SyncReceiver.html
75+
[`sync::rendezvous`]: sync/fn.rendezvous.html
6776
[`sync::Arc`]: sync/struct.Arc.html
68-
[`sync::Semaphore`]: sync/raw/struct.Semaphore.html
77+
[`sync::RWArc`]: sync/struct.RWArc.html
78+
[`sync::MutexArc`]: sync/struct.MutexArc.html
79+
[`sync::Semaphore`]: sync/struct.Semaphore.html
6980
[`sync::Mutex`]: sync/struct.Mutex.html
7081
[`sync::RWLock`]: sync/struct.RWLock.html
7182
[`sync::Barrier`]: sync/struct.Barrier.html
@@ -90,8 +101,6 @@ fn print_message() { println!("I am running in a different task!"); }
90101
spawn(print_message);
91102
92103
// Print something more profound in a different task using a lambda expression
93-
// This uses the proc() keyword to assign to spawn a function with no name
94-
// That function will call println!(...) as requested
95104
spawn(proc() println!("I am also running in a different task!") );
96105
~~~~
97106

branches/auto/src/doc/tutorial.md

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,103 +1720,38 @@ environment (sometimes referred to as "capturing" variables in their
17201720
environment). For example, you couldn't write the following:
17211721
17221722
~~~~ {.ignore}
1723-
let x = 3;
1723+
let foo = 10;
17241724
1725-
// `fun` cannot refer to `x`
1726-
fn fun() -> () { println!("{}", x); }
1725+
fn bar() -> int {
1726+
return foo; // `bar` cannot refer to `foo`
1727+
}
17271728
~~~~
17281729
1729-
A _closure_ does support accessing the enclosing scope; below we will create
1730-
2 _closures_ (nameless functions). Compare how `||` replaces `()` and how
1731-
they try to access `x`:
1732-
1733-
~~~~ {.ignore}
1734-
let x = 3;
1735-
1736-
// `fun` is an invalid definition
1737-
fn fun () -> () { println!("{}", x) } // cannot capture from enclosing scope
1738-
let closure = || -> () { println!("{}", x) }; // can capture from enclosing scope
1730+
Rust also supports _closures_, functions that can access variables in
1731+
the enclosing scope.
17391732
1740-
// `fun_arg` is an invalid definition
1741-
fn fun_arg (arg: int) -> () { println!("{}", arg + x) } // cannot capture
1742-
let closure_arg = |arg: int| -> () { println!("{}", arg + x) }; // can capture
1743-
// ^
1744-
// Requires a type because the implementation needs to know which `+` to use.
1745-
// In the future, the implementation may not need the help.
1733+
~~~~
1734+
fn call_closure_with_ten(b: |int|) { b(10); }
17461735
1747-
fun(); // Still won't work
1748-
closure(); // Prints: 3
1736+
let captured_var = 20;
1737+
let closure = |arg| println!("captured_var={}, arg={}", captured_var, arg);
17491738
1750-
fun_arg(7); // Still won't work
1751-
closure_arg(7); // Prints: 10
1739+
call_closure_with_ten(closure);
17521740
~~~~
17531741
17541742
Closures begin with the argument list between vertical bars and are followed by
17551743
a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
17561744
considered a single expression: it evaluates to the result of the last
17571745
expression it contains if that expression is not followed by a semicolon,
1758-
otherwise the block evaluates to `()`, the unit value.
1759-
1760-
In general, return types and all argument types must be specified
1761-
explicitly for function definitions. (As previously mentioned in the
1762-
[Functions section](#functions), omitting the return type from a
1763-
function declaration is synonymous with an explicit declaration of
1764-
return type unit, `()`.)
1765-
1766-
~~~~ {.ignore}
1767-
fn fun (x: int) { println!("{}", x) } // this is same as saying `-> ()`
1768-
fn square(x: int) -> uint { (x * x) as uint } // other return types are explicit
1769-
1770-
// Error: mismatched types: expected `()` but found `uint`
1771-
fn badfun(x: int) { (x * x) as uint }
1772-
~~~~
1773-
1774-
On the other hand, the compiler can usually infer both the argument
1775-
and return types for a closure expression; therefore they are often
1776-
omitted, since both a human reader and the compiler can deduce the
1777-
types from the immediate context. This is in contrast to function
1778-
declarations, which require types to be specified and are not subject
1779-
to type inference. Compare:
1746+
otherwise the block evaluates to `()`.
17801747
1781-
~~~~ {.ignore}
1782-
// `fun` as a function declaration cannot infer the type of `x`, so it must be provided
1783-
fn fun (x: int) { println!("{}", x) }
1784-
let closure = |x | { println!("{}", x) }; // infers `x: int`, return type `()`
1785-
1786-
// For closures, omitting a return type is *not* synonymous with `-> ()`
1787-
let add_3 = |y | { 3i + y }; // infers `y: int`, return type `int`.
1788-
1789-
fun(10); // Prints 10
1790-
closure(20); // Prints 20
1791-
closure(add_3(30)); // Prints 33
1748+
The types of the arguments are generally omitted, as is the return type,
1749+
because the compiler can almost always infer them. In the rare case where the
1750+
compiler needs assistance, though, the arguments and return types may be
1751+
annotated.
17921752
1793-
fun("String"); // Error: mismatched types
1794-
1795-
// Error: mismatched types
1796-
// inference already assigned `closure` the type `|int| -> ()`
1797-
closure("String");
17981753
~~~~
1799-
1800-
In cases where the compiler needs assistance, the arguments and return
1801-
types may be annotated on closures, using the same notation as shown
1802-
earlier. In the example below, since different types provide an
1803-
implementation for the operator `*`, the argument type for the `x`
1804-
parameter must be explicitly provided.
1805-
1806-
~~~~{.ignore}
1807-
// Error: the type of `x` must be known to be used with `x * x`
1808-
let square = |x | -> uint { (x * x) as uint };
1809-
~~~~
1810-
1811-
In the corrected version, the argument type is explicitly annotated,
1812-
while the return type can still be inferred.
1813-
1814-
~~~~
1815-
let square_explicit = |x: int| -> uint { (x * x) as uint };
1816-
let square_infer = |x: int| { (x * x) as uint };
1817-
1818-
println!("{}", square_explicit(20)); // 400
1819-
println!("{}", square_infer(-20)); // 400
1754+
let square = |x: int| -> uint { (x * x) as uint };
18201755
~~~~
18211756
18221757
There are several forms of closure, each with its own role. The most

branches/auto/src/etc/emacs/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ To install manually, check out this repository and add this to your
1212

1313
```lisp
1414
(add-to-list 'load-path "/path/to/rust-mode/")
15-
(autoload 'rust-mode "rust-mode" nil t)
16-
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
15+
(require 'rust-mode)
1716
```
1817

19-
This associates `rust-mode` with `.rs` files. To enable it explicitly, do
20-
<kbd>M-x rust-mode</kbd>.
18+
`rust-mode` will automatically be associated with `.rs` files. To enable it
19+
explicitly, do <kbd>M-x rust-mode</kbd>.
2120

2221
### `package.el` installation via Marmalade or MELPA
2322

branches/auto/src/libcollections/bitv.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -225,32 +225,6 @@ enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
225225
enum Op {Union, Intersect, Assign, Difference}
226226

227227
/// The bitvector type
228-
///
229-
/// # Example
230-
///
231-
/// ```rust
232-
/// use collections::bitv::Bitv;
233-
///
234-
/// let mut bv = Bitv::new(10, false);
235-
///
236-
/// // insert all primes less than 10
237-
/// bv.set(2, true);
238-
/// bv.set(3, true);
239-
/// bv.set(5, true);
240-
/// bv.set(7, true);
241-
/// println!("{}", bv.to_str());
242-
/// println!("# bits set to true: {}", bv.iter().count(|x| x));
243-
///
244-
/// // flip all values in bitvector, producing non-primes less than 10
245-
/// bv.negate();
246-
/// println!("{}", bv.to_str());
247-
/// println!("# bits set to true: {}", bv.iter().count(|x| x));
248-
///
249-
/// // reset bitvector to empty
250-
/// bv.clear();
251-
/// println!("{}", bv.to_str());
252-
/// println!("# bits set to true: {}", bv.iter().count(|x| x));
253-
/// ```
254228
#[deriving(Clone)]
255229
pub struct Bitv {
256230
/// Internal representation of the bit vector (small or large)
@@ -290,11 +264,10 @@ impl Bitv {
290264
}
291265
}
292266
}
267+
293268
}
294269

295270
impl Bitv {
296-
/// Creates an empty Bitv that holds `nbits` elements, setting each element
297-
/// to `init`.
298271
pub fn new(nbits: uint, init: bool) -> Bitv {
299272
let rep = if nbits < uint::BITS {
300273
Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
@@ -446,20 +419,6 @@ impl Bitv {
446419
}
447420
}
448421

449-
/// Returns an iterator over the elements of the vector in order.
450-
///
451-
/// # Example
452-
///
453-
/// ```rust
454-
/// let mut bv = Bitv::new(10, false);
455-
/// bv.set(1, true);
456-
/// bv.set(2, true);
457-
/// bv.set(3, true);
458-
/// bv.set(5, true);
459-
/// bv.set(8, true);
460-
/// // Count bits set to 1; result should be 5
461-
/// println!("{}", bv.iter().count(|x| x));
462-
/// ```
463422
#[inline]
464423
pub fn iter<'a>(&'a self) -> Bits<'a> {
465424
Bits {bitv: self, next_idx: 0, end_idx: self.nbits}

branches/auto/src/libnative/io/file_win32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub fn open(path: &CString, fm: io::FileMode, fa: io::FileAccess)
274274
(io::Truncate, io::Read) => libc::TRUNCATE_EXISTING,
275275
(io::Truncate, _) => libc::CREATE_ALWAYS,
276276
(io::Open, io::Read) => libc::OPEN_EXISTING,
277-
(io::Open, _) => libc::OPEN_ALWAYS,
277+
(io::Open, _) => libc::CREATE_NEW,
278278
(io::Append, io::Read) => {
279279
dwDesiredAccess |= libc::FILE_APPEND_DATA;
280280
libc::OPEN_EXISTING

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
210210
-> (ast::Crate, syntax::ast_map::Map) {
211211
let time_passes = sess.time_passes();
212212

213+
sess.building_library.set(session::building_library(&sess.opts, &krate));
213214
*sess.crate_types.borrow_mut() = session::collect_crate_types(sess, krate.attrs.as_slice());
214215

215216
time(time_passes, "gated feature checking", (), |_|
@@ -1045,6 +1046,7 @@ pub fn build_session_(sopts: session::Options,
10451046
entry_type: Cell::new(None),
10461047
macro_registrar_fn: Cell::new(None),
10471048
default_sysroot: default_sysroot,
1049+
building_library: Cell::new(false),
10481050
local_crate_source_file: local_crate_source_file,
10491051
working_dir: os::getcwd(),
10501052
lints: RefCell::new(NodeMap::new()),

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use syntax::codemap::Span;
2525
use syntax::diagnostic;
2626
use syntax::parse::ParseSess;
2727
use syntax::{abi, ast, codemap};
28+
use syntax;
2829

2930
use std::cell::{Cell, RefCell};
3031
use collections::HashSet;
@@ -184,6 +185,7 @@ pub struct Session {
184185
pub entry_type: Cell<Option<EntryFnType>>,
185186
pub macro_registrar_fn: Cell<Option<ast::NodeId>>,
186187
pub default_sysroot: Option<Path>,
188+
pub building_library: Cell<bool>,
187189
// The name of the root source file of the crate, in the local file system. The path is always
188190
// expected to be absolute. `None` means that there is no source file.
189191
pub local_crate_source_file: Option<Path>,
@@ -475,6 +477,26 @@ pub fn expect<T:Clone>(sess: &Session, opt: Option<T>, msg: || -> ~str) -> T {
475477
diagnostic::expect(sess.diagnostic(), opt, msg)
476478
}
477479

480+
pub fn building_library(options: &Options, krate: &ast::Crate) -> bool {
481+
if options.test { return false }
482+
for output in options.crate_types.iter() {
483+
match *output {
484+
CrateTypeExecutable => {}
485+
CrateTypeStaticlib | CrateTypeDylib | CrateTypeRlib => return true
486+
}
487+
}
488+
match syntax::attr::first_attr_value_str_by_name(krate.attrs.as_slice(),
489+
"crate_type") {
490+
Some(s) => {
491+
s.equiv(&("lib")) ||
492+
s.equiv(&("rlib")) ||
493+
s.equiv(&("dylib")) ||
494+
s.equiv(&("staticlib"))
495+
}
496+
_ => false
497+
}
498+
}
499+
478500
pub fn default_lib_output() -> CrateType {
479501
CrateTypeRlib
480502
}

0 commit comments

Comments
 (0)