Commit Graph

28368 Commits

Author SHA1 Message Date
bors
6d1c6124f6 auto merge of #13436 : pongad/rust/lazyemit, r=thestinger
Fixes #11926
2014-04-10 05:56:55 -07:00
Patrick Walton
d8e45ea7c0 libstd: Implement StrBuf, a new string buffer type like Vec, and
port all code over to use it.
2014-04-10 22:10:10 +10:00
Kasey Carrothers
27920afa85 Remove the unused Point struct in the assert-eq-macro-fail.rs test. 2014-04-09 21:56:21 -07:00
Brian Anderson
6bacbcc32e doc: Edit intro 2014-04-09 18:53:13 -07:00
bors
7fbcb400f0 auto merge of #13413 : alexcrichton/rust/once-fn-move, r=brson
This fixes the categorization of the upvars of procs (represented internally
as once fns) to consider usage to require a loan. In doing so, upvars are no
longer allowed to be moved out of repeatedly in loops and such.

Closes #10398
Closes #12041
Closes #12127
2014-04-09 18:31:58 -07:00
Brian Anderson
ad66f56afd doc: Add "A 30-minute Introduction to Rust"
By Steve Klabnik.
2014-04-09 17:43:26 -07:00
Kiet Tran
13d6c35c56 Collect move errors before reporting
This commit changes the way move errors are reported when some value is
captured by a PatIdent. First, we collect all of the "cannot move out
of" errors before reporting them, and those errors with the same "move
source" are reported together. If the move is caused by a PatIdent (that
binds by value), we add a note indicating where it is and suggest the
user to put `ref` if they don't want the value to move. This makes the
"cannot move out of" error in match expression nicer (though the extra
note may not feel that helpful in other places :P). For example, with
the following code snippet,

```rust
enum Foo {
    Foo1(~u32, ~u32),
    Foo2(~u32),
    Foo3,
}

fn main() {
    let f = &Foo1(~1u32, ~2u32);
    match *f {
        Foo1(num1, num2) => (),
        Foo2(num) => (),
        Foo3 => ()
    }
}
```

Errors before the change:

```rust
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:11:9: 11:18 error: cannot move out of dereference of `&`-pointer
test.rs:11         Foo2(num) => (),
                   ^~~~~~~~~
```

After:

```rust
test.rs:9:11: 9:13 error: cannot move out of dereference of `&`-pointer
test.rs:9     match *f {
                    ^~
test.rs:10:14: 10:18 note: attempting to move value to here (to prevent the move, you can use `ref num1` to capture value by reference)
test.rs:10         Foo1(num1, num2) => (),
                        ^~~~
test.rs:10:20: 10:24 note: and here (use `ref num2`)
test.rs:10         Foo1(num1, num2) => (),
                              ^~~~
test.rs:11:14: 11:17 note: and here (use `ref num`)
test.rs:11         Foo2(num) => (),
                        ^~~
```

Close #8064
2014-04-09 20:03:23 -04:00
Michael Darakananda
a00be50e00 Emit intrinsic lazily 2014-04-09 19:56:31 -04:00
bors
e2c84a78b4 auto merge of #13383 : ben0x539/rust/glob-dots, r=brson
Fixes #12930.
2014-04-09 14:11:56 -07:00
Rüdiger Sonderfeld
3a709761a5 rust-mode cleanup.
* Use `setq-local' instead of (set (make-local-variable ...) value).
  Provides a version for older Emacsen.
* Remove use of `cl.el'.
* Use \' in file regexp instead of line end match $.
* Use type for defcustom and add parent group.
2014-04-09 20:32:02 +02:00
Alex Crichton
767ed1a71f rustc: Prevent repeated moves out of proc upvars
This fixes the categorization of the upvars of procs (represented internally
as once fns) to consider usage to require a loan. In doing so, upvars are no
longer allowed to be moved out of repeatedly in loops and such.

Closes #10398
Closes #12041
Closes #12127
2014-04-08 17:10:47 -07:00
Huon Wilson
4b9a7a2588 collections: replace all ~[T] with Vec<T>. 2014-04-09 09:58:17 +10:00
Huon Wilson
d3c831ba4a std: use a match in assert_eq! to extend the lifetime of the args.
This enables

    assert_eq!(foo.collect::<Vec<...>>().as_slice(), &[1,2,3,4]);

to work, by extending the lifetime of the .as_slice() rvalue.
2014-04-09 09:57:49 +10:00
Alex Crichton
1563ea9f27 rustc: Remove f{32,64} % from the language
This commit removes the compiler support for floating point modulus operations,
as well as from the language. An implementation for this operator is now
required to be provided by libraries.

Floating point modulus is rarely used, doesn't exist in C, and is always lowered
to an fmod library call by LLVM, and LLVM is considering removing support
entirely.

