Commit Graph

20255 Commits

Author SHA1 Message Date
Brian Anderson
b17141370f std::rt: Rename RUST_TEST_THREADS to RUST_RT_TEST_THREADS 2013-07-17 10:47:05 -07:00
Daniel Micay
0239a06a64 rm unused visit_str method from TyVisitor 2013-07-17 13:30:32 -04:00
Daniel Micay
8d561587b2 stop initializing ref_count for stack closures
the only part of the header ~fn and &fn should be touching right now is
the tydesc
2013-07-17 13:30:32 -04: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
Alex Crichton
8885b740f6 Add documentation about mutable statics to rust.md 2013-07-17 08:57:08 -07:00
Björn Steinbrink
15ea4a8dd8 Generate better code for intrinsics
Currently, our intrinsics are generated as functions that have the
usual setup, which means an alloca, and therefore also a jump, for
those intrinsics that return an immediate value. This is especially bad
for unoptimized builds because it means that an intrinsic like
"contains_managed" that should be just "ret 0" or "ret 1" actually ends
up allocating stack space, doing a jump and a store/load sequence
before it finally returns the value.

To fix that, we need a way to stop the generic function declaration
mechanism from allocating stack space for the return value. This
implicitly also kills the jump, because the block for static allocas
isn't required anymore.

Additionally, trans_intrinsic needs to build the return itself instead
of calling finish_fn, because the latter relies on the availability of
the return value pointer.

With these changes, we get the bare minimum code required for our
intrinsics, which makes them small enough that inlining them makes the
resulting code smaller, so we can mark them as "always inline" to get
better performing unoptimized builds.

Optimized builds also benefit slightly from this change as there's less
code for LLVM to translate and the smaller intrinsics help it to make
better inlining decisions for a few code paths.

Building stage2 librustc gets ~1% faster for the optimized version and 5% for
the unoptimized version.
2013-07-17 17:21:41 +02:00
Björn Steinbrink
3e572511af Remove duplicated code from trans_intrinsics
Most arms of the huge match contain the same code, differing only in
small details like the name of the llvm intrinsic that is to be called.
Thus the duplicated code can be factored out into a few functions that
take some parameters to handle the differences.
2013-07-17 17:18:29 +02:00
Niko Matsakis
782853c658 Issue #7444 - Update neg test and pos test for move by capture 2013-07-17 09:02:52 -04:00
bors
93c270c63d auto merge of #7843 : alexcrichton/rust/better-lint-help, r=huonw
Closes #7818
2013-07-17 05:55:42 -07:00
Niko Matsakis
81c576cd5b Issue #7444 - Borrowck permits moved values to be captured 2013-07-17 07:19:43 -04: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
Alex Crichton
a468869e2a Remove --quiet from git submodule operations 2013-07-17 01:50:22 -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
gifnksm
827a6d26e6 tutorial: remove unused link references. 2013-07-17 15:38:26 +09: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
gifnksm
5d4b990fc6 tutorial: remove duplicate link references.
`pandoc` issues warnings.

```
pandoc: Duplicate link reference `[macros]' "source" (line 2151, column 1)
pandoc: Duplicate link reference `[tasks]' "source" (line 2150, column 1)
pandoc: Duplicate link reference `[wiki-start]' "source" (line 92, column 1)
```
2013-07-17 13:29:10 +09: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
Alex Crichton
d5f53c780e Provide more useful messages when tests are given -h or --help
Progress on #7824
2013-07-16 20:08:01 -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