Commit Graph

20097 Commits

Author SHA1 Message Date
Patrick Walton
99b33f7219 librustc: Remove all uses of "copy". 2013-07-17 14:57:51 -07:00
Patrick Walton
b4e674f6e6 librustc: Add a lint mode for unnecessary copy and remove a bunch of them. 2013-07-17 14:56:42 -07:00
bors
8c082658be auto merge of #7829 : graydon/rust/codegen-compiletests, r=cmr
This should get us over the hump of activating basic ratcheting on codegen tests, at least. It also puts in place optional (disabled by default) ratcheting on all #[bench] tests, and records all metrics from them to harvestable .json files in any case.
2013-07-17 13:07:24 -07:00
Graydon Hoare
6d78a367b1 extra: avoid possible divide-by-zero conditions test. 2013-07-17 12:28:48 -07:00
Graydon Hoare
4bf6b84a4d make: turn off --bench when running under valgrind 2013-07-17 11:52:21 -07:00
bors
060de1016b auto merge of #7844 : huonw/rust/no-implicit-prelude, r=alexcrichton
It disables the insertion of `use std::prelude::*;` into the top of
all the modules below the item on which it is placed (including that
item itself).

(Similar to GHC's `-XNoImplicitPrelude`.)
2013-07-17 11:28:46 -07:00
bors
9c1e530bde auto merge of #7826 : michaelwoerister/rust/end_of_spanned, r=cmr
This is the first of a series of refactorings to get rid of the `codemap::spanned<T>` struct (see this thread for more information: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004798.html).

The changes in this PR should not change any semantics, just rename `ast::blk_` to `ast::blk` and add a span field to it. 95% of the changes were of the form `block.node.id` -> `block.id`. Only some transformations in `libsyntax::fold` where not entirely trivial.
2013-07-17 09:49:43 -07:00
bors
93c270c63d auto merge of #7843 : alexcrichton/rust/better-lint-help, r=huonw
Closes #7818
2013-07-17 05:55:42 -07:00
bors
9da42dce27 auto merge of #7835 : omasanori/rust/l10n-improvement, r=pnkfelix
Adding options for `po4a` in `mk/docs.mk` and updating .pots.
2013-07-17 04:16:42 -07:00
bors
c032dddf6f auto merge of #7841 : alexcrichton/rust/tls++, r=huonw
Simulates borrow checks for '@mut' boxes, or at least it's the same idea. This allows you to store owned values, but mutate them while they're owned by TLS.

This should remove the necessity for a `pop`/`set` pattern to mutate data structures in TLS.
2013-07-17 02:37:43 -07:00
bors
a93244dbf6 auto merge of #7839 : graydon/rust/new-codegen-tests, r=pcwalton
Add some codegen tests. Nothing too surprising.
2013-07-17 00:52:48 -07:00
Michael Woerister
0cc70743d2 Made ast::blk not use spanned<T> anymore. 2013-07-17 08:21:46 +02:00
bors
af54f633fd auto merge of #7828 : alexcrichton/rust/lang-opt, r=graydon
Whenever a lang_item is required, some relevant message is displayed, often with
a span of what triggered the usage of the lang item.

Now "hello word" is as small as:

```rust
#[no_std];

extern {
    fn puts(s: *u8);
}

extern "rust-intrinsic" {
    fn transmute<T, U>(t: T) -> U;
}

#[start]
fn main(_: int, _: **u8, _: *u8) -> int {
    unsafe {
        let (ptr, _): (*u8, uint) = transmute("Hello!");
        puts(ptr);
    }
    return 0;
}
```
2013-07-16 23:10:44 -07:00
Huon Wilson
040e470f47 rustc: implement a #[no_implicit_prelude] attribute.
It disables the insertion of `use std::prelude::*;` into the top of
all the modules below the item on which it is placed (including that
item itself).
2013-07-17 15:01:02 +10:00
Alex Crichton
88a1b71305 Make all lang_items optional
Whenever a lang_item is required, some relevant message is displayed, often with
a span of what triggered the usage of the lang item
2013-07-16 21:37:52 -07:00
bors
4bd716ac8e auto merge of #7831 : ozten/rust/issues-7764-swap_unwarp-take-unwrap, r=pcwalton
Fixes Issue #7764

Running `make check` I do get a failure:

    test rt::io::extensions::test::push_bytes ... ok
    rustest rt::comm::test::oneshot_single_thread_send_port_close ... t: task failed at 'Unhandled condition:
     read_error: {kind: OtherIoError, desc: "Placeholder error. You shouldn\'t be seeing this", detail: None}',
     /Users/shout/Projects/rust/src/libstd/condition.rs:50
    /bin/sh: line 1: 35056 Abort trap: 6           x86_64-apple-darwin/stage2/test/stdtest-x86_64-apple-darwin --logfile
     tmp/check-stage2-T-x86_64-apple-darwin-H-x86_64-apple-darwin-std.log
    make: *** [tmp/check-stage2-T-x86_64-apple-darwin-H-x86_64-apple-darwin-std.ok] Error 134
2013-07-16 21:31:48 -07:00
Alex Crichton
0fd4d5d778 Sort lint attributes to print them in a more sane way
Closes #7818
2013-07-16 21:28:10 -07:00
Alex Crichton
948a62401e Add a get_mut method for TLS
Simulates borrow checks for '@mut' boxes, or at least it's the same idea.
2013-07-16 20:33:04 -07:00
Graydon Hoare
40f74341f3 test: new codegen tests, rename hello. 2013-07-16 17:44:57 -07:00
bors
8a1002fbd9 auto merge of #7827 : jdm/rust/enumlength, r=graydon
Allowing them in type signatures is a significant amount of extra work, unfortunately. This also doesn't apply to static values, which takes a different code path.
2013-07-16 16:19:37 -07:00
OGINO Masanori
ad3a69739f Add project information to l10n templates. 2013-07-17 07:48:30 +09:00
bors
53e934c2ab auto merge of #7684 : pnkfelix/rust/fsk-invert-range-rev-halfclosedness-issue5270-2ndpr, r=cmr
Changes int/uint range_rev to iterate over range `(hi,lo]` instead of `[hi,lo)`.

Fix #5270.

Also:
* Adds unit tests for int/uint range functions
* Updates the uses of `range_rev` to account for the new semantics.  (Note that pretty much all of the updates there were strict improvements to the code in question; yay!)
* Exposes new function, `range_step_inclusive`, which does the range `[hi,lo]`, (at least when `hi-lo` is a multiple of the `step` parameter).
* Special-cases when `|step| == 1` removing unnecessary bounds-check.  (I did not check whether LLVM was already performing this optimization; I figure it would be a net win to not leave that analysis to the compiler.  If reviewer objects, I can easily remove that from the refactored code.)

(This pull request is a rebased version of PR #7524, which went stale due to recent unrelated changes to num libraries.)
2013-07-16 14:37:34 -07:00
bors
9db190305f auto merge of #7823 : pnkfelix/rust/issue7821-document-lint-attributes, r=graydon
r? anyone

Fix #7821.
2013-07-16 12:58:31 -07:00
Austin King
712ac836c6 Rename Option swap_unwrap to take_unwrap. Fixes Issue#7764 2013-07-16 12:47:01 -07:00
bors
ad212ecee4 auto merge of #7822 : huonw/rust/cond-debug, r=graydon
As per @pcwalton's request, `debug!(..)` is only activated when the `debug` cfg is set; that is, for `RUST_LOG=some_module=4 ./some_program` to work, it needs to be compiled with `rustc --cfg debug some_program.rs`. (Although, there is the sneaky `__debug!(..)` macro that is always active, if you *really* need it.)

It functions by making `debug!` expand to `if false { __debug!(..) }` (expanding to an `if` like this is required to make sure `debug!` statements are typechecked and to avoid unused variable warnings), and adjusting trans to skip the pointless branches in `if true ...` and `if false ...`.

The conditional expansion change also required moving the inject-std-macros step into a new pass, and makes it actually insert them at the top of the crate; this means that the cfg stripping traverses over the macros and so filters out the unused ones.

This appears to takes an unoptimised build of `librustc` from 65s to 59s; and the full bootstrap from 18m41s to 18m26s on my computer (with general background use).

`./configure --enable-debug` will enable `debug!` statements in the bootstrap build.
2013-07-16 11:19:20 -07:00
Huon Wilson
4797dd4087 rustc: selectively trans branches for if <literal-bool>.
That is, the `b` branch in `if true { a } else { b }` will not be
trans'd, and that expression will be exactly the same as `a`. This
means that, for example, macros conditionally expanding to `if false
{ .. }` (like debug!) will not waste time in LLVM (or trans).
2013-07-17 03:13:41 +10:00
Huon Wilson
e252277fe9 rustc: handle allocas and LoadRangeAsserts in unreachable blocks correctly.
An alloca in an unreachable block would shortcircuit with Undef, but with type
`Type`, rather than type `*Type` (i.e. a plain value, not a pointer) but it is
expected to return a pointer into the stack, leading to confusion and LLVM
asserts later.

Similarly, attaching the range metadata to a Load in an unreachable block
makes LLVM unhappy, since the Load returns Undef.

Fixes #7344.
2013-07-17 03:13:23 +10:00
Huon Wilson
e4f7561bcd Clean-up tests after debug!/std-macros change.
The entire testsuite is converted to using info! rather than debug!
because some depend on the code within the debug! being trans'd.
2013-07-17 03:10:13 +10:00
Graydon Hoare
8e58a272cc extra: reduce bench loop max time to 3s. 2013-07-16 09:33:54 -07:00
Graydon Hoare
cdce33a421 Add configure and make machinery to activate perf metrics and ratchets. 2013-07-16 09:33:54 -07:00
Graydon Hoare
bc4c89c10a compiletest: Add support for metrics and ratchet modes. 2013-07-16 09:33:54 -07:00
Graydon Hoare
f2f7fb3ae1 extra: Add metrics functions to test. 2013-07-16 09:33:54 -07:00
Graydon Hoare
77823c907b extra: add tests for test::MetricMap, MetricDiff, ratchet. 2013-07-16 09:33:54 -07:00
bors
a317584e4f auto merge of #7726 : omasanori/rust/semver-2.0.0, r=graydon
The Ord impl of Version refered to the algorithm in release candidate versions of semver. [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html) says, "Build metadata SHOULD be ignored when determining version precedence."

Note that Version's `le` is not "less than or equal to" now, since `lt` ignores build metadata. I think the new ordering algorithm satisfies strict weak ordering which C++ STL requires, instead of strict total ordering.

BTW, is `a || b || ... || x`-style code better or idiomatic in Rust than `if a { return true; } if b { return true; } ... if x { return true; } return false;`-style one?
2013-07-16 09:31:28 -07:00
Felix S. Klock II
8515abe0d9 Add doc and examples for attributes allow/warn/deny/forbid.
Fix #7821.
2013-07-16 18:20:49 +02:00
Josh Matthews
877bba91d5 Permit C-style enums in vector repeat length expressions (N.B. values only, not type signatures) 2013-07-16 12:05:24 -04:00
OGINO Masanori
31d29d394f Add more tests for build metadata. 2013-07-16 20:53:25 +09:00
OGINO Masanori
9ba32f306a Update the ordering algorithm to semver 2.0.0.
Note that Version's `le` is not "less than or equal to" now, since `lt`
ignores build metadata. I think the new ordering algorithm satisfies
strict weak ordering which C++ STL requires, instead of strict total
ordering.
2013-07-16 20:53:25 +09:00
Huon Wilson
b48e37e8ee syntax: make a macros-injection pass; conditionally define debug! to a noop based on cfg(debug).
Macros can be conditionally defined because stripping occurs before macro
expansion, but, the built-in macros were only added as part of the actual
expansion process and so couldn't be stripped to have definitions conditional
on cfg flags.

debug! is defined conditionally in terms of the debug config, expanding to
nothing unless the --cfg debug flag is passed (to be precise it expands to
`if false { normal_debug!(...) }` so that they are still type checked, and
to avoid unused variable lints).
2013-07-16 15:05:50 +10:00
bors
274e7a4e49 auto merge of #7816 : thestinger/rust/header, r=huonw
Note that the headers are still on `~[T]` when `T` is managed. This is continued from #7605, which removed all the code relying on the headers and removed them from `~T` for non-managed `T`.
2013-07-15 21:01:20 -07:00
Daniel Micay
e118555ce6 remove headers from unique vectors 2013-07-15 23:57:27 -04:00
bors
47ba4583db auto merge of #7815 : blake2-ppc/rust/hashmap-iterators, r=huonw
Implement set difference, sym. difference, intersection and union using Iterators.

The set methods are left since they are part of the Set trait. A grep over the tree indicates that the four hashset operations have no users at all.

Also remove HashMap::mutate_values since it is unused, replaced by .mut_iter(), and not part of a trait.
2013-07-15 19:19:21 -07:00
blake2-ppc
750f32dbb5 hashmap: Iterators for hashset diff, sym. diff, intersec, union
Implement the difference, union, etc iterators with the help of a custom
iterator combinator with explicit closure environment. Reported issue #7814
to be able to use the std::iterator filter combinator.
2013-07-16 04:09:41 +02:00
blake2-ppc
cf4127f503 hashmap: Remove .mutate_values() which is replaced by .mut_iter() 2013-07-16 03:55:52 +02:00
bors
98c16549cb auto merge of #7808 : blake2-ppc/rust/ringbuf, r=thestinger 2013-07-15 17:04:20 -07:00
blake2-ppc
3385e795c5 ringbuf: Implement DoubleEndedIterator 2013-07-16 01:13:26 +02:00
bors
e844b524ed auto merge of #7806 : apasel422/rust/hash_consume, r=catamorphism
This partially addresses #7719.
2013-07-15 15:22:19 -07:00
Andrew Paseltiner
faa280cee6 std: add consuming iterators for HashMap and HashSet 2013-07-15 17:32:53 -04:00
bors
04f9ce0ae3 auto merge of #7681 : catamorphism/rust/rustpkg-local-repos, r=catamorphism
r? @graydon rustpkg can now build code from a local git repository. In the
case where the local repo is in a directory not in the RUST_PATH,
it checks out the repository into a directory in the first workspace
in the RUST_PATH.

The tests no longer try to connect to github.com, which should
solve some of the sporadic failures we've been seeing.
2013-07-15 13:40:21 -07:00
Tim Chevalier
0fa9ad8673 rustpkg: Handle local git repositories
rustpkg can now build code from a local git repository. In the
case where the local repo is in a directory not in the RUST_PATH,
it checks out the repository into a directory in the first workspace
in the RUST_PATH.

The tests no longer try to connect to github.com, which should
solve some of the sporadic failures we've been seeing.
2013-07-15 12:59:48 -07:00