Closes #12278
2014-04-08 15:39:46 -07:00
bors
8801d891c4 auto merge of #13399 : SimonSapin/rust/patch-8, r=cmr 2014-04-08 15:06:31 -07:00
Alex Crichton
0cc257eb42 rustc: Run destructors when dest=Ignore
Previously, if statements of the form "Foo;" or "let _ = Foo;" were encountered
where Foo had a destructor, the destructors were not run. This changes
the relevant locations in trans to check for ty::type_needs_drop and invokes
trans_to_lvalue instead of trans_into.

Closes #4734
Closes #6892
2014-04-08 08:28:54 -07:00
bors
02f51211ed auto merge of #13397 : alexcrichton/rust/rollup, r=alexcrichton 2014-04-08 08:16:52 -07:00
Simon Sapin
7619b78191 Update an obsolete comment about conditions 2014-04-08 10:56:48 +01:00
Alex Crichton
da8d4fddc6 Test fixes from rollup
Closes #13394 (sync: remove unsafe and add Send+Share to Deref (enabled by autoderef vtables))
Closes #13389 (Made libflate functions return Options instead of outright failing)
Closes #13388 (doc: Document flavorful variations of paths)
Closes #13387 (Register new snapshots)
Closes #13386 (std: Add more docs for ptr mod)
Closes #13384 (Tweak crate loading to load less metadata)
Closes #13382 (fix ~ZeroSizeType rvalues)
Closes #13378 (Update tidy script, replace XXX with FIXME)
Closes #13377 (std: User a smaller stdin buffer on windows)
Closes #13369 (Fix spelling errors in comments.)
Closes #13314 (Made 'make install' include libs for additional targets)
Closes #13278 (std: make vec!() macro handle a trailing comma)
Closes #13276 (Add test for #11881)
2014-04-08 00:03:16 -07:00
JustAPerson
cdf349d442 Add test for #11881
Closes #11881.

This code has been copied from the original issue and updated for
modern Rust APIs.
2014-04-08 00:03:12 -07:00
Kang Seonghoon
7a281718f0 std: make vec!() macro handle a trailing comma
Fixes #12910.
2014-04-08 00:03:12 -07:00
Dmitry Promsky
87334fb05f Made 'make install' include libs for additional targets 2014-04-08 00:03:12 -07:00
Joseph Crail
22b632560f Fix spelling errors in comments. 2014-04-08 00:03:12 -07:00
Alex Crichton
6ac34926a4 std: User a smaller stdin buffer on windows
Apparently windows doesn't like reading from stdin with a large buffer size, and
it also apparently is ok with a smaller buffer size. This changes the reader
returned by stdin() to return an 8k buffered reader for stdin rather than a 64k
buffered reader.

Apparently libuv has run into this before, taking a peek at their code, with a
specific comment in their console code saying that "ReadConsole can't handle big
buffers", which I presume is related to invoking ReadFile as if it were a file
descriptor.

