Commit Graph

27609 Commits

Author SHA1 Message Date
bors
f8f60d80bf auto merge of #12998 : huonw/rust/log_syntax, r=alexcrichton
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 `()`.
2014-03-24 07:11:59 -07:00
Felix S. Klock II
57ac379a63 Correct overly broad definition of 'static kind bound.
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.
2014-03-24 13:03:43 +01:00
bors
11d9483d58 auto merge of #12948 : olleolleolle/rust/master, r=huonw
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.
2014-03-24 04:41:53 -07:00
Olle Jonsson
a6c14dda21 Documentation sprint: Terminfo 2014-03-24 12:16:15 +01:00
noam
4b224af72a Added suggested notes
* Note on while loop not supporting named breaks.
* Note on hygienic macros (and example of such within loops)
2014-03-24 00:43:43 -04:00
bors
2c7f3b850c auto merge of #13096 : sstewartgallus/rust/cleanup-test-warnings, r=huonw 2014-03-23 16:31:52 -07:00
noam
7dfa4b2982 docs: named lifetimes
* 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.
2014-03-23 18:29:58 -04:00
bors
1599ac9cf2 auto merge of #13095 : alexcrichton/rust/serialize-tuple, r=huonw
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
2014-03-23 15:16:48 -07:00
Steven Stewart-Gallus
8feb2ddf12 This commit cleans up a few test warnings 2014-03-23 14:22:17 -07:00
bors
841f31ecf9 auto merge of #13074 : pczarn/rust/build-rlib, r=alexcrichton
Fixes #12992

I tried to increase the number of deflate's probes. Reduction of 0.5% or 2% is not enough.
2014-03-23 14:01:52 -07:00
bors
bc37b8fde5 auto merge of #13103 : mozilla-servo/rust/url-totaleq, r=alexcrichton 2014-03-23 11:56:54 -07:00
Alex Crichton
e46e9332d9 serialize: Read/emit tuples with {read,emit}_tuple
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
2014-03-23 10:10:13 -07:00
Alex Crichton
4d5aafd3a6 sync: Introduce new wrapper types for locking
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.
2014-03-23 09:45:20 -07:00
Alex Crichton
ae049e82f8 sync: Rewrite the base primitives
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.
2014-03-23 09:45:20 -07:00
Alex Crichton
53e451f410 sync: Move Once to using &self
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.
2014-03-23 09:45:20 -07:00
Alex Crichton
3572a30e7a sync: Move the Mutex type to using &self
This also uses the Unsafe type for any interior mutability in the type to avoid
transmutes.
2014-03-23 09:45:20 -07:00
Alex Crichton
d6b3f1f231 sync: Move the concurrent queue to using &self
This commit also lifts it up a level in the module hierarchy in the soon-to-come
reorganization of libsync.
2014-03-23 09:45:19 -07:00
Alex Crichton
dd64bd83b7 std: Move NativeMutex from &mut self to &self
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).
2014-03-23 09:45:19 -07:00
Alex Crichton
da118e88d5 Snapshot cleanup 2014-03-23 09:45:13 -07:00
bors
903e83889a auto merge of #13102 : huonw/rust/totaleq-deriving, r=thestinger
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
:(.)
2014-03-23 08:36:51 -07:00
Ms2ger
aa39d755e3 Make url::Url derive TotalEq. 2014-03-23 15:32:18 +01:00
bors
cafb7ed6f6 auto merge of #13099 : FlaPer87/rust/master, r=huonw 2014-03-23 07:21:55 -07:00
bors
1cd0a5ed26 auto merge of #13093 : Havvy/rust/master, r=sfackler
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.
2014-03-23 06:06:54 -07:00
Huon Wilson
f6db0ef946 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
:(.)
2014-03-23 23:48:10 +11:00
Piotr Czarnecki
f0f5072566 rustc: Change the filename of compressed bitcode
Fixes #12992
Store compressed bitcode files in rlibs with a different extension. Compression doesn't interfere with --emit=bc.
Regression test compares outputs.
2014-03-23 13:36:49 +01:00
bors
06be5f7c44 auto merge of #13092 : sfackler/rust/buffer-vec, r=thestinger
`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.
2014-03-23 04:01:59 -07:00
Flavio Percoco
576e36e674 Register new snapshots 2014-03-23 11:37:31 +01:00
bors
11c6817e13 auto merge of #13090 : thestinger/rust/iter, r=Aatch
This has been rendered obsolete by partial type hints. Since the `~[T]`
type is in the process of being removed, it needs to go away.
2014-03-23 02:41:53 -07:00
Daniel Micay
ae429056ff iter: remove to_owned_vec
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.
2014-03-23 05:41:23 -04:00
bors
2ddb605654 auto merge of #13088 : thestinger/rust/hashmap, r=cmr
Closes #5283
2014-03-22 23:46:58 -07:00
Daniel Micay
3829ac2a52 use TotalEq for HashMap
Closes #5283
2014-03-23 01:59:11 -04:00
bors
3d9fdf7165 auto merge of #13089 : thestinger/rust/managed, r=Aatch
This removes two tests built on `managed::refcount`, but these issues
are well-covered elsewhere for non-managed types.
2014-03-22 20:11:55 -07:00
Daniel Micay
31d5ffc5bd make std::managed private
This removes two tests built on `managed::refcount`, but these issues
are well-covered elsewhere for non-managed types.
2014-03-22 22:33:16 -04:00
Ryan Scheel (Havvy)
f62bdfc134 Change types T,U to R (recv), S (sender) in libsync/comm.rs 2014-03-22 17:50:59 -07:00
Steven Fackler
56cf09c69c Some cleanup in std::io::buffered
`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.
2014-03-22 17:26:40 -07:00
bors
94e4e91724 auto merge of #13087 : eddyb/rust/fix-autoderef, r=cmr
Implements vtable support for generic Deref impls with trait bounds.
Also fixes cross-crate inlining when using autoderef.
2014-03-22 17:21:51 -07:00
Eduard Burtescu
087ec2aa24 Implement cross-crate support for autoderef.
Closes #13044.
2014-03-23 01:11:39 +02:00
bors
e68550e7ac auto merge of #13085 : edwardw/rust/saddest-cell, r=cmr 2014-03-22 16:06:51 -07:00
Eduard Burtescu
75d7d5210a Implement vtable support for autoderef.
Closes #13042.
2014-03-22 23:31:42 +02:00
bors
6f430c4426 auto merge of #13084 : Havvy/rust/master, r=alexcrichton
The indentation looks off in the guide because the main() function is not shown, so I'm dedenting the visible function.
2014-03-22 14:16:50 -07:00
bors
7e7a5e3d3e auto merge of #13076 : FlaPer87/rust/remove-freeze, r=alexcrichton
This PR removes the `Freeze` kind and the `NoFreeze` marker completely.

