Commit Graph

24477 Commits

Author SHA1 Message Date
bors
f817ed3e6f auto merge of #10823 : rapha/rust/master, r=alexcrichton
Hi, first pull request here so let me know if I've missed any of the procedure.
2013-12-09 13:51:32 -08:00
Niko Matsakis
1252947fa9 Make main pub in test case (cc #9629) 2013-12-09 14:54:59 -05:00
Niko Matsakis
9f7baedc62 Address nits for PR for #9629 2013-12-09 12:45:13 -05:00
Raphael Speyer
7168d715a5 Implement PortReader and ChanWriter 2013-12-10 04:20:39 +11:00
Jan Niklas Hasse
6de5b7ab1e Add missing .com 2013-12-09 17:40:10 +01:00
Alex Crichton
52b835c5e7 Store metadata separately in rlib files
Right now whenever an rlib file is linked against, all of the metadata from the
rlib is pulled in to the final staticlib or binary. The reason for this is that
the metadata is currently stored in a section of the object file. Note that this
is intentional for dynamic libraries in order to distribute metadata bundled
with static libraries.

This commit alters the situation for rlib libraries to instead store the
metadata in a separate file in the archive. In doing so, when the archive is
passed to the linker, none of the metadata will get pulled into the result
executable. Furthermore, the metadata file is skipped when assembling rlibs into
an archive.

The snag in this implementation comes with multiple output formats. When
generating a dylib, the metadata needs to be in the object file, but when
generating an rlib this needs to be separate. In order to accomplish this, the
metadata variable is inserted into an entirely separate LLVM Module which is
then codegen'd into a different location (foo.metadata.o). This is then linked
into dynamic libraries and silently ignored for rlib files.

While changing how metadata is inserted into archives, I have also stopped
compressing metadata when inserted into rlib files. We have wanted to stop
compressing metadata, but the sections it creates in object file sections are
apparently too large. Thankfully if it's just an arbitrary file it doesn't
matter how large it is.

I have seen massive reductions in executable sizes, as well as staticlib output
sizes (to confirm that this is all working).
2013-12-09 08:25:58 -08:00
bors
b485e2b65d auto merge of #10881 : sanxiyn/rust/allocation-lint-2, r=alexcrichton 2013-12-09 08:21:32 -08:00
Seo Sanghyeon
3b14f25868 Extend allocation lint for boxing expressions 2013-12-10 01:17:32 +09:00
bors
4e0cb316fc auto merge of #10840 : cmr/rust/any_docs2, r=huonw 2013-12-09 05:51:29 -08:00
Corey Richardson
4051713625 Add some Any docs. 2013-12-09 07:23:14 -05:00
bors
a417dbd1c7 auto merge of #10859 : huonw/rust/helper-dists, r=cmr
This moves `std::rand::distribitions::{Normal, StandardNormal}` to `...::distributions::normal`, reexporting `Normal` from `distributions` (and similarly for `Exp` and Exp1`), and adds:
- Log-normal
- Chi-squared
- F
- Student T

all of which are implemented in C++11's random library. Tests in 0424b8aded. Note that these are approximately half documentation & half implementation (of which a significant portion is boilerplate `}`'s and so on).
2013-12-09 03:41:27 -08:00
bors
e5f2021202 auto merge of #10874 : vadimcn/rust/integrated-as, r=alexcrichton
Last LLVM update seems to have fixed whatever prevented LLVM integrated assembler from generating correct unwind tables on Windows.   This PR switches Windows builds to use internal assembler by default.
Compilation via external assembler can still be requested via the newly added `-Z no-integrated-as` option.

Closes #8809
2013-12-09 01:01:43 -08:00
bors
09db61fb4f auto merge of #10867 : sfackler/rust/unsugared-doc, r=huonw
Closes #10853
2013-12-08 22:06:25 -08:00
S Pradeep Kumar
04d852aeb1 Add defun motions for rust-mode.
Specifically, we can now use:
+ beginning-of-defun
+ end-of-defun
+ mark-defun

where "defun" means a Rust item.

+ Add tests in rust-mode-tests.el
+ Fix indentation in rust-mode-tests.el
+ Add support for trait to Imenu
2013-12-09 14:36:56 +09:00
Vadim Chugunov
c8498c1933 Disable failing test. 2013-12-08 21:19:55 -08:00
Vadim Chugunov
554c3c316e Use LLVM integrated assembler on Windows too. 2013-12-08 20:14:36 -08:00
Steven Fackler
4d688e8214 Accept unsugared docs in missing-doc lint
Closes #10853
2013-12-08 20:08:49 -08:00
bors
9f3be466e1 auto merge of #10866 : ktt3ja/rust/edit-doc, r=huonw
A comment that I previously added to ast::DefStruct is incorrect. Here's the modification.
2013-12-08 19:26:23 -08:00
Kiet Tran
1f80ec4fec Fix comment on ast::DefStruct 2013-12-08 21:21:15 -05:00
bors
898d2c33b7 auto merge of #10813 : dwrensha/rust/xcrate-lifetime-param, r=huonw
Before applying this patch, the included testcase fails with:
```
src/test/run-pass/xcrate-trait-lifetime-param.rs:20:10: 20:28 error: wrong number of lifetime parameters: expected 0 but found 1
src/test/run-pass/xcrate-trait-lifetime-param.rs:20 impl <'a> other::FromBuf<'a> for Reader<'a> {
                                                              ^~~~~~~~~~~~~~~~~~
```

There's another example in my comments to #10506.
2013-12-08 16:06:22 -08:00
David Renshaw
d99efe84df encode trait lifetime params in metadata to allow cross-crate usage 2013-12-08 18:09:31 -05:00
bors
a6310f6ad3 auto merge of #10477 : ktt3ja/rust/dead-code, r=alexcrichton
PR for issue #1749 mainly to get some feedback and suggestion. This adds a pass that warns if a function, struct, enum, or static item is never used. For the following code,

```rust
pub static pub_static: int = 0;
static priv_static: int = 0;
static used_static: int = 0;

pub fn pub_fn() { used_fn(); }
fn priv_fn() { let unused_struct = PrivStruct; }
fn used_fn() {}

pub struct PubStruct();
struct PrivStruct();
struct UsedStruct1 { x: int }
struct UsedStruct2(int);
struct UsedStruct3();

pub enum pub_enum { foo1, bar1 }
enum priv_enum { foo2, bar2 }
enum used_enum { foo3, bar3 }

fn foo() {
	bar();
	let unused_enum = foo2;
}

fn bar() {
	foo();
}

fn main() {
	let used_struct1 = UsedStruct1 { x: 1 };
	let used_struct2 = UsedStruct2(1);
	let used_struct3 = UsedStruct3;
	let t = used_static;
	let e = foo3;
}
```

it would add the following warnings:

```rust
/home/ktt3ja/test.rs:2:0: 2:28 warning: code is never used: `priv_static`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:2 static priv_static: int = 0;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ktt3ja/test.rs:6:0: 6:48 warning: code is never used: `priv_fn`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:6 fn priv_fn() { let unused_struct = PrivStruct; }
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ktt3ja/test.rs:10:0: 10:20 warning: code is never used: `PrivStruct`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:10 struct PrivStruct();
                        ^~~~~~~~~~~~~~~~~~~~
/home/ktt3ja/test.rs:16:0: 16:29 warning: code is never used: `priv_enum`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:16 enum priv_enum { foo2, bar2 }
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ktt3ja/test.rs:19:0: 22:1 warning: code is never used: `foo`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:19 fn foo() {
/home/ktt3ja/test.rs:20 	bar();
/home/ktt3ja/test.rs:21 	let unused_enum = foo2;
/home/ktt3ja/test.rs:22 }
/home/ktt3ja/test.rs:24:0: 26:1 warning: code is never used: `bar`, #[warn(dead_code)] on by default
/home/ktt3ja/test.rs:24 fn bar() {
/home/ktt3ja/test.rs:25 	foo();
/home/ktt3ja/test.rs:26 }
```

Furthermore, I would like to solicit some test cases since I haven't tested extensively and I'm still unclear about some of the things in here. For example, I'm not sure how reexports would affect this and just assumed that LiveContext (which is a copy of reachable::ReachableContext) does enough work to handle it. Also, the test case above doesn't include any impl or methods, etc.
2013-12-08 11:51:22 -08:00
bors
af6010ca0b auto merge of #10855 : alexcrichton/rust/snapshots, r=pcwalton
This transitions the snapshot dependency process to understand that our
snapshots are now a single static binary rather than an array of files.
2013-12-08 10:31:32 -08:00
Huon Wilson
705b705ba5 std::rand: implement the student t distribution. 2013-12-08 22:12:58 +11:00
Huon Wilson
6155a1c980 std::rand: implement the F distribution. 2013-12-08 22:12:58 +11:00
Huon Wilson
1ee42912e1 std::rand: implement the chi-squared distribution. 2013-12-08 22:12:58 +11:00
Kiet Tran
1755408d1a Remove dead codes 2013-12-08 02:55:28 -05:00
Kiet Tran
c06dd0e0af Add dead-code warning pass 2013-12-08 02:55:27 -05:00
Alex Crichton
70273bb1d6 Register new snapshots
This transitions the snapshot dependency process to understand that our
snapshots are now a single static binary rather than an array of files.
2013-12-07 23:02:39 -08:00
bors
49b751dda1 auto merge of #10850 : alexcrichton/rust/fix-target, r=pcwalton
Right now multiple targets/hosts is broken because the libdir passed for all of
the LLVM libraries is for the wrong architecture. By using the right arch
(target, not host), everything is linked and assembled just fine.
2013-12-07 10:51:12 -08:00
Alex Crichton
f04d6241cb Fix the linked targets for rustc
Right now multiple targets/hosts is broken because the libdir passed for all of
the LLVM libraries is for the wrong architecture. By using the right arch
(target, not host), everything is linked and assembled just fine.
2013-12-07 10:38:32 -08:00
Adrien Tétar
89e1fb3223 rustdoc: fix the search-bar layout
Now with broader compatibility.
2013-12-07 17:15:16 +01:00
bors
67aca9c9af auto merge of #10844 : huonw/rust/deriving-expn-info, r=alexcrichton
Previously something like

    struct NotEq;

    #[deriving(Eq)]
    struct Error {
        foo: NotEq
    }

would just point to the `foo` field, with no mention of the
`deriving(Eq)`. With this patch, the compiler creates a note saying "in
expansion of #[deriving(Eq)]" pointing to the Eq.

(includes some cleanup/preparation; the commit view might be nicer, to filter out the noise of the first one.)
2013-12-07 05:11:10 -08:00
bors
7c719ec1bc auto merge of #10831 : luqmana/rust/9382, r=nikomatsakis
Fixes #9382.

r? @nikomatsakis
2013-12-07 03:41:12 -08:00
Huon Wilson
1d986de248 std::rand: implement the log-normal distribution. 2013-12-07 22:39:08 +11:00
Huon Wilson
9d5639d11b std::rand: move normal and exponential to their own file. 2013-12-07 22:20:43 +11:00
bors
5466462b85 auto merge of #10824 : huonw/rust/str-doc, r=alexcrichton
Fixes #10819.
2013-12-07 01:36:17 -08:00
bors
3abc350ea4 auto merge of #10797 : pradeep90/rust/rust-mode-changes, r=brson
+ Delete trailing whitespace.
2013-12-06 23:46:20 -08:00
bors
70d66ae085 auto merge of #10364 : Kimundi/rust/result_compose, r=alexcrichton
This implements parts of the changes to `Result` and `Option` I proposed and discussed in this thread: https://mail.mozilla.org/pipermail/rust-dev/2013-November/006254.html

This PR includes:
- Adding `ok()` and `err()` option adapters for both `Result` variants.
- Removing `get_ref`, `expect` and iterator constructors for `Result`, as they are reachable with the variant adapters.
- Removing `Result`s `ToStr` bound on the error type because of composability issues. (See https://mail.mozilla.org/pipermail/rust-dev/2013-November/006283.html)
- Some warning cleanups
2013-12-06 22:21:18 -08:00
bors
820271df1c auto merge of #10809 : alexcrichton/rust/static-snapshot, r=alexcrichton
Now that we have the necessary logic in rustc for windows, this is possible to land.
2013-12-06 21:01:32 -08:00
Alex Crichton
e91ffb0710 Link rustllvm statically, and distribute a static snapshot
In order to keep up to date with changes to the libraries that `llvm-config`
spits out, the dependencies to the LLVM are a dynamically generated rust file.
This file is now automatically updated whenever LLVM is updated to get kept
up-to-date.

At the same time, this cleans out some old cruft which isn't necessary in the
makefiles in terms of dependencies.

Closes #10745
Closes #10744
2013-12-06 20:51:17 -08:00
Huon Wilson
c629b1d9de std::str: Add examples to the StrSlice trait.
Fixes #10819.
2013-12-07 13:59:36 +11:00
Huon Wilson
0c0e73eed6 syntax::deriving: indicate from which trait type errors (etc) arise
using the expansion info.

Previously something like

    struct NotEq;

    #[deriving(Eq)]
    struct Error {
        foo: NotEq
    }

would just point to the `foo` field, with no mention of the
`deriving(Eq)`. With this patch, the compiler creates a note saying "in
expansion of #[deriving(Eq)]" pointing to the Eq.
2013-12-07 13:43:22 +11:00
Huon Wilson
3ef933647a syntax: print expansion info from #[attribute] macros in the correct
format.

Previously, any attempt to use this information from inside something
like #[deriving(Foo)] would result in it printing like `deriving(Foo)!`.
2013-12-07 13:41:11 +11:00
Huon Wilson
09a879460c syntax::deriving: add the cx and span to the TraitDef to reduce duplication. 2013-12-07 11:57:44 +11:00
Marvin Löbel
142eb685f9 Made Results API more composable 2013-12-06 22:29:02 +01:00
Luqman Aden
920ca61871 librustc: Pass the correct type when adding cleanups. 2013-12-06 15:47:14 -05:00
bors
aa4455e4c7 auto merge of #10832 : chris-morgan/rust/let's-lop-lang-item-line-count, r=alexcrichton
This should make maintenance of lang items simpler and also reduces the
line count by about 201 lines.
2013-12-06 01:11:18 -08:00
bors
2eb22ae2b4 auto merge of #10665 : cmr/rust/doc_lint, r=alexcrichton
Because the root module isn't actually an item, we need to do some hackish
handling of it.

Closes #10656.
2013-12-05 23:41:19 -08:00
Corey Richardson
30a5612830 Check crate root for docs in missing_doc lint.
Because the root module isn't actually an item, we need to do some hackish
handling of it.

Closes #10656.
2013-12-06 01:39:32 -05:00