Commit Graph

4156 Commits

Author SHA1 Message Date
Alex Crichton
ec996737fe 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
2014-04-10 15:22:00 -07:00
Felix S. Klock II
da25539c1a Generalized the pretty-print entry points to support -o <file>. 2014-04-10 15:21:59 -07:00
Huon Wilson
6e63b12f5f Remove some internal ~[] from several libraries.
Some straggling instances of `~[]` across a few different libs. Also,
remove some public ones from workcache.
2014-04-10 15:21:58 -07:00
Eduard Bopp
342e8b59be Fix outdated lint warning about inner attribute
It suggested adding a semicolon instead of the new syntax using an exclamation
mark.
2014-04-10 15:21:58 -07:00
Kevin Ballard
8135032779 Remove references to @Trait from a compiler error message 2014-04-10 15:21:57 -07:00
Michael Woerister
5099b8c863 debuginfo: Don't create debuginfo for statics inlined from other crates.
Fixes issue #13213, that is linker errors when the inlined static has been optimized out of the exporting crate.
2014-04-10 15:21:57 -07:00
Michael Woerister
c26d25466d debuginfo: Implement discriminator type metadata re-use.
An optimization for sharing the type metadata of generic enum discriminators between monomorphized instances (fixes issue #12840)
2014-04-10 15:21:57 -07:00
Michael Woerister
43e8ace76b debuginfo: Improve source code position assignment for inlined functions.
This commit makes sure that code inlined from other functions isn't assigned the source position of the call site, since this leads to undesired behavior when setting line breakpoints (issue #12886)
2014-04-10 15:21:57 -07:00
Eduard Burtescu
a62eba7abf rustc: move mutability from ty_vec and ty_trait to VstoreSlice and RegionTraitStore. 2014-04-10 20:18:46 +03:00
Eduard Burtescu
2803b383f0 rustc: use VstoreFixed's length in crate-independent type hashes. 2014-04-10 20:18:46 +03:00
Eduard Burtescu
b61764b609 rustc: rename ty::vstore and its variants to UpperCamelCase. 2014-04-10 20:18:46 +03:00
bors
6d1c6124f6 auto merge of #13436 : pongad/rust/lazyemit, r=thestinger
Fixes #11926
2014-04-10 05:56:55 -07:00
Patrick Walton
d8e45ea7c0 libstd: Implement StrBuf, a new string buffer type like Vec, and
port all code over to use it.
2014-04-10 22:10:10 +10:00
Kiet Tran
13d6c35c56 Collect move errors before reporting
This commit changes the way move errors are reported when some value is
captured by a PatIdent. First, we collect all of the "cannot move out
of" errors before reporting them, and those errors with the same "move
source" are reported together. If the move is caused by a PatIdent (that
binds by value), we add a note indicating where it is and suggest the
user to put `ref` if they don't want the value to move. This makes the
"cannot move out of" error in match expression nicer (though the extra
note may not feel that helpful in other places :P). For example, with
the following code snippet,

```rust
enum Foo {
    Foo1(~u32, ~u32),
    Foo2(~u32),
    Foo3,
}

fn main() {
    let f = &Foo1(~1u32, ~2u32);
    match *f {
        Foo1(num1, num2) => (),
        Foo2(num) => (),
        Foo3 => ()
    }
}
```

Errors before the change:

```rust
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:10:9: 10:25 error: cannot move out of dereference of `&`-pointer
test.rs:10         Foo1(num1, num2) => (),
                   ^~~~~~~~~~~~~~~~
test.rs:11:9: 11:18 error: cannot move out of dereference of `&`-pointer
test.rs:11         Foo2(num) => (),
                   ^~~~~~~~~
```

After:

```rust
test.rs:9:11: 9:13 error: cannot move out of dereference of `&`-pointer
test.rs:9     match *f {
                    ^~
test.rs:10:14: 10:18 note: attempting to move value to here (to prevent the move, you can use `ref num1` to capture value by reference)
test.rs:10         Foo1(num1, num2) => (),
                        ^~~~
test.rs:10:20: 10:24 note: and here (use `ref num2`)
test.rs:10         Foo1(num1, num2) => (),
                              ^~~~
test.rs:11:14: 11:17 note: and here (use `ref num`)
test.rs:11         Foo2(num) => (),
                        ^~~
```

Close #8064
2014-04-09 20:03:23 -04:00
Michael Darakananda
a00be50e00 Emit intrinsic lazily 2014-04-09 19:56:31 -04:00
Alex Crichton
767ed1a71f rustc: Prevent repeated moves out of proc upvars
This fixes the categorization of the upvars of procs (represented internally
as once fns) to consider usage to require a loan. In doing so, upvars are no
longer allowed to be moved out of repeatedly in loops and such.

Closes #10398
Closes #12041
Closes #12127
2014-04-08 17:10:47 -07:00
Alex Crichton
0cc257eb42 rustc: Run destructors when dest=Ignore
Previously, if statements of the form "Foo;" or "let _ = Foo;" were encountered
where Foo had a destructor, the destructors were not run. This changes
the relevant locations in trans to check for ty::type_needs_drop and invokes
trans_to_lvalue instead of trans_into.

Closes #4734
Closes #6892
2014-04-08 08:28:54 -07:00
Daniel Micay
de2567dec9 fix ~ZeroSizeType rvalues
Closes #13360
2014-04-08 00:03:11 -07:00
Alex Crichton
cced02fcac rustc: Don't read both rlib and dylib metadata
This is an optimization which is quite impactful for compiling small crates.
Reading libstd's metadata takes about 50ms, and a hello world before this change
took about 100ms (this change halves that time).

Recent changes made it such that this optimization wasn't performed, but I think
it's a better idea do to this for now. See #10786 for tracking this issue.
2014-04-08 00:03:11 -07:00
Alex Crichton
5367c32c7d rustc: Never register syntax crates in CStore
When linking, all crates in the local CStore are used to link the final product.
With #[phase(syntax)], crates want to be omitted from this linkage phase, and
this was achieved by dumping the entire CStore after loading crates. This causes
crates like the standard library to get loaded twice. This loading process is a
fairly expensive operation when dealing with decompressing metadata.

This commit alters the loading process to never register syntax crates in
CStore. Instead, only phase(link) crates ever make their way into the map of
crates. The CrateLoader trait was altered to return everything in one method
instead of having separate methods for finding information.
2014-04-08 00:03:11 -07:00
Alex Crichton
31755e2452 rustc: Use CStore, not a separate crate cache
This separate crate cache is one factor which is causing libstd to be loaded
twice during normal compilation. The crates loaded for syntax extensions have a
separate cache than the crates loaded for linking, so all crates are loaded once
per #[phase] they're tagged with.

This removes the cache and instead uses the CStore structure itself as the cache
for loaded crates. This should allow crates loaded during the syntax phase to be
shared with the crates loaded during the link phase.
2014-04-08 00:03:11 -07:00
Alex Crichton
c3ea3e439f Register new snapshots 2014-04-08 00:03:11 -07:00
Tobba
bc234ae130 Made libflate functions return Options instead of outright failing 2014-04-08 00:03:11 -07:00
bors
e4779b5050 auto merge of #13165 : sfackler/rust/io-vec, r=alexcrichton
`Reader`, `Writer`, `MemReader`, `MemWriter`, and `MultiWriter` now work with `Vec<u8>` instead of `~[u8]`. This does introduce some extra copies since `from_utf8_owned` isn't usable anymore, but I think that can't be helped until `~str`'s representation changes.
2014-04-06 23:36:38 -07:00
Steven Fackler
49a8081095 De-~[] Mem{Reader,Writer} 2014-04-06 15:40:01 -07:00
Steven Fackler
d0e60b72ee De-~[] Reader and Writer
There's a little more allocation here and there now since
from_utf8_owned can't be used with Vec.
2014-04-06 15:39:56 -07:00
bors
31e8f2448c auto merge of #13346 : ben0x539/rust/priv-field-in, r=alexcrichton
In the error message for when a private field is used, include the name of the struct, or if it's a struct-like enum variant, the names of the variant and the enum.