Closes #13304
2014-04-08 00:03:12 -07:00
Boris Egorov
00cbda2d0a Improve searching for XXX in tidy script (#3303)
Few places where previous version of tidy script cannot find XXX:
* inside one-line comment preceding by a few spaces;
* inside multiline comments (now it finds it if multiline comment starts
on the same line with XXX).

Change occurences of XXX found by new tidy script.
2014-04-08 00:03:12 -07:00
Daniel Micay
de2567dec9 fix ~ZeroSizeType rvalues
Closes #13360
2014-04-08 00:03:11 -07:00
Alex Crichton
cced02fcac rustc: Don't read both rlib and dylib metadata
This is an optimization which is quite impactful for compiling small crates.
Reading libstd's metadata takes about 50ms, and a hello world before this change
took about 100ms (this change halves that time).

Recent changes made it such that this optimization wasn't performed, but I think
it's a better idea do to this for now. See #10786 for tracking this issue.
2014-04-08 00:03:11 -07:00
Alex Crichton
5367c32c7d rustc: Never register syntax crates in CStore
When linking, all crates in the local CStore are used to link the final product.
With #[phase(syntax)], crates want to be omitted from this linkage phase, and
this was achieved by dumping the entire CStore after loading crates. This causes
crates like the standard library to get loaded twice. This loading process is a
fairly expensive operation when dealing with decompressing metadata.

This commit alters the loading process to never register syntax crates in
CStore. Instead, only phase(link) crates ever make their way into the map of
crates. The CrateLoader trait was altered to return everything in one method
instead of having separate methods for finding information.
2014-04-08 00:03:11 -07:00
Alex Crichton
31755e2452 rustc: Use CStore, not a separate crate cache
This separate crate cache is one factor which is causing libstd to be loaded
twice during normal compilation. The crates loaded for syntax extensions have a
separate cache than the crates loaded for linking, so all crates are loaded once
per #[phase] they're tagged with.

This removes the cache and instead uses the CStore structure itself as the cache
for loaded crates. This should allow crates loaded during the syntax phase to be
shared with the crates loaded during the link phase.
2014-04-08 00:03:11 -07:00
Brian Anderson
ef37cfdecc std: Add more docs for ptr mod 2014-04-08 00:03:11 -07:00
Alex Crichton
c3ea3e439f Register new snapshots 2014-04-08 00:03:11 -07:00
Alex Crichton
c83afb9719 doc: Document flavorful variations of paths
Closes #4293
2014-04-08 00:03:11 -07:00
Tobba
bc234ae130 Made libflate functions return Options instead of outright failing 2014-04-08 00:03:11 -07:00
Jim Radford
dc49018679 sync: remove unsafe and add Send+Share to Deref (enabled by autoderef vtables) 2014-04-08 00:03:11 -07:00
bors
e415c25bcd auto merge of #13393 : alexcrichton/rust/hopefully-fix-bsd, r=sfackler
This appears to be causing the BSD bots to lock up when looking at the core
dumps I've managed to get. Dropping the `FileDesc` structure triggers the `Arc`
it's contained in to get cleaned up, invoking free(). This instead just closes
the file descriptor (the arc itself is never cleaned up).

I'm still not entirely sure why this is a problem because the pthreads runtime
should register hooks for fork() to prevent this sort of deadlock, but perhaps
that's only done on linux?
2014-04-07 21:21:47 -07:00
Alex Crichton
7da210907e native: Try hard to not malloc on a forked child
This appears to be causing the BSD bots to lock up when looking at the core
dumps I've managed to get. Dropping the `FileDesc` structure triggers the `Arc`
it's contained in to get cleaned up, invoking free(). This instead just closes
the file descriptor (the arc itself is never cleaned up).

I'm still not entirely sure why this is a problem because the pthreads runtime
should register hooks for fork() to prevent this sort of deadlock, but perhaps
that's only done on linux?
2014-04-07 20:27:12 -07:00
Benjamin Herr
1700f359bc libglob: only return dirs for globs ending in /
`foo.txt/` should not return `foo.txt` if `foo.txt` is in fact a text
file and not a directory.
2014-04-08 01:21:37 +02:00
Benjamin Herr
4051bd900a libglob: allow "." and ".." to be matched
... also don't read the whole directory if the glob for that path
component doesn't contain any metacharacters.

Patterns like `../*.jpg` will work now, and `.*` will match both `.` and
`..` to be consistent with shell expansion.

As before: Just `*` still won't match `.` and `..`, while it will still
match dotfiles like `.git` by default.
2014-04-08 01:21:28 +02:00
bors
9a33330caa auto merge of #13288 : alexcrichton/rust/remove-check-fast, r=brson
Rebasing of #12304.
2014-04-07 11:26:37 -07:00
Alex Crichton
2ecae80af2 Fix some windows rpass tests 2014-04-07 09:29:42 -07:00
bors
2db9700332 auto merge of #13363 : free-Runner/rust/patch-1, r=alexcrichton 2014-04-07 08:56:34 -07:00
bors
c7fac44712 auto merge of #13358 : tbu-/rust/pr_doc_equivrel, r=cmr
Add requirements of TotalEq and TotalOrd

Clarify that TotalEq needs an underlying equivalence relation and that TotalOrd
needs a total ordering and specifically named the required (and sufficient)
attributes.
2014-04-07 06:21:35 -07:00
bors
dd3e553120 auto merge of #13356 : alexcrichton/rust/ignore-flaky, r=huonw
This test relies on the parent to be descheduled before the child sends its
data. This has proved to be unreliable on libnative on the bots. It's a fairly
trivial test regardless, so ignoring it for now won't lose much.
2014-04-07 05:01:35 -07:00
bors
8902ed0c65 auto merge of #13354 : alexcrichton/rust/fixup-some-signals, r=sfackler
This also makes the listener struct sendable again by explicitly putting the
Send bound on the relevant Rtio object.

cc #13352
2014-04-07 03:46:37 -07:00
bors
0deb16a54e auto merge of #13347 : HeroesGrave/rust/master, r=alexcrichton
This has to be the most pathetic pull request I've ever made, but the `[` in `#![some_attribute]` was not getting highlighted in KATE.
2014-04-07 02:26:37 -07:00
bors
e4779b5050 auto merge of #13165 : sfackler/rust/io-vec, r=alexcrichton
`Reader`, `Writer`, `MemReader`, `MemWriter`, and `MultiWriter` now work with `Vec<u8>` instead of `~[u8]`. This does introduce some extra copies since `from_utf8_owned` isn't usable anymore, but I think that can't be helped until `~str`'s representation changes.
2014-04-06 23:36:38 -07:00
Alex Crichton
0d9fd8e2a1 rmake: Fix a test on FreeBSD 2014-04-06 15:55:43 -07:00
Alex Crichton
8ded99c0ef Remove ignore-fast that has cropped up 2014-04-06 15:55:43 -07:00
Brian Anderson
42847c8b1e Use ignore-freebsd for tests broken on FreeBSD 2014-04-06 15:55:43 -07:00
Brian Anderson
1ef8b75187 Ignore another test that fails mysteriously on BSD 2014-04-06 15:55:43 -07:00