Commit Graph

30174 Commits

Author SHA1 Message Date
bors bb5695b95c auto merge of #15245 : sfackler/rust/coretest, r=alexcrichton
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
2014-06-29 23:36:43 +00:00
Steven Fackler 1ed646eaf7 Extract tests from libcore to a separate crate
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
2014-06-29 15:57:21 -07:00
bors a490871a6c auto merge of #15252 : alexcrichton/rust/issue-15231, r=pcwalton
When cloning a stream, the data is already guaranteed to be in a consistent
state, so there's no need to perform a zeroing. This prevents segfaults as seen
in #15231

Closes #15231
2014-06-29 21:41:45 +00:00
bors ff94f867d2 auto merge of #15234 : pcwalton/rust/integer-fallback-and-casts, r=alexcrichton
This will break code that looks like:

    let mut x = 0;
    while ... {
        x += 1;
    }
    println!("{}", x);

Change that code to:

    let mut x = 0i;
    while ... {
        x += 1;
    }
    println!("{}", x);

Closes #15201.

[breaking-change]

r? @alexcrichton
2014-06-29 19:46:46 +00:00
Erick Tryzelaar ab1bd3adf6 core: optimize {option,result}::collect
The bug #11084 causes these collect functions to run about
twice as slow as they should because llvm is having trouble
optimizing away the closure for some reason. This patch works
around that performance bug by using a simple adapter iterator
explicitly for capturing if the outer iterator returns an
error.
2014-06-29 12:32:24 -07:00
Erick Tryzelaar 1ea9991921 alloc: impl Default for Rc 2014-06-29 12:32:24 -07:00
Erick Tryzelaar 2317840c14 collections: minor cleanup 2014-06-29 12:29:36 -07:00
Patrick Walton a5bb0a3a45 librustc: Remove the fallback to `int` for integers and `f64` for
floating point numbers for real.

This will break code that looks like:

    let mut x = 0;
    while ... {
        x += 1;
    }
    println!("{}", x);

Change that code to:

    let mut x = 0i;
    while ... {
        x += 1;
    }
    println!("{}", x);

Closes #15201.

[breaking-change]
2014-06-29 11:47:58 -07:00
Alex Gaynor c420f448b3 Wrap two code examples in backticks
This makes the docs ever-so-slightly easier to read.
2014-06-29 11:11:03 -07:00
bors cc5663ad55 auto merge of #15246 : Sawyer47/rust/rand-doc-fix, r=alexcrichton
Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
2014-06-29 17:51:39 +00:00
Alex Crichton ca7fb82e0b rustuv: Don't zero-out data on clones
When cloning a stream, the data is already guaranteed to be in a consistent
state, so there's no need to perform a zeroing. This prevents segfaults as seen
in #15231

Closes #15231
2014-06-29 09:38:07 -07:00
bors bd9563aa38 auto merge of #15249 : aochagavia/rust/rand, r=huonw 2014-06-29 13:11:36 +00:00
bors b569c77148 auto merge of #14904 : huonw/rust/cstr-remove-withref, r=alexcrichton 2014-06-29 11:21:39 +00:00
Huon Wilson 569f13a521 c_str: move `.unwrap` & document it more clearly.
This should be called rarely, but it was placed first in the list of
methods, making it very tempting to call.
2014-06-29 21:15:26 +10:00
Huon Wilson d4d4bc4fe9 c_str: replace .with_ref with .as_ptr throughout the codebase. 2014-06-29 21:15:26 +10:00
Huon Wilson 2c9aada10c c_str: add `.as_ptr` & `.as_mut_ptr` to replace `.with_[mut_]ref`.
These forms return the pointer directly, rather than the added
indirection, indentation, and inefficiencies of the closures in
`.with_ref` and `.with_mut_ref`. The two closure functions are
deprecated.

Replace

    foo(c_str.with_ref(|p| p))

    c_str.with_ref(|p| {
        foo(p);
        bar(p);
    })

with

    foo(c_str.as_ptr())

    let p = c_str.as_ptr();
    foo(p);
    bar(p);

This change does mean that one has to be careful to avoid writing `let p
= x.to_c_str().as_ptr();` since the `CString` will be freed at the end
of the statement. Previously, `with_ref` was used (and `as_ptr` avoided)
for this reason, but Rust has strongly moved away from closures to more
RAII-style code, and most uses of `.with_ref` where in the form
`.with_ref(|p| p)` anyway, that is, they were exactly `.as_ptr`.

[breaking-change]
2014-06-29 21:15:26 +10:00
Piotr Jawniak ba46c8bf66 rand: Small fix in parameter name
Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
2014-06-29 12:09:22 +02:00
Adolfo Ochagavía 96fdf4dae5 Impl Rand for tuples of arity 11 and 12 2014-06-29 11:44:25 +02:00
bors 6a3695d54f auto merge of #15241 : arjantop/rust/maybeownedvector-improvements, r=alexcrichton 2014-06-29 00:31:30 +00:00
bors 1e6b69977a auto merge of #15210 : luqmana/rust/windoc, r=alexcrichton
Getting rust to build on windows can be a bit annoying in setting up all the toolchains and whatnot. The whole process is made much easier by using msys2 so let's document that prominently right on the README.
2014-06-28 22:06:35 +00:00
bors fe8bc17801 auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwalton
This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
2014-06-28 20:11:34 +00:00
Alex Crichton 0dfc90ab15 Rename all raw pointers as necessary 2014-06-28 11:53:58 -07:00
Arjan Topolovec 8fce20c2cb Implementation of common traits for MaybeOwnedVector 2014-06-28 20:28:04 +02:00
bors de337f3ddf auto merge of #15191 : pcwalton/rust/variance-in-trait-matching, r=huonw
I believe that #5781 got fixed by the DST work. It duplicated the
variance inference work in #12828. Therefore, all that is left in #5781
is adding a test.