This fixes #13341.
2014-04-06 10:36:33 -07:00
bors
02c81fe2b5 auto merge of #13340 : FlaPer87/rust/code-model, r=cmr
Rust currently defaults to `RelocPIC` regardless. This patch adds a new
codegen option that allows choosing different relocation-model. The
available models are:

    - default (Use the target-specific default model)
    - static
    - pic
    - no-pic

For a more detailed information use `llc --help`
2014-04-06 07:06:36 -07:00
Flavio Percoco
b78ac5b74a Add support for different relocation models
Rust currently defaults to `RelocPIC` regardless. This patch adds a new
codegen option that allows choosing different relocation-model. The
available models are:

    - default (Use the target-specific default model)
    - static
    - pic
    - no-pic

For a more detailed information use `llc --help`
2014-04-06 15:06:44 +02:00
bors
4af69f204e auto merge of #13344 : eddyb/rust/kill-unboxed-vec, r=cmr
Removes the special `ty_unboxed_vec` type from the type system.
It was previously used only during translating `~[T]`/`~str` allocation and drop glue.
2014-04-06 05:46:38 -07:00
Eduard Burtescu
2d22243b0c rustc: remove ty_unboxed_vec. 2014-04-06 14:05:32 +03:00
bors
f1f50565a1 auto merge of #13315 : alexcrichton/rust/libc, r=alexcrichton,me
Rebasing of #12526 with a very obscure bug fixed on windows.
2014-04-06 02:56:39 -07:00
Alex Crichton
38f7a1b41b rustc: Pass --enable-long-section-names to gcc
This was quite a curious bug on windows, and the details can be found in the
comment I added to src/librustc/back/link.rs
2014-04-05 17:53:44 -07:00
Benjamin Herr
d4b73a7411 name struct in "field ... is private" error 2014-04-06 02:37:25 +02:00
bors
b2b2bbb628 auto merge of #13112 : ktt3ja/rust/issue-13058, r=pnkfelix
Previously, Rebuilder did not visit type parameters when rebuilding
generics and path, so in some cases the suggestion turns out to be
erroneous.
2014-04-05 13:31:33 -07:00
bors
94a055c729 auto merge of #13333 : Ryman/rust/improve_incompatible_type_error, r=alexcrichton
This can be a frustrating error message, ideally we should print the signature mismatch, but hinting that it's a trait incompatibility helps tracking root cause. Also beefed up the testcases for this.

Ideally we would print the signature mismatch in the error helper?
2014-04-05 08:41:32 -07:00
bors
e7148592ad auto merge of #13330 : huonw/rust/loop-error, r=alexcrichton
rustc: move the check_loop pass earlier.

This pass is purely AST based, and by running it earlier we emit more
useful error messages, e.g. type inference fails in the case of 
`let r = break;` with few constraints on `r`, but it's more useful to be told that
the `break` is outside the loop (rather than a type error) when it is.

Closes #13292.
2014-04-05 04:41:33 -07:00
bors
339d400261 auto merge of #13284 : pnkfelix/rust/more-fs-info-on-crate-mismatch, r=alexcrichton
Fix #13266.

There is a little bit of acrobatics in the definition of `crate_paths`
to avoid calling `clone()` on the dylib/rlib unless we actually are
going to need them.

