Commit Graph

4114 Commits

Author SHA1 Message Date
bors
65abf96fb6 auto merge of #13424 : eddyb/rust/ty-mut-in-store, r=nikomatsakis
Cleans up some remnants of the old mutability system and only allows vector/trait mutability in `VstoreSlice` (`&mut [T]`) and `RegionTraitStore` (`&mut Trait`).
2014-04-11 05:01:38 -07:00
Eduard Burtescu
ee4c770f8b rustc: fix the fallout from moving mutability into VstoreSlice and RegionTraitStore. 2014-04-11 09:01:31 +03:00
bors
cea8def620 auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it.

Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
2014-04-10 21:01:41 -07:00
Alex Crichton
1f2c18a0af rustc: Don't allow priv use to shadow pub use
Previously, a private use statement would shadow a public use statement, all of
a sudden publicly exporting the privately used item. The correct behavior here
is to only shadow the use for the module in question, but for now it just
reverts the entire name to private so the pub use doesn't have much effect.

The behavior isn't exactly what we want, but this no longer has backwards
compatibility hazards.
2014-04-10 15:22:01 -07:00
Alex Crichton
df533c6e87 rustc: Don't succeed on shadowed nonexistent import
Previously resolve was checking the "import resolution" for whether an import
had succeeded or not, but this was the same structure filled in by a previous
import if a name is shadowed. Instead, this alters resolve to consult the local
resolve state (as opposed to the shared one) to test whether an import succeeded
or not.

Closes #13404
2014-04-10 15:22:00 -07:00
Alex Crichton
83d2c0b8a6 rustc: Disallow importing through use statements
Resolve is currently erroneously allowing imports through private `use`
statements in some circumstances, even across module boundaries. For example,
this code compiles successfully today:

    use std::c_str;
    mod test {
        use c_str::CString;
    }

This should not be allowed because it was explicitly decided that private `use`
statements are purely bringing local names into scope, they are not
participating further in name resolution.

As a consequence of this patch, this code, while valid today, is now invalid:

    mod test {
        use std::c_str;

        unsafe fn foo() {
            ::test::c_str::CString::new(0 as *u8, false);
        }
    }

While plausibly acceptable, I found it to be more consistent if private imports
were only considered candidates to resolve the first component in a path, and no
others.

Closes #12612
2014-04-10 15:22:00 -07:00
Kasey Carrothers
0bf4e900d4 Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names. 2014-04-10 15:22:00 -07:00
Alex Crichton
3f2c55f7d5 rustc: Use realpath() for sysroot/rpath
When calculating the sysroot, it's more accurate to use realpath() rather than
just one readlink() to account for any intermediate symlinks that the rustc
binary resolves itself to.

For rpath, realpath() is necessary because the rpath must dictate a relative
rpath from the destination back to the originally linked library, which works
more robustly if there are no symlinks involved.

Concretely, any binary generated on OSX into $TMPDIR requires an absolute rpath
because the temporary directory is behind a symlink with one layer of
indirection. This symlink causes all relative rpaths to fail to resolve.

cc #11734
cc #11857
2014-04-10 15:22:00 -07:00
Alex Crichton
25a6b6ef8b rustc: Add a realpath utility function
This is required in rustc to resolve symlinks for utilities such as the sysroot
and the rpath values which are encoded into binaries.
2014-04-10 15:22:00 -07:00
Alex Crichton
f9e17e1d33 rustc: Don't rpath to librustrt.dylib
This library no longer exists, there's no reason for this rpath to exist any
more.
2014-04-10 15:22:00 -07:00
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
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
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