]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #13416 : brson/rust/30min, r=alexcrichton
bors [Tue, 15 Apr 2014 13:02:06 +0000 (06:02 -0700)]
auto merge of #13416 : brson/rust/30min, r=alexcrichton

This is intended to be the first thing somebody new to the language reads about Rust. It is supposed to be simple and intriguing, to give the user an idea of whether Rust is appropriate for them, and to hint that there's a lot of cool stuff to learn if they just keep diving deeper.

I'm particularly happy with the sequence of concurrency examples.

10 years agorustdoc: add webfonts and tweak the styles accordingly
Adrien Tétar [Sat, 12 Apr 2014 19:39:12 +0000 (21:39 +0200)]
rustdoc: add webfonts and tweak the styles accordingly

10 years agodoc: Address feedback about intro
Brian Anderson [Tue, 15 Apr 2014 03:49:29 +0000 (20:49 -0700)]
doc: Address feedback about intro

10 years agoFixes #13507
Meyer S. Jacobs [Tue, 15 Apr 2014 00:39:52 +0000 (17:39 -0700)]
Fixes #13507

Fixes hashing of DefId for ty_enum.

Adds tests for cross-crate TypeId equivalence for various types.

10 years agoOnly check --crate-type flags if present.
JustAPerson [Sun, 13 Apr 2014 19:26:02 +0000 (14:26 -0500)]
Only check --crate-type flags if present.

Before, normal compilation and the --crate-file-name flag would
generate output based on both #![crate_type] attributes and
--crate-type flags. Now, if one or more flag is specified by command
line, only those will be used.

Closes #11573.

10 years agoauto merge of #13496 : alexcrichton/rust/issue-13495, r=sfackler
bors [Mon, 14 Apr 2014 21:36:54 +0000 (14:36 -0700)]
auto merge of #13496 : alexcrichton/rust/issue-13495, r=sfackler

This bug was introduced in #13384 by accident, and this commit continues the
work of #13384 by finishing support for loading a syntax extension crate without
registering it with the local cstore.

Closes #13495

10 years agoauto merge of #13493 : Manishearth/rust/newattr-everywhere, r=alexcrichton
bors [Mon, 14 Apr 2014 19:21:52 +0000 (12:21 -0700)]
auto merge of #13493 : Manishearth/rust/newattr-everywhere, r=alexcrichton

See #13478

10 years agoauto merge of #13480 : edwardw/rust/vtable-ice, r=alexcrichton
bors [Mon, 14 Apr 2014 18:00:20 +0000 (11:00 -0700)]
auto merge of #13480 : edwardw/rust/vtable-ice, r=alexcrichton

A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466

10 years agoauto merge of #13431 : lifthrasiir/rust/rustdoc-smaller-index, r=alexcrichton
bors [Mon, 14 Apr 2014 15:36:56 +0000 (08:36 -0700)]
auto merge of #13431 : lifthrasiir/rust/rustdoc-smaller-index, r=alexcrichton

This is a series of inter-related commits which depend on #13402 (Prune the paths that do not appear in the index). Please consider this as an early review request; I'll rebase this when the parent PR get merged and rebase is required.

----

This PR aims at reducing the search index without removing the actual information. In my measurement with both library and compiler docs, the search index is 52% smaller before gzipped, and 16% smaller after gzipped:

```
 1719473 search-index-old.js
 1503299 search-index.js (after #13402, 13% gain)
  724955 search-index-new.js (after this PR, 52% gain w.r.t. #13402)

  262711 search-index-old.js.gz
  214205 search-index.js.gz (after #13402, 18.5% gain)
  179396 search-index-new.js.gz (after this PR, 16% gain w.r.t. #13402)
```

Both the uncompressed and compressed size of the search index have been accounted. While the former would be less relevant when #12597 (Web site should be transferring data compressed) is resolved, the uncompressed index will be around for a while anyway and directly affects the UX of docs. Moreover, LZ77 (and gzip) can only remove *some* repeated strings (since its search window is limited in size), so optimizing for the uncompressed size often has a positive effect on the compressed size as well.

Each commit represents the following incremental improvements, in the order:

1. Parent paths were referred by its AST `NodeId`, which tends to be large. We don't need the actual node ID, so we remap them to the smaller sequential numbers. This also means that the list of paths can be a flat array instead of an object.
2. We remap each item type to small predefined numbers. This is strictly intended to reduce the uncompressed size of the search index.
3. We use arrays instead of objects and reconstruct the original objects in the JavaScript code. Since this removes a lot of boilerplates, this affects both the uncompressed and compressed size.
4. (I've found that a centralized `searchIndex` is easier to handle in JS, so I shot one global variable down.)
5. Finally, the repeated paths in the consecutive items are omitted (replaced by an empty string). This also greatly affects both the uncompressed and compressed size.

There had been several unsuccessful attempts to reduce the search index. Especially, I explicitly avoided complex optimizations like encoding paths in a compressed form, and only applied the optimizations when it had a substantial gain compared to the changes. Also, while I've tried to be careful, the lack of proper (non-smoke) tests makes me a bit worry; any advice on testing the search indices would be appreciated.

10 years agoUse new attribute syntax in python files in src/etc too (#13478)
Manish Goregaokar [Mon, 14 Apr 2014 15:30:31 +0000 (21:00 +0530)]
Use new attribute syntax in python files in src/etc too (#13478)

10 years agoauto merge of #13477 : Manishearth/rust/newattr, r=brson
bors [Mon, 14 Apr 2014 14:11:53 +0000 (07:11 -0700)]
auto merge of #13477 : Manishearth/rust/newattr, r=brson

See #13476

10 years agoauto merge of #13481 : huonw/rust/devec-path, r=alexcrichton
bors [Mon, 14 Apr 2014 08:41:48 +0000 (01:41 -0700)]
auto merge of #13481 : huonw/rust/devec-path, r=alexcrichton

Remove the use of ~[] from Path's internals.

10 years agoauto merge of #13479 : sfackler/rust/result-unwrap, r=cmr
bors [Mon, 14 Apr 2014 07:16:49 +0000 (00:16 -0700)]
auto merge of #13479 : sfackler/rust/result-unwrap, r=cmr

`foo.ok().unwrap()` and `foo.err().unwrap()` are the fallbacks for types
that aren't `Show`.

Closes #13379

10 years agoMake Result::{unwrap, unwrap_err} require Show
Steven Fackler [Sat, 12 Apr 2014 03:59:18 +0000 (20:59 -0700)]
Make Result::{unwrap, unwrap_err} require Show

`foo.ok().unwrap()` and `foo.err().unwrap()` are the fallbacks for types
that aren't `Show`.

Closes #13379

10 years agoauto merge of #13475 : Ryman/rust/result_unwrap_or_else, r=brson
bors [Mon, 14 Apr 2014 02:36:50 +0000 (19:36 -0700)]
auto merge of #13475 : Ryman/rust/result_unwrap_or_else, r=brson

It might make more sense to mirror `Option`'s `unwrap_or_else` but I've left it as `handle` as it feels more explicit about the signature difference.

10 years agorustdoc: Omit repeated paths in the search index.
Kang Seonghoon [Wed, 9 Apr 2014 17:24:00 +0000 (02:24 +0900)]
rustdoc: Omit repeated paths in the search index.

Since the items roughly follow the lexical order, there are
many consecutive items with the same path value which can be
easily compressed.

For the library and compiler docs, this commit decreases
the index size by 26% and 6% before and after gzip, respectively.

10 years agorustdoc: Get rid of `allPaths` global variable by merging it into `searchIndex`.
Kang Seonghoon [Wed, 9 Apr 2014 16:27:35 +0000 (01:27 +0900)]
rustdoc: Get rid of `allPaths` global variable by merging it into `searchIndex`.

10 years agorustdoc: Use an array instead of an object for the search index.
Kang Seonghoon [Wed, 9 Apr 2014 08:16:09 +0000 (17:16 +0900)]
rustdoc: Use an array instead of an object for the search index.

`buildIndex` JS function recovers them into the original object form.
This greatly reduces the size of the uncompressed search index (27%),
while this effect is less visible after gzipped (~5%).

10 years agorustdoc: Represent item types as a small number in the search index.
Kang Seonghoon [Wed, 9 Apr 2014 07:49:31 +0000 (16:49 +0900)]
rustdoc: Represent item types as a small number in the search index.

Has negligible improvements with gzip, but saves about 7% without it.
This also has an effect of changing the tie-breaking order of item types.

10 years agorustdoc: Use smaller sequential numbers instead of `NodeId`s for parents.
Kang Seonghoon [Wed, 9 Apr 2014 06:52:31 +0000 (15:52 +0900)]
rustdoc: Use smaller sequential numbers instead of `NodeId`s for parents.

`allPaths` is now a flat array in effect. This decreases the size of
the search index by about 4--5% (gzipped or not).

10 years agoauto merge of #13464 : alexcrichton/rust/fix-rustdoc-rendering, r=brson
bors [Sun, 13 Apr 2014 22:51:46 +0000 (15:51 -0700)]
auto merge of #13464 : alexcrichton/rust/fix-rustdoc-rendering, r=brson

Closures did not have their bounds printed at all, nor their lifetimes. Trait
bounds were also printed in angle brackets rather than after a colon with a '+'
inbetween them.

Note that on the current task::spawn [1] documentation page, there is no mention
of a `Send` bound even though it is crucially important!

[1] - http://static.rust-lang.org/doc/master/std/task/fn.task.html

10 years agoReplace 'region' with 'lifetime' in a few transmute function names
John Simon [Sun, 13 Apr 2014 21:23:17 +0000 (17:23 -0400)]
Replace 'region' with 'lifetime' in a few transmute function names

10 years agoauto merge of #13470 : Manishearth/rust/docnum, r=brson
bors [Sun, 13 Apr 2014 20:36:48 +0000 (13:36 -0700)]
auto merge of #13470 : Manishearth/rust/docnum, r=brson

See #7511

10 years agorustc: Don't link in syntax extensions
Alex Crichton [Sun, 13 Apr 2014 18:26:43 +0000 (11:26 -0700)]
rustc: Don't link in syntax extensions

This bug was introduced in #13384 by accident, and this commit continues the
work of #13384 by finishing support for loading a syntax extension crate without
registering it with the local cstore.

Closes #13495

10 years agorustdoc: Fix rendering closures and trait bounds
Alex Crichton [Fri, 11 Apr 2014 19:45:51 +0000 (12:45 -0700)]
rustdoc: Fix rendering closures and trait bounds

Closures did not have their bounds printed at all, nor their lifetimes. Trait
bounds were also printed in angle brackets rather than after a colon with a '+'
inbetween them.

Note that on the current task::spawn [1] documentation page, there is no mention
of a `Send` bound even though it is crucially important!

[1] - http://static.rust-lang.org/doc/master/std/task/fn.task.html

10 years agoauto merge of #13452 : Ryman/rust/fix_uint_as_u, r=alexcrichton
bors [Sun, 13 Apr 2014 17:36:47 +0000 (10:36 -0700)]
auto merge of #13452 : Ryman/rust/fix_uint_as_u, r=alexcrichton

Fixes #13359.

10 years agoauto merge of #13471 : Ryman/rust/feature_syntax_error, r=brson
bors [Sun, 13 Apr 2014 15:51:49 +0000 (08:51 -0700)]
auto merge of #13471 : Ryman/rust/feature_syntax_error, r=brson

The current error message is misleading, it asks users to add `#[feature(..)]` which ends up being treated as an outer attribute, which then has no error unless `attribute_usage` lint is enforced. The code will still fail and the user might not understand why.

10 years agoauto merge of #13469 : kmcallister/rust/utf16, r=huonw
bors [Sun, 13 Apr 2014 12:51:52 +0000 (05:51 -0700)]
auto merge of #13469 : kmcallister/rust/utf16, r=huonw

This fixes two separate issues related to character encoding.

* Add `encode_utf16` to the `Char` trait, analogous to `encode_utf8`.  `&str` already supports UTF-16 encoding but only with a heap allocation.  Also fix `encode_utf8` docs and add tests.

* Correctly decode non-BMP hex escapes in JSON (#13064).

10 years agoauto merge of #13468 : alexcrichton/rust/issue-13467, r=thestinger
bors [Sun, 13 Apr 2014 11:06:53 +0000 (04:06 -0700)]
auto merge of #13468 : alexcrichton/rust/issue-13467, r=thestinger

Previously, all slices derived from a vector whose values were of size 0 had a
null pointer as the 'data' pointer on the slice. This caused first pointer to be
yielded during iteration to always be the null pointer. Due to the null pointer
optimization, this meant that the first return value was None, instead of
Some(&T).

This commit changes slice construction from a Vec instance to use a base pointer
of 1 if the values have zero size. This means that the iterator will never
return null, and the iteration will proceed appropriately.

Closes #13467

10 years agoauto merge of #13463 : alexcrichton/rust/c-linkage-oh-my, r=brson
bors [Sun, 13 Apr 2014 09:16:54 +0000 (02:16 -0700)]
auto merge of #13463 : alexcrichton/rust/c-linkage-oh-my, r=brson

Previously, upstream C libraries were linked in a nondeterministic fashion
because they were collected through iter_crate_data() which is a nodeterministic
traversal of a hash map. When upstream rlibs had interdependencies among their
native libraries (such as libfoo depending on libc), then the ordering would
occasionally be wrong, causing linkage to fail.

This uses the topologically sorted list of libraries to collect native
libraries, so if a native library depends on libc it just needs to make sure
that the rust crate depends on liblibc.

10 years agoauto merge of #13462 : alexcrichton/rust/fix-cross-rpath, r=brson
bors [Sun, 13 Apr 2014 07:51:54 +0000 (00:51 -0700)]
auto merge of #13462 : alexcrichton/rust/fix-cross-rpath, r=brson

After removing absolute rpaths, cross compile builds (notably the nightly
builders) broke. This is because the RPATH was pointing at an empty directory
because only the rustc binary is copied over, not all of the target libraries.
This modifies the cross compile logic to fixup the rpath of the stage0
cross-compiled rustc to point to where it came from.

10 years agoauto merge of #13461 : eddyb/rust/cleanup-at-fn, r=luqmana
bors [Sun, 13 Apr 2014 05:21:56 +0000 (22:21 -0700)]
auto merge of #13461 : eddyb/rust/cleanup-at-fn, r=luqmana

10 years agoauto merge of #13460 : SimonSapin/rust/patch-9, r=alexcrichton
bors [Sun, 13 Apr 2014 03:36:58 +0000 (20:36 -0700)]
auto merge of #13460 : SimonSapin/rust/patch-9, r=alexcrichton

10 years agoauto merge of #13455 : alexcrichton/rust/jettison-timerfd, r=brson
bors [Sun, 13 Apr 2014 01:41:58 +0000 (18:41 -0700)]
auto merge of #13455 : alexcrichton/rust/jettison-timerfd, r=brson

Rust advertises itself as being compatible with linux 2.6.18, but the timerfd
set of syscalls weren't added until linux 2.6.25. There is no real need for a
specialized timer implementation beyond being a "little more accurate", but the
select() implementation will suffice for now.

If it is later deemed that an accurate timerfd implementation is needed, it can
be added then through some method which will allow the standard distribution to
continue to be compatible with 2.6.18

Closes #13447

10 years agolibsyntax: update helper to stringify TyU* and TyI* to take into account having a...
Kevin Butler [Fri, 11 Apr 2014 00:21:01 +0000 (01:21 +0100)]
libsyntax: update helper to stringify TyU* and TyI* to take into account having a value.

Fixes #13359.

10 years agoauto merge of #13459 : alexcrichton/rust/stop-ignoring-ffi, r=sfackler
bors [Sat, 12 Apr 2014 21:46:59 +0000 (14:46 -0700)]
auto merge of #13459 : alexcrichton/rust/stop-ignoring-ffi, r=sfackler

Using some strategically-placed `#` markers most of the examples are testable
(and their contents are nontrivial).

Closes #13445

10 years agonative: Remove timerfd implementation on linux
Alex Crichton [Fri, 11 Apr 2014 04:44:02 +0000 (21:44 -0700)]
native: Remove timerfd implementation on linux

Rust advertises itself as being compatible with linux 2.6.18, but the timerfd
set of syscalls weren't added until linux 2.6.25. There is no real need for a
specialized timer implementation beyond being a "little more accurate", but the
select() implementation will suffice for now.

If it is later deemed that an accurate timerfd implementation is needed, it can
be added then through some method which will allow the standard distribution to
continue to be compatible with 2.6.18

Closes #13447

10 years agoauto merge of #13448 : alexcrichton/rust/rework-chan-return-values, r=brson
bors [Sat, 12 Apr 2014 19:21:58 +0000 (12:21 -0700)]
auto merge of #13448 : alexcrichton/rust/rework-chan-return-values, r=brson

There are currently a number of return values from the std::comm methods, not
all of which are necessarily completely expressive:

 * `Sender::try_send(t: T) -> bool`
    This method currently doesn't transmit back the data `t` if the send fails
    due to the other end having disconnected. Additionally, this shares the name
    of the synchronous try_send method, but it differs in semantics in that it
    only has one failure case, not two (the buffer can never be full).

 * `SyncSender::try_send(t: T) -> TrySendResult<T>`
    This method accurately conveys all possible information, but it uses a
    custom type to the std::comm module with no convenience methods on it.
    Additionally, if you want to inspect the result you're forced to import
    something from `std::comm`.

 * `SyncSender::send_opt(t: T) -> Option<T>`
    This method uses Some(T) as an "error value" and None as a "success value",
    but almost all other uses of Option<T> have Some/None the other way

 * `Receiver::try_recv(t: T) -> TryRecvResult<T>`
    Similarly to the synchronous try_send, this custom return type is lacking in
    terms of usability (no convenience methods).

With this number of drawbacks in mind, I believed it was time to re-work the
return types of these methods. The new API for the comm module is:

    Sender::send(t: T) -> ()
    Sender::send_opt(t: T) -> Result<(), T>
    SyncSender::send(t: T) -> ()
    SyncSender::send_opt(t: T) -> Result<(), T>
    SyncSender::try_send(t: T) -> Result<(), TrySendError<T>>
    Receiver::recv() -> T
    Receiver::recv_opt() -> Result<T, ()>
    Receiver::try_recv() -> Result<T, TryRecvError>

The notable changes made are:

* Sender::try_send => Sender::send_opt. This renaming brings the semantics in
  line with the SyncSender::send_opt method. An asychronous send only has one
  failure case, unlike the synchronous try_send method which has two failure
  cases (full/disconnected).

* Sender::send_opt returns the data back to the caller if the send is guaranteed
  to fail. This method previously returned `bool`, but then it was unable to
  retrieve the data if the data was guaranteed to fail to send. There is still a
  race such that when `Ok(())` is returned the data could still fail to be
  received, but that's inherent to an asynchronous channel.

* Result is now the basis of all return values. This not only adds lots of
  convenience methods to all return values for free, but it also means that you
  can inspect the return values with no extra imports (Ok/Err are in the
  prelude). Additionally, it's now self documenting when something failed or not
  because the return value has "Err" in the name.

Things I'm a little uneasy about:

* The methods send_opt and recv_opt are not returning options, but rather
  results. I felt more strongly that Option was the wrong return type than the
  _opt prefix was wrong, and I coudn't think of a much better name for these
  methods. One possible way to think about them is to read the _opt suffix as
  "optionally".

* Result<T, ()> is often better expressed as Option<T>. This is only applicable
  to the recv_opt() method, but I thought it would be more consistent for
  everything to return Result rather than one method returning an Option.

Despite my two reasons to feel uneasy, I feel much better about the consistency
in return values at this point, and I think the only real open question is if
there's a better suffix for {send,recv}_opt.

Closes #11527

10 years agodoc: Un-ignore lots of guide-ffi tests
Alex Crichton [Fri, 11 Apr 2014 13:29:54 +0000 (06:29 -0700)]
doc: Un-ignore lots of guide-ffi tests

Using some strategically-placed `#` markers most of the examples are testable
(and their contents are nontrivial).

Closes #13445

10 years agodoc: design changes cleanups
Adrien Tétar [Thu, 20 Mar 2014 18:05:22 +0000 (19:05 +0100)]
doc: design changes cleanups

Conflicts:
src/librustdoc/html/layout.rs

10 years agofixed issues
Daniel Fagnan [Wed, 19 Mar 2014 22:33:03 +0000 (16:33 -0600)]
fixed issues

Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>
10 years agoTweaked the design to be a lot cleaner.
Daniel Fagnan [Tue, 18 Mar 2014 07:44:55 +0000 (01:44 -0600)]
Tweaked the design to be a lot cleaner.

Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>
10 years agoCheck bounds when looking up type parameters
Edward Wang [Sat, 12 Apr 2014 08:16:37 +0000 (16:16 +0800)]
Check bounds when looking up type parameters

A mismatched type with more type parameters than the expected one causes
`typeck` looking up out of the bound of type parameter vector, which
leads to ICE.

Closes #13466

10 years agostd: update & de-~[] path's tests.
Huon Wilson [Sat, 12 Apr 2014 10:56:23 +0000 (20:56 +1000)]
std: update & de-~[] path's tests.

10 years agostd: migrate path::windows to using StrBuf internally.
Huon Wilson [Sat, 12 Apr 2014 12:44:31 +0000 (22:44 +1000)]
std: migrate path::windows to using StrBuf internally.

Same representation change performed with path::unix.

This also implements BytesContainer for StrBuf & adds an (unsafe) method
for viewing & mutating the raw byte vector of a StrBuf.

10 years agostd: migrate path::unix to using Vec internally.
Huon Wilson [Sat, 12 Apr 2014 10:42:17 +0000 (20:42 +1000)]
std: migrate path::unix to using Vec internally.

10 years agoUpdate tutorials to use new attribute syntax (#13476)
Manish Goregaokar [Sat, 12 Apr 2014 03:33:16 +0000 (09:03 +0530)]
Update tutorials to use new attribute syntax (#13476)

10 years agolibstd: Add unwrap_or and unwrap_or_handle to Result
Kevin Butler [Sat, 12 Apr 2014 02:18:02 +0000 (03:18 +0100)]
libstd: Add unwrap_or and unwrap_or_handle to Result

10 years agolibrustc: Improve error message for missing feature attributes.
Kevin Butler [Fri, 11 Apr 2014 23:25:32 +0000 (00:25 +0100)]
librustc: Improve error message for missing feature attributes.

10 years agoDocument traits in std::num (#7511)
Manish Goregaokar [Fri, 11 Apr 2014 23:07:45 +0000 (04:37 +0530)]
Document traits in std::num (#7511)

10 years agoDecode non-BMP hex escapes in JSON
Keegan McAllister [Fri, 11 Apr 2014 20:21:19 +0000 (13:21 -0700)]
Decode non-BMP hex escapes in JSON

Fixes #13064.

10 years agoAdd tests for Char::encode_utf{8,16}
Keegan McAllister [Fri, 11 Apr 2014 20:44:54 +0000 (13:44 -0700)]
Add tests for Char::encode_utf{8,16}

10 years agoImplement Char::encode_utf16
Keegan McAllister [Fri, 11 Apr 2014 19:49:31 +0000 (12:49 -0700)]
Implement Char::encode_utf16

And clean up encode_utf8 a bit.

10 years agostd: Fix iteration over vectors of 0-size values
Alex Crichton [Fri, 11 Apr 2014 21:34:21 +0000 (14:34 -0700)]
std: Fix iteration over vectors of 0-size values

Previously, all slices derived from a vector whose values were of size 0 had a
null pointer as the 'data' pointer on the slice. This caused first pointer to be
yielded during iteration to always be the null pointer. Due to the null pointer
optimization, this meant that the first return value was None, instead of
Some(&T).

This commit changes slice construction from a Vec instance to use a base pointer
of 1 if the values have zero size. This means that the iterator will never
return null, and the iteration will proceed appropriately.

Closes #13467

10 years agoauto merge of #13395 : Ryman/rust/bytecontainer_impl_container, r=alexcrichton
bors [Fri, 11 Apr 2014 20:46:45 +0000 (13:46 -0700)]
auto merge of #13395 : Ryman/rust/bytecontainer_impl_container, r=alexcrichton

Also some minor cleanup in Path related to this.

10 years agoSimplify GenericPath::set_extension.
Kevin Butler [Tue, 8 Apr 2014 02:13:23 +0000 (03:13 +0100)]
Simplify GenericPath::set_extension.

10 years agoParameterize contains_nul for BytesContainer.
Kevin Butler [Tue, 8 Apr 2014 01:30:08 +0000 (02:30 +0100)]
Parameterize contains_nul for BytesContainer.

10 years agorustc: Deterministically link upstream C libraries
Alex Crichton [Fri, 11 Apr 2014 19:20:33 +0000 (12:20 -0700)]
rustc: Deterministically link upstream C libraries

Previously, upstream C libraries were linked in a nondeterministic fashion
because they were collected through iter_crate_data() which is a nodeterministic
traversal of a hash map. When upstream rlibs had interdependencies among their
native libraries (such as libfoo depending on libc), then the ordering would
occasionally be wrong, causing linkage to fail.

This uses the topologically sorted list of libraries to collect native
libraries, so if a native library depends on libc it just needs to make sure
that the rust crate depends on liblibc.

10 years agoauto merge of #13458 : huonw/rust/doc-signatures, r=alexcrichton
bors [Fri, 11 Apr 2014 19:01:44 +0000 (12:01 -0700)]
auto merge of #13458 : huonw/rust/doc-signatures, r=alexcrichton

Add more type signatures to the docs; tweak a few of them.

Someone reading the docs won't know what the types of various things
are, so this adds them in a few meaningful places to help with
comprehension.

cc #13423.

10 years agomk: Fix rpath on cross compile builds
Alex Crichton [Fri, 11 Apr 2014 17:52:01 +0000 (10:52 -0700)]
mk: Fix rpath on cross compile builds

After removing absolute rpaths, cross compile builds (notably the nightly
builders) broke. This is because the RPATH was pointing at an empty directory
because only the rustc binary is copied over, not all of the target libraries.
This modifies the cross compile logic to fixup the rpath of the stage0
cross-compiled rustc to point to where it came from.

10 years agoauto merge of #13236 : liigo/rust/rename-benchharness, r=huonw
bors [Fri, 11 Apr 2014 17:01:43 +0000 (10:01 -0700)]
auto merge of #13236 : liigo/rust/rename-benchharness, r=huonw

Closes #12640

based on PR #13030, rebased, and passed all tests.

10 years agorustc: remove the last mentions of @fn.
Eduard Burtescu [Wed, 9 Apr 2014 13:29:29 +0000 (16:29 +0300)]
rustc: remove the last mentions of @fn.

10 years agorustc: remove proc -> once || coercions.
Eduard Burtescu [Wed, 9 Apr 2014 13:10:34 +0000 (16:10 +0300)]
rustc: remove proc -> once || coercions.

10 years agorustc: fix fallout from removing ast::Sigil and use ty::TraitStore in ty::ClosureTy.
Eduard Burtescu [Fri, 11 Apr 2014 15:03:10 +0000 (18:03 +0300)]
rustc: fix fallout from removing ast::Sigil and use ty::TraitStore in ty::ClosureTy.

10 years agorustdoc: fix fallout from removing ast::Sigil.
Eduard Burtescu [Wed, 9 Apr 2014 12:34:35 +0000 (15:34 +0300)]
rustdoc: fix fallout from removing ast::Sigil.

10 years agosyntax: remove ast::Sigil.
Eduard Burtescu [Wed, 9 Apr 2014 12:33:42 +0000 (15:33 +0300)]
syntax: remove ast::Sigil.

10 years agoliblog doc: Fix apparent search-and-replace errors
Simon Sapin [Fri, 11 Apr 2014 14:28:03 +0000 (15:28 +0100)]
liblog doc: Fix apparent search-and-replace errors

10 years agoAdd more type signatures to the docs; tweak a few of them.
Huon Wilson [Fri, 11 Apr 2014 10:18:19 +0000 (20:18 +1000)]
Add more type signatures to the docs; tweak a few of them.

Someone reading the docs won't know what the types of various things
are, so this adds them in a few meaningful places to help with
comprehension.

cc #13423.

10 years agoauto merge of #13424 : eddyb/rust/ty-mut-in-store, r=nikomatsakis
bors [Fri, 11 Apr 2014 12:01:38 +0000 (05:01 -0700)]
auto merge of #13424 : eddyb/rust/ty-mut-in-store, r=nikomatsakis

Cleans up some remnants of the old mutability system and only allows vector/trait mutability in `VstoreSlice` (`&mut [T]`) and `RegionTraitStore` (`&mut Trait`).

10 years agolibtest: rename `BenchHarness` to `Bencher`
Liigo Zhuang [Tue, 1 Apr 2014 01:16:35 +0000 (09:16 +0800)]
libtest: rename `BenchHarness` to `Bencher`
Closes #12640

10 years agoauto merge of #13457 : alexcrichton/rust/issue-13420, r=thestinger
bors [Fri, 11 Apr 2014 09:21:36 +0000 (02:21 -0700)]
auto merge of #13457 : alexcrichton/rust/issue-13420, r=thestinger

On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is
necessary to deallocate that memory.

Closes #13420

10 years agoauto merge of #13453 : brson/rust/snappies, r=alexcrichton
bors [Fri, 11 Apr 2014 07:36:37 +0000 (00:36 -0700)]
auto merge of #13453 : brson/rust/snappies, r=alexcrichton

This is the first snap based on mingw-w64.

10 years agorustc: fix the fallout from moving mutability into VstoreSlice and RegionTraitStore.
Eduard Burtescu [Fri, 11 Apr 2014 06:01:31 +0000 (09:01 +0300)]
rustc: fix the fallout from moving mutability into VstoreSlice and RegionTraitStore.

10 years agoauto merge of #13451 : cmr/rust/doc-ffi, r=brson
bors [Fri, 11 Apr 2014 05:51:40 +0000 (22:51 -0700)]
auto merge of #13451 : cmr/rust/doc-ffi, r=brson

Closes #8748

10 years agostd: Be sure to call pthread_attr_destroy
Alex Crichton [Fri, 11 Apr 2014 05:38:05 +0000 (22:38 -0700)]
std: Be sure to call pthread_attr_destroy

On some OSes (such as freebsd), pthread_attr_init allocates memory, so this is
necessary to deallocate that memory.

Closes #13420

10 years agostd: Make std::comm return types consistent
Alex Crichton [Thu, 10 Apr 2014 17:53:49 +0000 (10:53 -0700)]
std: Make std::comm return types consistent

There are currently a number of return values from the std::comm methods, not
all of which are necessarily completely expressive:

  Sender::try_send(t: T) -> bool
    This method currently doesn't transmit back the data `t` if the send fails
    due to the other end having disconnected. Additionally, this shares the name
    of the synchronous try_send method, but it differs in semantics in that it
    only has one failure case, not two (the buffer can never be full).

  SyncSender::try_send(t: T) -> TrySendResult<T>
    This method accurately conveys all possible information, but it uses a
    custom type to the std::comm module with no convenience methods on it.
    Additionally, if you want to inspect the result you're forced to import
    something from `std::comm`.

  SyncSender::send_opt(t: T) -> Option<T>
    This method uses Some(T) as an "error value" and None as a "success value",
    but almost all other uses of Option<T> have Some/None the other way

  Receiver::try_recv(t: T) -> TryRecvResult<T>
    Similarly to the synchronous try_send, this custom return type is lacking in
    terms of usability (no convenience methods).

With this number of drawbacks in mind, I believed it was time to re-work the
return types of these methods. The new API for the comm module is:

  Sender::send(t: T) -> ()
  Sender::send_opt(t: T) -> Result<(), T>
  SyncSender::send(t: T) -> ()
  SyncSender::send_opt(t: T) -> Result<(), T>
  SyncSender::try_send(t: T) -> Result<(), TrySendError<T>>
  Receiver::recv() -> T
  Receiver::recv_opt() -> Result<T, ()>
  Receiver::try_recv() -> Result<T, TryRecvError>

The notable changes made are:

* Sender::try_send => Sender::send_opt. This renaming brings the semantics in
  line with the SyncSender::send_opt method. An asychronous send only has one
  failure case, unlike the synchronous try_send method which has two failure
  cases (full/disconnected).

* Sender::send_opt returns the data back to the caller if the send is guaranteed
  to fail. This method previously returned `bool`, but then it was unable to
  retrieve the data if the data was guaranteed to fail to send. There is still a
  race such that when `Ok(())` is returned the data could still fail to be
  received, but that's inherent to an asynchronous channel.

* Result is now the basis of all return values. This not only adds lots of
  convenience methods to all return values for free, but it also means that you
  can inspect the return values with no extra imports (Ok/Err are in the
  prelude). Additionally, it's now self documenting when something failed or not
  because the return value has "Err" in the name.

Things I'm a little uneasy about:

* The methods send_opt and recv_opt are not returning options, but rather
  results. I felt more strongly that Option was the wrong return type than the
  _opt prefix was wrong, and I coudn't think of a much better name for these
  methods. One possible way to think about them is to read the _opt suffix as
  "optionally".

* Result<T, ()> is often better expressed as Option<T>. This is only applicable
  to the recv_opt() method, but I thought it would be more consistent for
  everything to return Result rather than one method returning an Option.

Despite my two reasons to feel uneasy, I feel much better about the consistency
in return values at this point, and I think the only real open question is if
there's a better suffix for {send,recv}_opt.

Closes #11527

10 years agoauto merge of #13440 : huonw/rust/strbuf, r=alexcrichton
bors [Fri, 11 Apr 2014 04:01:41 +0000 (21:01 -0700)]
auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton

libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it.

Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269

10 years agoRegister snapshots.
Brian Anderson [Fri, 11 Apr 2014 02:53:10 +0000 (19:53 -0700)]
Register snapshots.

This is the first snap based on mingw-w64.

10 years agoFix tests. Add Vec<u8> conversion to StrBuf.
Huon Wilson [Thu, 10 Apr 2014 10:55:34 +0000 (20:55 +1000)]
Fix tests. Add Vec<u8> conversion to StrBuf.

10 years agoDocument the nullable pointer optimization in the FFI guide
Corey Richardson [Fri, 11 Apr 2014 00:29:09 +0000 (20:29 -0400)]
Document the nullable pointer optimization in the FFI guide

Closes #8748

10 years agoauto merge of #13443 : alexcrichton/rust/rollup, r=alexcrichton
bors [Thu, 10 Apr 2014 22:31:55 +0000 (15:31 -0700)]
auto merge of #13443 : alexcrichton/rust/rollup, r=alexcrichton

Closes #13441 (debuginfo: Fixes and improvements for #12840, #12886, and #13213)
Closes #13433 (Remove references to @Trait from a compiler error message)
Closes #13430 (Fix outdated lint warning about inner attribute)
Closes #13425 (Remove a pile of (mainly) internal `~[]` uses)
Closes #13419 (Stop using transmute_mut in RefCell)
Closes #13417 (Remove an unnecessary file `src/libnative/io/p`.)
Closes #13409 (Closing assorted resolve bugs)
Closes #13406 (Generalized the pretty-print entry points to support `-o <file>`.)
Closes #13403 (test: Add a test for #7663)
Closes #13402 (rustdoc: Prune the paths that do not appear in the index.)
Closes #13396 (rustc: Remove absolute rpaths)
Closes #13371 (Rename ast::Purity and ast::Impure Function. Closes #7287)
Closes #13350 (collections: replace all ~[T] with Vec<T>.)

10 years agorustc: Don't allow priv use to shadow pub use
Alex Crichton [Tue, 8 Apr 2014 22:10:41 +0000 (15:10 -0700)]
rustc: Don't allow priv use to shadow pub use

Previously, a private use statement would shadow a public use statement, all of
a sudden publicly exporting the privately used item. The correct behavior here
is to only shadow the use for the module in question, but for now it just
reverts the entire name to private so the pub use doesn't have much effect.

The behavior isn't exactly what we want, but this no longer has backwards
compatibility hazards.

10 years agorustc: Don't succeed on shadowed nonexistent import
Alex Crichton [Tue, 8 Apr 2014 22:03:29 +0000 (15:03 -0700)]
rustc: Don't succeed on shadowed nonexistent import

Previously resolve was checking the "import resolution" for whether an import
had succeeded or not, but this was the same structure filled in by a previous
import if a name is shadowed. Instead, this alters resolve to consult the local
resolve state (as opposed to the shared one) to test whether an import succeeded
or not.

Closes #13404

10 years agorustc: Disallow importing through use statements
Alex Crichton [Tue, 8 Apr 2014 21:31:25 +0000 (14:31 -0700)]
rustc: Disallow importing through use statements

Resolve is currently erroneously allowing imports through private `use`
statements in some circumstances, even across module boundaries. For example,
this code compiles successfully today:

    use std::c_str;
    mod test {
        use c_str::CString;
    }

This should not be allowed because it was explicitly decided that private `use`
statements are purely bringing local names into scope, they are not
participating further in name resolution.

As a consequence of this patch, this code, while valid today, is now invalid:

    mod test {
        use std::c_str;

        unsafe fn foo() {
            ::test::c_str::CString::new(0 as *u8, false);
        }
    }

While plausibly acceptable, I found it to be more consistent if private imports
were only considered candidates to resolve the first component in a path, and no
others.

Closes #12612

10 years agoRenamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated...
Kasey Carrothers [Mon, 7 Apr 2014 01:04:40 +0000 (18:04 -0700)]
Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names.

10 years agorustc: Use realpath() for sysroot/rpath
Alex Crichton [Tue, 8 Apr 2014 17:15:46 +0000 (10:15 -0700)]
rustc: Use realpath() for sysroot/rpath

When calculating the sysroot, it's more accurate to use realpath() rather than
just one readlink() to account for any intermediate symlinks that the rustc
binary resolves itself to.

For rpath, realpath() is necessary because the rpath must dictate a relative
rpath from the destination back to the originally linked library, which works
more robustly if there are no symlinks involved.

Concretely, any binary generated on OSX into $TMPDIR requires an absolute rpath
because the temporary directory is behind a symlink with one layer of
indirection. This symlink causes all relative rpaths to fail to resolve.

cc #11734
cc #11857

10 years agorustc: Add a realpath utility function
Alex Crichton [Tue, 8 Apr 2014 17:06:11 +0000 (10:06 -0700)]
rustc: Add a realpath utility function

This is required in rustc to resolve symlinks for utilities such as the sysroot
and the rpath values which are encoded into binaries.

10 years agorustc: Don't rpath to librustrt.dylib
Alex Crichton [Tue, 8 Apr 2014 17:05:18 +0000 (10:05 -0700)]
rustc: Don't rpath to librustrt.dylib

This library no longer exists, there's no reason for this rpath to exist any
more.

10 years agorustc: Remove absolute rpaths
Alex Crichton [Mon, 7 Apr 2014 22:40:58 +0000 (15:40 -0700)]
rustc: Remove absolute rpaths

Concerns have been raised about using absolute rpaths in #11746, and this is the
first step towards not relying on rpaths at all. The only current use case for
an absolute rpath is when a non-installed rust builds an executable that then
moves from is built location. The relative rpath back to libstd and absolute
rpath to the installation directory still remain (CFG_PREFIX).

Closes #11746
Rebasing of #12754

10 years agorustdoc: Prune the paths that do not appear in the index.
Kang Seonghoon [Tue, 8 Apr 2014 18:25:54 +0000 (03:25 +0900)]
rustdoc: Prune the paths that do not appear in the index.

For the full library and compiler docs, the size of
`search-index.js` decreases by 13% (18.5% after gzip -9)
which is a substantial gain.

10 years agorustdoc: Clean the `initSearch` routine up.
Kang Seonghoon [Tue, 8 Apr 2014 17:47:52 +0000 (02:47 +0900)]
rustdoc: Clean the `initSearch` routine up.

10 years agomk: Add a dummy CFG_COMPILER_HOST_TRIPLE to rustdoc invocation.
Kang Seonghoon [Tue, 8 Apr 2014 17:45:53 +0000 (02:45 +0900)]
mk: Add a dummy CFG_COMPILER_HOST_TRIPLE to rustdoc invocation.

Otherwise it will prohibit `make compiler-docs` on Windows.

10 years agotest: Add a test for #7663
Alex Crichton [Tue, 8 Apr 2014 18:38:18 +0000 (11:38 -0700)]
test: Add a test for #7663

I think that the test case from this issue has become out of date with resolve
changes in the past 9 months, and it's not entirely clear to me what the
original bug was.

Regardless, it seems like tricky resolve behavior, so tests were added to make
sure things resolved correctly and warnings were correctly reported.

Closes #7663

10 years agoGeneralized the pretty-print entry points to support `-o <file>`.
Felix S. Klock II [Tue, 8 Apr 2014 20:07:15 +0000 (22:07 +0200)]
Generalized the pretty-print entry points to support `-o <file>`.

10 years agoRemove an unnecessary file.
OGINO Masanori [Wed, 9 Apr 2014 04:42:44 +0000 (13:42 +0900)]
Remove an unnecessary file.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoStop using transmute_mut in RefCell
Steven Fackler [Wed, 9 Apr 2014 05:54:06 +0000 (22:54 -0700)]
Stop using transmute_mut in RefCell

This is supposedly undefined behavior now that Unsafe exists, so we'll
use Cell instead.

10 years agoRemove some internal ~[] from several libraries.
Huon Wilson [Wed, 9 Apr 2014 10:02:26 +0000 (20:02 +1000)]
Remove some internal ~[] from several libraries.

Some straggling instances of `~[]` across a few different libs. Also,
remove some public ones from workcache.

10 years agonative: remove some internal ~[].
Huon Wilson [Wed, 9 Apr 2014 09:41:44 +0000 (19:41 +1000)]
native: remove some internal ~[].

10 years agogreen: de-~[].
Huon Wilson [Wed, 9 Apr 2014 08:36:19 +0000 (18:36 +1000)]
green: de-~[].

10 years agostd,syntax: make std::fmt::parse use `Vec`s.
Huon Wilson [Wed, 9 Apr 2014 01:46:49 +0000 (11:46 +1000)]
std,syntax: make std::fmt::parse use `Vec`s.