The other oddity is that I have replaced the `root_ident: Option<&str>`
parameter with a `root: &Option<CratePaths>`, which may surprise one
who was expecting to see something like: `root: Option<&CratePaths>`.
I went with the approach here because I could not come up with code for
the alternative that was acceptable to the borrow checker.
2014-04-04 21:06:34 -07:00
Felix S. Klock II
4afd060a59 Accumulate list of paths for crate hash mismatch.
(i.e. semi-generalized version of prior errorinfo gathering.)

Also revised presentation to put each path on its own line, prefixed
by file:linenum information.
2014-04-05 03:49:03 +02:00
Felix S. Klock II
1599d22603 Added session.fileline_note() method and support infrastucture for it.
Add way to print notes with just file:linenum prefix (preserving
integration with source lookup for e.g. vi and emacs) but don't repeat
the other span info.
2014-04-05 03:46:43 +02:00
Kevin Butler
28938d08a0 librustc: Improve error message for incompatible trait method signatures. 2014-04-05 02:22:00 +01:00
Huon Wilson
3766453a42 rustc: move the check_loop pass earlier.
This pass is purely AST based, and by running it earlier we emit more
useful error messages, e.g. type inference fails in the case of `let r =
break;` with few constraints on `r`, but its more useful to be told that
the `break` is outside a loop (rather than a type error) when it is.

Closes #13292.
2014-04-05 10:52:28 +11:00
Alex Crichton
d250ec0bdd Register new snapshots 2014-04-04 13:23:08 -07:00
Eduard Burtescu
7c48e53c1e syntax: remove obsolete mutability from ExprVec and ExprRepeat. 2014-04-04 13:23:03 -07:00
Corey Richardson
0459ee77d0 Fix fallout from std::libc separation 2014-04-04 09:31:44 -07:00
Corey Richardson
308c03501a Remove libc from std
These wrappers are bound to a specific libc, and they don't need to be part of
libstd.
2014-04-04 09:31:21 -07:00
bors
eae2652710 auto merge of #13301 : erickt/rust/remove-refcell-get, r=huonw
`RefCell::get` can be a bit surprising, because it actually clones the wrapped value. This removes `RefCell::get` and replaces all the users with `RefCell::borrow()` when it can, and `RefCell::borrow().clone()` when it can't. It removes `RefCell::set` for consistency. This closes #13182.

It also fixes an infinite loop in a test when debugging is on.
2014-04-04 08:41:50 -07:00
bors
286b62e0da auto merge of #13295 : huonw/rust/gate-concat-idents, r=alexcrichton
rustc: feature-gate `concat_idents!`.

concat_idents! is not as useful as it could be, due to macros only being
allowed in limited places, and hygiene, so lets feature gate it until we
make a decision about it.

cc #13294
2014-04-04 06:07:02 -07:00
bors
37a9885429 auto merge of #13291 : thestinger/rust/no_null, r=alexcrichton
This was missed when dropping the null-termination from our string
types. An explicit null byte can still be placed anywhere in a string if
desired, but there's no reason to stick one at the end of every string
constant.
2014-04-04 04:41:49 -07:00
Huon Wilson
6c5e1d0925 rustc: feature-gate concat_idents!.
concat_idents! is not as useful as it could be, due to macros only being
allowed in limited places, and hygiene, so lets feature gate it until we
make a decision about it.