Fixes #12577

cc @nikomatsakis r?
2014-03-22 13:01:52 -07:00
Ryan Scheel (Havvy)
a73d2c70d4 Unindent stringifier() in tasks guide 2014-03-22 11:54:19 -07:00
Edward Wang
7c3ed86e5a Get rid of @Cell 2014-03-23 02:53:35 +08:00
bors
0e6f90eb89 auto merge of #12995 : Kroisse/rust/vec_ng_mut_slices, r=alexcrichton
These functions are implemented for &mut [T], but std::vec_ng::Vec has not yet.
2014-03-22 11:06:46 -07:00
Eunchong Yu
5b03050f66 Add Vec::mut_slice_from(), mut_slice_to(), and mut_split_at() 2014-03-23 02:26:25 +09:00
bors
403e869571 auto merge of #13053 : alexcrichton/rust/removing-ref-cell-get, r=huonw
This commit removes the `get()` method from `Ref` and `RefMut` in favor of the `*` operator, and removes all usage of the `deref()` function manually from rustc, favoring using `*` instead.

Some of the code is a little wacky, but that's due to either #13044 or #13042
2014-03-22 09:51:49 -07:00
Alex Crichton
02dab5a3e7 rand: Use fill() instead of read()
It's possible for a reader to have a short read, and there's no reason the task
should fail in this scenario. By using fill(), this has a stronger guarantee
that the buffer will get filled with data.
2014-03-22 08:57:58 -07:00
Alex Crichton
5560383071 std: Add an I/O reader method to fill a buffer
I've found a common use case being to fill a slice (not an owned vector)
completely with bytes. It's posible for short reads to happen, and if you're
trying to get an exact number of bytes then this helper will be useful.
2014-03-22 08:57:58 -07:00
Alex Crichton
9dc357b8ed rustuv: Remove usage of get() 2014-03-22 08:56:21 -07:00
Alex Crichton
3fb1ed0e04 rustc: Remove all usage of manual deref()
Favor using '*' instead
2014-03-22 08:48:34 -07:00