Closes #5781.

r? @huonw
2014-06-28 18:21:34 +00:00
Patrick Walton 05e3248a79 librustc: Match trait self types exactly.
This can break code that looked like:

    impl Foo for Box<Any> {
        fn f(&self) { ... }
    }

    let x: Box<Any + Send> = ...;
    x.f();

Change such code to:

    impl Foo for Box<Any> {
        fn f(&self) { ... }
    }

    let x: Box<Any> = ...;
    x.f();

That is, upcast before calling methods.

This is a conservative solution to #5781. A more proper treatment (see
the xfail'd `trait-contravariant-self.rs`) would take variance into
account. This change fixes the soundness hole.

Some library changes had to be made to make this work. In particular,
`Box<Any>` is no longer showable, and only `Box<Any+Send>` is showable.
Eventually, this restriction can be lifted; for now, it does not prove
too onerous, because `Any` is only used for propagating the result of
task failure.

This patch also adds a test for the variance inference work in #12828,
which accidentally landed as part of DST.

Closes #5781.

[breaking-change]
2014-06-28 11:18:37 -07:00
bors b47f2226a2 auto merge of #15214 : tbu-/rust/pr_doc_vecinsert, r=huonw 2014-06-28 14:31:37 +00:00
Tobias Bucher a208842b9d Add remark and an example about the bounds of `Vec::insert` 2014-06-28 12:29:24 +02:00
bors e6d6c8beaa auto merge of #15235 : Sawyer47/rust/issue-12552, r=huonw
Closes #12552
2014-06-28 09:16:35 +00:00
Piotr Jawniak 5be84098b5 Add test for issue #12552
Closes #12552
2014-06-28 09:30:44 +02:00
bors 0ddf6f4b7c auto merge of #15233 : jbclements/rust/match-var-hygiene-etc, r=cmr
This PR includes two big things and a bunch of little ones.

1) It enables hygiene for variables bound by 'match' expressions.
2) It fixes a bug discovered indirectly (#15221), wherein fold traversal failed to visit nonterminal nodes.
3) It fixes a small bug in the macro tutorial.

It also adds tests for the first two, and makes a bunch of small comment improvements and cleanup.
2014-06-28 05:21:34 +00:00
John Clements 04ced031ad comments only 2014-06-27 22:14:22 -07:00
John Clements e3361bcbc2 adjust fold to fold over interpolated items/exprs/etc.
Closes #15221
2014-06-27 22:14:13 -07:00
John Clements 2f73b7874e looks like a cut-n-paste error in unused code 2014-06-27 22:11:11 -07:00
John Clements 764c2fe2d5 simplified test case 2014-06-27 22:11:11 -07:00
John Clements 268f6c56c2 removed incomplete comment
as written, I don't believe this comment was helpful; I think it's
better just to steer the reader toward a general understanding of
hygiene.
2014-06-27 22:11:11 -07:00
John Clements 351a5fd2b4 added unit and standalone test for 15221, extra debugging output 2014-06-27 22:10:43 -07:00
John Clements e100d26d1d undo helpful attempt to spell-check
Yes, that word is spelled \'memoization\'
2014-06-27 22:08:58 -07:00
John Clements ee1ee7f463 make tests hygienic...
... and possibly totally pointless. Specifically, fixing
these to make their macros hygienic may mean that they no
longer test the thing that they were supposed to test.
2014-06-27 22:08:57 -07:00
John Clements 235ca1801e remove trailing whitespace 2014-06-27 22:08:57 -07:00
John Clements 4b46c700f4 hygiene for match-bound vars now implemented
Closes #9384
2014-06-27 22:08:57 -07:00
John Clements 7bad96e742 improve match test case to include guard 2014-06-27 22:08:51 -07:00
John Clements 47eec97cda remove unnecessary abstraction 2014-06-27 21:41:17 -07:00
John Clements 977b380cd2 cleanup and shiny new more-functional interface 2014-06-27 21:41:17 -07:00
John Clements a18a63185c WIP match hygiene, compiles 2014-06-27 21:41:17 -07:00
John Clements 84e8143c4f get rid of needless wrapper function 2014-06-27 21:41:16 -07:00
John Clements c956f76c3c replaced ignore-pretty with no-pretty-expanded
Per @acrichto's suggestion, use the more narrowly focused exclusion.
2014-06-27 21:41:16 -07:00
John Clements 4b833e24c3 make fold_attribute part of Folder trait 2014-06-27 21:41:16 -07:00
John Clements b8c5e46505 working on hygiene 2014-06-27 21:41:10 -07:00
bors afdfe40aa0 auto merge of #15226 : luqmana/rust/abol, r=pcwalton
This was causing a ton of leaks in macro expansion.
2014-06-27 21:11:31 +00:00
Luqman Aden 04e64c0c91 librustc: Schedule cleanups properly when coercing to a &Trait. 2014-06-27 17:05:24 -04:00