cc #13294
2014-04-04 20:25:50 +11:00
Erick Tryzelaar
3961957bd6 std: Remove RefCell::set() 2014-04-03 20:28:59 -07:00
Erick Tryzelaar
7bcfe2ee10 std: Remove RefCell::get()
It's surprising that `RefCell::get()` is implicitly doing a clone
on a value. This patch removes it and replaces all users with
either `.borrow()` when we can autoderef, or `.borrow().clone()`
when we cannot.
2014-04-03 20:28:55 -07:00
bors
2a2d0dce87 auto merge of #13296 : brson/rust/0.11-pre, r=alexcrichton
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 19:56:45 -07:00
bors
c2e457686b auto merge of #13237 : alexcrichton/rust/private-tuple-structs, r=brson
This is the final commit need to implement [RFC #4](https://github.com/rust-lang/rfcs/blob/master/active/0004-private-fields.md), it makes all tuple struct fields private by default, overridable with the `pub` keyword.

I'll note one divergence from the original RFC which is outlined in the first commit.
2014-04-03 18:41:45 -07:00
Daniel Micay
7ce2630cef stop asking LLVM to null-terminate strings
This was missed when dropping the null-termination from our string
types. An explicit null byte can still be placed anywhere in a string if
desired, but there's no reason to stick one at the end of every string
constant.
2014-04-03 21:35:21 -04:00
bors
e7fe207229 auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichton
Closes #13285 (rustc: Stop using LLVMGetSectionName)
Closes #13280 (std: override clone_from for Vec.)
Closes #13277 (serialize: add a few missing pubs to base64)
Closes #13275 (Add and remove some ignore-win32 flags)
Closes #13273 (Removed managed boxes from libarena.)
Closes #13270 (Minor copy-editing for the tutorial)
Closes #13267 (fix Option<~ZeroSizeType>)
Closes #13265 (Update emacs mode to support new `#![inner(attribute)]` syntax.)
Closes #13263 (syntax: Remove AbiSet, use one Abi)
2014-04-03 17:17:02 -07:00
Brian Anderson
0875ffcbff Bump version to 0.11-pre
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 16:28:46 -07:00
bors
bb31cb8d2e auto merge of #13286 : alexcrichton/rust/release, r=brson
Merging the 0.10 release into the master branch.
2014-04-03 13:52:03 -07:00
Alex Crichton
57e0908af3 syntax: Remove AbiSet, use one Abi
This change removes the AbiSet from the AST, converting all usage to have just
one Abi value. The current scheme selects a relevant ABI given a list of ABIs
based on the target architecture and how relevant each ABI is to that
architecture.

Instead of this mildly complicated scheme, only one ABI will be allowed in abi
strings, and pseudo-abis will be created for special cases as necessary. For
example the "system" abi exists for stdcall on win32 and C on win64.

Closes #10049
2014-04-03 13:43:45 -07:00
Daniel Micay
898669c4e2 fix Option<~ZeroSizeType>
1778b63616 provided the guarantee of no
`exchange_free` calls for ~ZeroSizeType, so a sentinel can now be used
without overhead.

Closes #11998
2014-04-03 13:43:35 -07:00
Alex Crichton
15e6e8cf3e rustc: Stop using LLVMGetSectionName
The recent pull request to remove libc from libstd has hit a wall in compiling
on windows, and I've been trying to investigate on the try bots as to why (it
compiles locally just fine). To the best of my knowledge, the LLVM section
iterator is behaving badly when iterating over the sections of the libc DLL.

