This is the final nail in the coffin for the crate map. The `start` function for
libgreen now has a new added parameter which is the event loop factory instead
of inferring it from the crate map. The two current valid values for this
parameter are `green::basic::event_loop` and `rustuv::event_loop`.
Summary:
It was possible to borrow unsafe static items in static initializers.
This patch implements a small `Visitor` that walks static initializer's
expressions and checks borrows aliasability.
Fixes#13005
Test Plan: make check
Differential Revision: http://phabricator.octayn.net/D2
While double-checking my understanding of the meaning of `'static`, I made the following test program:
```rust
fn foo<X:'static>(_x: X) { }
#[cfg(not(acceptable))]
fn bar() {
let a = 3;
let b = &a;
foo(b);
}
#[cfg(acceptable)]
fn bar() {
static c : int = 4;;
let d : &'static int = &c;
foo(d);
}
fn main() {
bar();
}
```
Transcript of compiling above program, illustrating that the `--cfg acceptable` variant of `bar` compiles successfully, showing that the`'static` kind bound only disallows non-`static` references, not *all* references:
```
% rustc --version
/Users/fklock/opt/rust-dbg/bin/rustc 0.10-pre (caf17fe 2014-03-21 02:21:50 -0700)
host: x86_64-apple-darwin
% rustc /tmp/s.rs
/tmp/s.rs:7:5: 7:8 error: instantiating a type parameter with an incompatible type `&int`, which does not fulfill `'static`
/tmp/s.rs:7 foo(b);
^~~
error: aborting due to previous error
% rustc --cfg acceptable /tmp/s.rs
% ./s
%
```
(Note that the explicit type annotation on `let d : &'static int` is necessary; it did not suffice for me to just write `let d = &'static c;`. That might be a latent bug, I am not sure yet.)
Anyway, a fix to the documentation seemed prudent.
syntax: allow `trace_macros!` and `log_syntax!` in item position.
Previously
trace_macros!(true)
fn main() {}
would complain about `trace_macros` being an expression macro in item
position. This is a pointless limitation, because the macro is purely
compile-time, with no runtime effect. (And similarly for log_syntax.)
This also changes the behaviour of `trace_macros!` very slightly, it
used to be equivalent to
macro_rules! trace_macros {
(true $($_x: tt)*) => { true };
(false $($_x: tt)*) => { false }
}
I.e. you could invoke it with arbitrary trailing arguments, which were
ignored. It is changed to accept only exactly `true` or `false` (with no
trailing arguments) and expands to `()`.
While double-checking my understanding of the meaning of `'static`,
I made the following test program:
```rust
fn foo<X:'static>(_x: X) { }
#[cfg(not(acceptable))]
fn bar() {
let a = 3;
let b = &a;
foo(b);
}
#[cfg(acceptable)]
fn bar() {
static c : int = 4;;
let d : &'static int = &c;
foo(d);
}
fn main() {
bar();
}
```
Transcript of compiling above program, illustrating that the `--cfg
acceptable` variant of `bar` compiles successfully, showing that the
`'static` kind bound only disallows non-`static` references, not *all*
references:
```
% rustc --version
/Users/fklock/opt/rust-dbg/bin/rustc 0.10-pre (caf17fe 2014-03-21 02:21:50 -0700)
host: x86_64-apple-darwin
% rustc /tmp/s.rs
/tmp/s.rs:7:5: 7:8 error: instantiating a type parameter with an incompatible type `&int`, which does not fulfill `'static`
/tmp/s.rs:7 foo(b);
^~~
error: aborting due to previous error
% rustc --cfg acceptable /tmp/s.rs
% ./s
%
```
(Note that the explicit type annotation on `let d : &'static int` is
necessary; it did not suffice for me to just write `let d = &'static
c;`. That might be a latent bug, I am not sure yet.)
Anyway, a fix to the documentation seemed prudent.
Rust doc sprint: adding doc strings to the Terminfo library.
This is my very first Rust repository PR, so please do not hold back any formatting, nit-picky commentary. I need it.
* Include tip given by Leo Testard in mailing list about labeled `break`
and `continue`:
https://mail.mozilla.org/pipermail/rust-dev/2014-March/009145.html
* cross-reference named lifetimes in tutorial -> lifetimes guide
* Broke named lifetimes section into two sub-sections.
* Added mention of `'static` lifetime.
This commit moves from {read,emit}_seq for tuples to {read,emit}_tuple, as well
as providing a generalized macro for generating these implementations from one
invocation.
Closes#13086
This commit moves from {read,emit}_seq for tuples to {read,emit}_tuple, as well
as providing a generalized macro for generating these implementations from one
invocation.
Closes#13086
This introduces new synchronization types which are meant to be the foundational
building blocks for sharing data among tasks. The new Mutex and RWLock types
have a type parameter which is the internal data that is accessed. Access to the
data is all performed through the guards returned, and the guards all have
autoderef implemented for easy access.
This commit rewrites the core primitives of the sync library: Mutex, RWLock, and
Semaphore. These primitives now have updated, more modernized apis:
* Guards are returned instead of locking with closures. All condition variables
have moved inside the guards and extraneous methods have been removed.
* Downgrading on an rwlock is now done through the guard instead of the rwlock
itself.
These types are meant to be general locks, not locks of an internal type (for
external usage). New types will be introduced for locking shared data.
Similarly to the rest of the previous commits, this moves the once primitive to
using &self instead of &mut self for proper sharing among many threads now.
The proper usage of shared types is now sharing through `&self` rather than
`&mut self` because the mutable version will provide stronger guarantees (no
aliasing on *any* thread).
std: remove the `equals` method from `TotalEq`.
`TotalEq` is now just an assertion about the `Eq` impl of a
type (i.e. `==` is a total equality if a type implements `TotalEq`) so
the extra method is just confusing.
Also, a new method magically appeared as a hack to allow deriving to
assert that the contents of a struct/enum are also TotalEq, because the
deriving infrastructure makes it very hard to do anything but create a
trait method. (You didn't hear about this horrible work-around from me
:(.)
This will make the types more readable in the documentation, since the letters correspond with what you should either be sending or expecting to receive.
`TotalEq` is now just an assertion about the `Eq` impl of a
type (i.e. `==` is a total equality if a type implements `TotalEq`) so
the extra method is just confusing.
Also, a new method magically appeared as a hack to allow deriving to
assert that the contents of a struct/enum are also TotalEq, because the
deriving infrastructure makes it very hard to do anything but create a
trait method. (You didn't hear about this horrible work-around from me
:(.)
Fixes#12992
Store compressed bitcode files in rlibs with a different extension. Compression doesn't interfere with --emit=bc.
Regression test compares outputs.
`Vec` is now used for the internal buffer instead of `~[]`. Some module
level documentation somehow ended up attached to `BufferedReader` so I
fixed that as well.
This needs to be removed as part of removing `~[T]`. Partial type hints
are now allowed, and will remove the need to add a version of this
method for `Vec<T>`. For now, this involves a few workarounds for
partial type hints not completely working.
`Vec` is now used for the internal buffer instead of `~[]`. Some module
level documentation somehow ended up attached to `BufferedReader` so I
fixed that as well.