Commit Graph

26593 Commits

Author SHA1 Message Date
Brendan Zabarauskas
6943acd1a5 Reduce reliance on to_str_radix
This is in preparation to remove the implementations of ToStrRadix in integers, and to remove the associated logic from `std::num::strconv`.

The parts that still need to be liberated are:

- `std::fmt::Formatter::runplural`
- `num::{bigint, complex, rational}`
2014-02-22 03:56:16 +11:00
Brendan Zabarauskas
e37327bfee Decouple integer formatting from std::num::strconv
This works towards a complete rewrite and ultimate removal of the `std::num::strconv` module (see #6220), and the removal of the `ToStrRadix` trait in favour of using the `std::fmt` functionality directly. This should make for a cleaner API, encourage less allocation, and make the implementation far more comprehensible.

The `Formatter::pad_integral` method has also been refactored make it easier to understand.

The formatting tests for integers have been moved out of `run-pass/ifmt.rs` in order to provide more immediate feedback when building using `make check-stage2-std NO_REBUILD=1`.

The benchmarks have been standardised between std::num::strconv and std::num::fmt to make it easier to compare the performance of the different implementations.

Arbitrary radixes are now easier to use in format strings. For example:

~~~
assert_eq!(format!("{:04}", radix(3, 2)), ~"0011");
~~~
2014-02-22 03:56:16 +11:00
Brendan Zabarauskas
9abff54d61 Add Pod trait bound to std::num::Primitive 2014-02-22 03:51:56 +11:00
bors
2fa7d6b44f auto merge of #12415 : HeroesGrave/rust/move-enum-set, r=alexcrichton
Part of #8784

Also removed the one glob import.
2014-02-21 05:26:58 -08:00
bors
c9864cec2b auto merge of #12410 : DaGenix/rust/fix-incorrect-comment, r=alexcrichton
The comments say that the prelude imports std::io::println since it would
be annoying to have to import it in every program that uses it. However,
the prelude doesn't actually import that function anymore. So, update the
comments to better match reality.
2014-02-21 04:01:57 -08:00
bors
37903cbf4d auto merge of #12290 : mrshu/rust/lint-warn-by-default, r=alexcrichton
This first part of my attempts to fix #11432.

In this one I only set NonCamelCaseTypes to warn by default and tried to fix errors that were reported by `make check`.

Please feel free to let me know if I missed something or didn't do it the right way.

Thanks.
2014-02-21 00:56:58 -08:00
bors
ca41bbb2e3 auto merge of #12407 : alexcrichton/rust/up-llvm, r=sfackler
This updates the LLVM submodule to the `rust-llvm-2014-02-19` tag which is the
old one with https://github.com/rust-lang/llvm/pull/4 cherry-picked on top.

Awesome job by @neykov for this!
2014-02-20 23:16:57 -08:00
mr.Shu
70319f7b25 Changed NonCamelCaseTypes lint to warn by default
Added allow(non_camel_case_types) to librustc where necesary

Tried to fix problems with non_camel_case_types outside rustc

fixed failing tests

Docs updated

Moved #[allow(non_camel_case_types)] a level higher.

markdown.rs reverted

Fixed timer that was failing tests

Fixed another timer
2014-02-21 08:11:52 +01:00
bors
d70f909fa3 auto merge of #12164 : alexcrichton/rust/rlibs-and-dylibs, r=cmr
The first commit improves error messages during linking, and the second commit improves error messages during crate-loading time.

Closes #12297
Closes #12377
2014-02-20 18:51:57 -08:00
Alex Crichton
afa5f574ff Re-work loading crates with nicer errors
This commit rewrites crate loading internally in attempt to look at less
metadata and provide nicer errors. The loading is now split up into a few
stages:

1. Collect a mapping of (hash => ~[Path]) for a set of candidate libraries for a
   given search. The hash is the hash in the filename and the Path is the
   location of the library in question. All candidates are filtered based on
   their prefix/suffix (dylib/rlib appropriate) and then the hash/version are
   split up and are compared (if necessary).

   This means that if you're looking for an exact hash of library you don't have
   to open up the metadata of all libraries named the same, but also in your
   path.

2. Once this mapping is constructed, each (hash, ~[Path]) pair is filtered down
   to just a Path. This is necessary because the same rlib could show up twice
   in the path in multiple locations. Right now the filenames are based on just
   the crate id, so this could be indicative of multiple version of a crate
   during one crate_id lifetime in the path. If multiple duplicate crates are
   found, an error is generated.

3. Now that we have a mapping of (hash => Path), we error on multiple versions
   saying that multiple versions were found. Only if there's one (hash => Path)
   pair do we actually return that Path and its metadata.

With this restructuring, it restructures code so errors which were assertions
previously are now first-class errors. Additionally, this should read much less
metadata with lots of crates of the same name or same version in a path.

Closes #11908
2014-02-20 17:48:32 -08:00
bors
7e9bcc5456 auto merge of #12401 : alexcrichton/rust/if-ok-2-try, r=brson
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 16:56:51 -08:00
bors
6532d2fa0d auto merge of #12161 : aepsil0n/rust/docs/for-loop, r=alexcrichton
I just started learning Rust and the absence of an explanation of the for-loop in the beginning really bugged me about the tutorial. Hence I simply added these lines, where I would have expected them. I know that there is something later on in the section on traits. However, this simple iteration scheme feels like something that you should be aware of right away.
2014-02-20 10:36:49 -08:00
Alex Crichton
7bb498bd7a Mass rename if_ok! to try!
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 09:16:52 -08:00
bors
1366e04cf4 auto merge of #12405 : kud1ing/rust/backticks, r=huonw 2014-02-20 08:21:45 -08:00
bors
06e1281198 auto merge of #12403 : eddyb/rust/generic-dtors-with-bounds, r=nikomatsakis
Fix generic Drop impls with trait bounds.
Fixes #4252.
2014-02-20 07:06:49 -08:00
bors
5f324aaf20 auto merge of #12399 : michaelwoerister/rust/simd-fix, r=alexcrichton
Fixes  #12333.
I also re-enabled the *function-arg-initialization* test case, so if it passes again, fixes #12021.
2014-02-20 05:46:48 -08:00
bors
882c25fa2d auto merge of #12398 : alexcrichton/rust/rlibs-and-dylibs-2, r=cmr
The new methodology can be found in the re-worded comment, but the gist of it is
that -C prefer-dynamic doesn't turn off static linkage. The error messages
should also be a little more sane now.

Closes #12133
2014-02-20 04:31:49 -08:00
bors
47b05278d0 auto merge of #12397 : alexcrichton/rust/send-off-the-runtime, r=brson
The fairness yield mistakenly called `Local::take()` which meant that it would
only work if a local task was available. In theory sending on a channel (or calling try_recv) requires
no runtime because it never blocks, so there's no reason it shouldn't support
such a use case.

Closes #12391
2014-02-20 03:11:48 -08:00
bors
25ba057fad auto merge of #12343 : liigo/rust/move-extra-test-to-libtest, r=alexcrichton
I don't think `extra` is a good/meaningful name for a library. `libextra` should disappear, and we move all of its sub modules out of it. This PR is just one of that steps: move `extra::test` to `libtest`.

I didn't add `libtest` to doc index, because it's an internal library currently.

**Update:**

All comments addressed. All tests passed. Rebased and squashed.
2014-02-20 01:51:56 -08:00
bors
f76628d390 auto merge of #12396 : alexcrichton/rust/windows-env-var, r=huonw
On windows, the GetEnvironmentVariable function will return the necessary buffer
size if the buffer provided was too small. This case previously fell through the
checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice`
method.

This adds an extra case for when the return value is >= the buffer size, in
which case we assume the return value as the new buffer size and try again.

Closes #12376
2014-02-20 00:36:53 -08:00
Liigo Zhuang
53b9d1a324 move extra::test to libtest 2014-02-20 16:03:58 +08:00
bors
b5e35736b0 auto merge of #12392 : aepsil0n/rust/fix/pub_randbigint, r=huonw
Closes #12383.

Test suite did not capture this and can't as long as it is in the same module hierarchy. This is probably something that should be addressed in the future.
2014-02-19 23:21:50 -08:00
HeroesGrave
5bf8d3289f move enum_set to libcollections. #8784 2014-02-20 19:38:01 +13:00
bors
0cc8ba0c20 auto merge of #12244 : pcwalton/rust/deuniquevectorpatterns, r=pcwalton
Preparatory work for removing unique vectors from the language, which is
itself preparatory work for dynamically sized types.

r? @brson
2014-02-19 21:56:51 -08:00
bors
801f8f67f8 auto merge of #12394 : huonw/rust/transmute--, r=pnkfelix
These can all be done by implicit or explicit &T -> *T casts, which are
more restricted and so are safer.
2014-02-19 20:41:51 -08:00
Palmer Cox
bb6fc34b37 Update comments in the prelude
The comments say that the prelude imports std::io::println since it would
be annoying to have to import it in every program that uses it. However,
the prelude doesn't actually import that function anymore. So, update the
comments to better match reality.
2014-02-19 22:08:57 -05:00
Alex Crichton
765a4e9fe3 Fix sending/try_recv on channels off the runtime
The fairness yield mistakenly called `Local::take()` which meant that it would
only work if a local task was available. In theory sending on a channel (or
calling try_recv) requires no runtime because it never blocks, so there's no
reason it shouldn't support such a use case.

Closes #12391
2014-02-19 16:53:00 -08:00
Patrick Walton
33923f47e3 librustc: Remove unique vector patterns from the language.
Preparatory work for removing unique vectors from the language, which is
itself preparatory work for dynamically sized types.
2014-02-19 16:35:31 -08:00
bors
879e8aa7be auto merge of #12387 : cmr/rust/ast-json, r=alexcrichton
See the commits
2014-02-19 16:21:48 -08:00
bors
ea0058281c auto merge of #12389 : zr40/rust/fix-test-metric-typo, r=alexcrichton 2014-02-19 15:01:50 -08:00
Alex Crichton
fda671683e Upgrade LLVM for segmented stacks on thumb
This updates the LLVM submodule to the `rust-llvm-2014-02-19` tag which is the
old one with https://github.com/rust-lang/llvm/pull/4 cherry-picked on top.

Awesome job by @neykov for this!
2014-02-19 14:58:02 -08:00
Eduard Burtescu
efaa1ea979 Resolve the vtables for method calls to generic Drop impls with trait bounds. 2014-02-20 00:12:09 +02:00
kud1ing
4ad57513f4 adjust to currently used style 2014-02-19 22:38:15 +01:00
Eduard Burtescu
efef078cfa Replaced method_map_entry with method_origin and cleaned up vtable checking a bit. 2014-02-19 23:26:40 +02:00
Eduard Burtescu
1ca1ff23d3 Don't recurse twice into ExprParen in vtable checking. 2014-02-19 23:26:40 +02:00
bors
6ae5de0223 auto merge of #12231 : wycats/rust/url_path_parse, r=alexcrichton
It is sometimes useful to parse just the path portion of a URL (path,
query string and fragment) rather than the entire URL.

In theory I could have made Url embed a Path, but that would be a
breaking change and I assume that Servo uses this API. I would be
happy to update the PR to embed Path in Url if that's what people
wanted.
2014-02-19 12:51:48 -08:00
bors
1228fb0c99 auto merge of #11904 : nick29581/rust/0filemap, r=alexcrichton 2014-02-19 11:36:48 -08:00
Corey Richardson
34ffe3cc1c rustc: support dumping the AST as JSON
This is mostly useful for working on rustc, when one is unfamiliar with the
AST a particular construct will produce. It's a -Z flag as it's very much for
debugging.

Closes #10485
2014-02-19 13:32:26 -05:00
bors
209b47f248 auto merge of #12379 : alexcrichton/rust/fix-ar-thing, r=brson
When creating a staticlib, it unzips all static archives it finds and then
inserts the files manually into the output file. This process is done through
`ar`, and `ar` doesn't like if you specify you want to add files and you don't
give it any files.

This case arose whenever you linked to an archive that didn't have any contents
or all of the contents were filtered out. This just involved ignoring the case
where the number of inputs we have is 0, because we don't have any files to add
anyway.
2014-02-19 10:21:50 -08:00
bors
af4b5b4aac auto merge of #12375 : FlaPer87/rust/issue-7660, r=cmr 2014-02-19 09:01:51 -08:00
Alex Crichton
35c6e22fab Tweak how preference factors into linkage
The new methodology can be found in the re-worded comment, but the gist of it is
that -C prefer-dynamic doesn't turn off static linkage. The error messages
should also be a little more sane now.

Closes #12133
2014-02-19 08:33:08 -08:00
Michael Woerister
a40b272fae debuginfo: Re-enable test case that should have worked all along. 2014-02-19 17:16:36 +01:00
Michael Woerister
6656e5cd45 debuginfo: Fix a RUSTFLAGS incompatibility in test runner. 2014-02-19 17:12:37 +01:00
Michael Woerister
3ce04dc719 debuginfo: Move test case from run-pass to debug-info directory so it does not interfere with RUSTFLAGS=-g 2014-02-19 17:12:37 +01:00
Michael Woerister
5f9e32ad68 debuginfo: Add support for simd types 2014-02-19 17:12:37 +01:00
Alex Crichton
9347096d54 Fix getting/setting huge env vars on windows
On windows, the GetEnvironmentVariable function will return the necessary buffer
size if the buffer provided was too small. This case previously fell through the
checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice`
method.

This adds an extra case for when the return value is >= the buffer size, in
which case we assume the return value as the new buffer size and try again.

Closes #12376
2014-02-19 08:11:00 -08:00
bors
98b07755dd auto merge of #12374 : dylanbraithwaite/rust/size_of_unit_clarification, r=cmr
Changed the docs for std::mem to clarify the fact that the size functions return sizes in bytes.
2014-02-19 07:16:48 -08:00
Huon Wilson
dcee327c35 rustc: remove some unnecessary transmutes.
These can all be done by implicit or explicit &T -> *T casts, which are
more restricted and so are safer.
2014-02-20 01:31:39 +11:00
bors
ace204a745 auto merge of #12349 : edwardw/rust/debug-expansion, r=huonw
Currently, the format_args! macro and its downstream macros in turn
expand to series of let statements, one for each of its arguments, and
then the invocation of the macro function. If one or more of the
arguments are RefCell's, the enclosing statement for the temporary of
the let is the let itself, which leads to scope problem. This patch
changes let's to a match expression.

Closes #12239.
2014-02-19 06:01:45 -08:00
Eduard Bopp
cb3a419d97 libnum: Make RandBigInt trait public
Closes #12383.
2014-02-19 14:01:50 +01:00