Upon investigating the LLVMGetSectionName function in LLVM, I discovered that
this function doesn't always return a null-terminated string. It returns the
data pointer of a StringRef instance (LLVM's equivalent of &str essentially),
but it has no method of returning the length of the name of the section.

This commit modifies the section iteration when loading libraries to invoke a
custom LLVMRustGetSectionName which will correctly return both the length and
the data pointer.

I have not yet verified that this will fix landing liblibc, as it will require a
snapshot before doing a full test. Regardless, this is a worrisome situation
regarding the LLVM API, and should likely be fixed anyway.
2014-04-03 10:49:35 -07:00
Felix S. Klock II
3ccbffac40 After a hash mismatch error, emit file-system paths of crates involved.
Fix #13266.

There is a little bit of acrobatics in the definition of `crate_paths`
to avoid calling `clone()` on the dylib/rlib unless we actually are
going to need them.

The other oddity is that I have replaced the `root_ident: Option<&str>`
parameter with a `root: &Option<CratePaths>`, which may surprise one
who was expecting to see something like: `root: Option<&CratePaths>`.
I went with the approach here because I could not come up with code for
the alternative that was acceptable to the borrow checker.
2014-04-03 17:46:22 +02:00
bors
6f1c06d6a1 auto merge of #13244 : cmr/rust/tbaa, r=alexcrichton 2014-04-03 03:42:02 -07:00
Alex Crichton
9a259f4303 Fix fallout of requiring uint indices 2014-04-02 15:56:31 -07:00
Alex Crichton
46abacfdfe rustc: Require that vector indices are uints
This commit tightens up the restriction on types used to index slices to require
exactly `uint` indices. Previously any integral type was accepted, but this
leads to a few subtle problems:

  * 64-bit indices don't make much sense on 32-bit systems
  * Signed indices for slices used as negative indexing isn't implemented

This was discussed at the recent work week, and also has some discussion on
issue #10453.

Closes #10453
2014-04-02 15:56:31 -07:00
Corey Richardson
46790a7d27 util: ppaux: remove dead code 2014-04-02 11:17:24 -04:00
Corey Richardson
841eb1c56f util: common: remove dead code 2014-04-02 11:17:24 -04:00
Corey Richardson
fdcb104517 middle: typeck: rscope: remove dead code 2014-04-02 11:17:24 -04:00
Corey Richardson
3bd0a37c0b middle: typeck: remove dead code 2014-04-02 11:17:24 -04:00
Corey Richardson
009389f051 middle: typeck: infer: resolve: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
167c29ff3f middle: typeck: infer: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
ce47c91bfc middle: typeck: infer: lub: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
1a98ec83c1 middle: typeck: infer: combine: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
dcb01ff573 middle: typeck: check: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
39f839d9ee middle: ty: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
b4653941d6 middle: trans: type_: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
53b70a83c6 middle: trans: tvec: remove dead code 2014-04-02 11:17:23 -04:00
Corey Richardson
4bc2c3b2b4 middle: trans: reflect: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
32753ed811 middle: trans: meth: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
f9973103c5 middle: trans: datum: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
9dd185c255 middle: trans: context: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
e53f48be34 middle: trans: common: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
8f385fc2e0 middle: trans: callee: remove dead code 2014-04-02 11:17:22 -04:00
Corey Richardson
a2290ccbc5 middle: trans: cabi: remove dead code 2014-04-02 11:17:21 -04:00
Corey Richardson
5e2b5221ca middle: trans: builder: ignore dead code 2014-04-02 11:17:21 -04:00
Corey Richardson
8de5eec222 middle: trans: build: remove dead code 2014-04-02 11:17:21 -04:00
Corey Richardson
49dc0193bd middle: trans: base: remove dead code 2014-04-02 11:17:21 -04:00
Corey Richardson
a9bf099000 middle: trans: adt: remove dead code 2014-04-02 11:17:21 -04:00
Corey Richardson
ee82233a1e middle: region: remove dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
39fce48324 middle: pat_util: remove dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
dc59df776a middle: mem_categorization: remove dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
393bc08762 middle: lang_items: allow dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
35c98a8378 middle: kind: remove dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
fb19d680f4 middle: graph: ignore dead code 2014-04-02 11:17:20 -04:00
Corey Richardson
6ed787155d middle: freevars: remove dead code 2014-04-02 11:17:19 -04:00
Corey Richardson
4e5409ba91 middle: dataflow: remove dead code 2014-04-02 11:17:19 -04:00
Corey Richardson
d03e647a0a middle: const_eval: remove dead code 2014-04-02 11:17:19 -04:00
Corey Richardson
2013488bee middle: cfg: allow dead code 2014-04-02 11:17:19 -04:00
Corey Richardson
77d1978f8e middle: borrowck: remove dead code 2014-04-02 11:17:19 -04:00
Corey Richardson
0ce17d941d middle: astencode: remove dead code 2014-04-02 11:17:18 -04:00