Commit Graph

4114 Commits

Author SHA1 Message Date
Alex Crichton
da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Alex Crichton
7a5a8c3c07 rustc: Default the ~[] lint to allow for now
Most of the standard distribution is still using ~[] instead of Vec, so this
lint is essentially useless currently. When the standard distribution has been
ported to not use ~[], then we can turn the lint back on.
2014-03-20 09:13:44 -07:00
bors
c01e2f05a3 auto merge of #13017 : alexcrichton/rust/issue-13010, r=huonw
Previously, any library of the pattern `lib<name>-<hash>-<version>.so` was
>considered a candidate (rightly so) for loading a crate. Sets are generated for
each unique `<hash>`, and then from these sets a candidate is selected. If a set
contained more than one element, then it immediately generated an error saying
that multiple copies of the same dylib were found.

This is incorrect because each candidate needs to be validated to actually
contain a rust library (valid metadata). This commit alters the logic to filter
each set of candidates for a hash to only libraries which are actually rust
libraries. This means that if multiple false positives are found with the right
name pattern, they're all ignored.

Closes #13010
2014-03-20 08:21:46 -07:00
bors
8e285208d5 auto merge of #12686 : FlaPer87/rust/shared, r=nikomatsakis
`Share` implies that all *reachable* content is *threadsafe*.

Threadsafe is defined as "exposing no operation that permits a data race if multiple threads have access to a &T pointer simultaneously". (NB: the type system should guarantee that if you have access to memory via a &T pointer, the only other way to gain access to that memory is through another &T pointer)...

Fixes #11781
cc #12577 

What this PR will do
================

- [x] Add Share kind and
- [x]  Replace usages of Freeze with Share in bounds.
- [x] Add Unsafe<T> #12577
- [x] Forbid taking the address of a immutable static item with `Unsafe<T>` interior

What's left to do in a separate PR (after the snapshot)?
===========================================

- Remove `Freeze` completely
2014-03-20 05:51:48 -07:00
Flavio Percoco
68a3ec08b3 Allow static items that don't fulfill Freeze 2014-03-20 10:17:28 +01:00
Flavio Percoco
ff1c49fa54 Forbid borrow of static items with unsafe interior 2014-03-20 10:17:28 +01:00
Flavio Percoco
69ccd807da Gather loans for static items
We currently gather loans for static items that are defined within
functions. This change enables loan gathering on static items declared
globally.
2014-03-20 10:17:28 +01:00
Flavio Percoco
710f13f0ad Add Unsafe<T> type 2014-03-20 10:16:55 +01:00
Flavio Percoco
37154fb8b9 Add a Share kind
Fixes #11781
2014-03-20 10:16:55 +01:00
Daniel Micay
14f656d1a7 rename std::vec_ng -> std::vec
Closes #12771
2014-03-20 04:25:32 -04:00
bors
7aded2adb6 auto merge of #12772 : thestinger/rust/slice, r=alexcrichton
Closes #12702
2014-03-19 23:21:49 -07:00
Daniel Micay
ce620320a2 rename std::vec -> std::slice
Closes #12702
2014-03-20 01:30:27 -04:00
bors
d8590e2c9c auto merge of #13013 : huonw/rust/tytrait, r=cmr
These variants occur rarely but inflate the whole enum for the other variants, leaving a lot of wasted space. In total this reduces `ty::sty` from 160 bytes to 96 (on a 64-bit platform).

After this, `ty_struct` and `ty_enum` are the largest variants, with the 80-byte `substs` being the major contributor.
2014-03-19 20:21:48 -07:00
bors
4ca51aeea7 auto merge of #12770 : eddyb/rust/drop-tld, r=cmr
Sadly, this seems to make memory usage worse (unless `Vec<T>` makes it worse and this PR doesn't change that much, which is entirely possible).
2014-03-19 13:01:49 -07:00
Alex Crichton
068740b343 rustc: Prevent false positives in crate loading
Previously, any library of the pattern `lib<name>-<hash>-<version>.so` was
>considered a candidate (rightly so) for loading a crate. Sets are generated for
each unique `<hash>`, and then from these sets a candidate is selected. If a set
contained more than one element, then it immediately generated an error saying
that multiple copies of the same dylib were found.

This is incorrect because each candidate needs to be validated to actually
contain a rust library (valid metadata). This commit alters the logic to filter
each set of candidates for a hash to only libraries which are actually rust
libraries. This means that if multiple false positives are found with the right
name pattern, they're all ignored.

Closes #13010
2014-03-19 10:47:00 -07:00
bors
61d5bc5d2d auto merge of #12762 : klutzy/rust/win-struct-abi, r=alexcrichton
This fixes struct passing abi on x86 ffi: Structs are now passed
indirectly with byval attribute (as clang does).
Empty structs are also explicitly ignored rather than directly passed.

Fixes #5744
Fixes #11198
Fixes #11343
2014-03-19 08:51:50 -07:00
Huon Wilson
ddc796096b rustc: put ty_closure behind some indirection.
This reduces the size of sty from 112 to 96; like with the ty_trait
variant, this variant of sty occurs rarely (~1%) so the benefits are
large and the costs small.
2014-03-19 22:20:56 +11:00
Huon Wilson
405b5fc1ee rustc: put ty_trait behind some indirection.
This reduces ty::sty from 160 bytes to just 112, and some measurements
eddyb made suggest that the ty_trait variant occurs very
rarely (e.g. ~1% of all sty instances) hence this will result in a large
memory saving, and the cost of the indirection is unlikely to be an
issue.
2014-03-19 22:19:05 +11:00
klutzy
2d31bcaf16 rustc: Fix x86 ffi for empty struct arguments 2014-03-19 16:41:51 +09:00
klutzy
7437995b3e rustc: Fix x86 ffi for struct arguments
This fixes struct passing abi on x86 ffi: Structs are now passed
indirectly with byval attribute (as clang does).
2014-03-19 16:41:50 +09:00
Eduard Burtescu
c04d4846f2 Discard MTWT & interner tables from TLD after they stop being useful. 2014-03-19 07:28:18 +02:00
Steven Fackler
0f2d46f396 Docify std::vec_ng
I also removed a couple of methods that were silly and added sort.
2014-03-18 22:03:17 -07:00
Ben Noordhuis
8f7a7970f3 rustc: remove obsolete linkage types
Remove obsolete linkage types from the llvm::Linkage enum.  The linkage
types are no-ops and weren't used inside rustc anyway.
2014-03-18 13:49:09 -07:00
Ben Noordhuis
c800c98574 rustc: remove linker_private/linker_private_weak
Remove the linker_private and linker_private_weak linkage attributes,
they have been superseded by private and private_weak and have been
removed in upstream LLVM in commit r203866.
2014-03-18 13:49:09 -07:00
Alex Crichton
87c7c03f45 syntax: Don't parameterize the the pretty printer
The pretty printer constitues an enormous amount of code, there's no reason for
it to be generic. This just least to a huge amount of metadata which isn't
necessary. Instead, this change migrates the pretty printer to using a trait
object instead.

Closes #12985
2014-03-18 13:48:03 -07:00
Huon Wilson
92f0bc2935 rustc: buffer the output writer for -Z ast-json[-noexpand].
This takes the time for `rustc libstd/lib.rs -Z ast-json-noexpand >
file.json` from 9.0s to 3.5s (~0.5s spent parsing etc.) and `-Z
ast-json` from 11s to 5s (~1.5s spent parsing and expanding).
2014-03-18 13:47:55 -07:00
Corey Richardson
873f7408bd rustc: test: don't silently ignore bad benches
This is adequate because when a function has a type that isn't caught here,
that is, it has a single argument, but it *isn't* `&mut BenchHarness`, it
errors later on with:

     error: mismatched types: expected `fn(&mut test::BenchHarness)` but found
     `fn(int)` (expected &-ptr but found int)

which I consider acceptable.

Closes #12997
2014-03-18 13:47:50 -07:00
Corey Richardson
1607871dc2 rustc: disallow duplicate methods in trait impls
Closes #8153
2014-03-18 13:47:42 -07:00
bors
0a181a8917 auto merge of #12742 : FlaPer87/rust/issue-11411-static-mut-slice, r=nikomatsakis
This PR enables the use of mutable slices in *mutable* static items. The work was started by @xales and I added a follow-up commit that moves the *immutable* restriction to the recently added `check_static`

Closes #11411
2014-03-17 09:57:06 -07:00
Eduard Burtescu
e2ebc8f811 Fix rustdoc and tests. 2014-03-17 09:55:41 +02:00
Eduard Burtescu
e02aa722aa Refactor pprust a bit. 2014-03-17 09:53:08 +02:00
Eduard Burtescu
871e570810 De-@ codemap and diagnostic. 2014-03-17 09:53:08 +02:00
Eduard Burtescu
0bb6de3076 De-@ move maps and rework parts of trans. 2014-03-17 09:53:08 +02:00
Eduard Burtescu
3f64d4126b De-@ gather_loans. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
a1e24c7f22 De-@ typeck::check::method. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
da842c6278 De-@ resolve_lifetime. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
90cbe0cad2 De-@ ParseSess uses. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
555a239301 De-@ CStore uses. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
f77c744142 De-@ filesearch. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
eeb37b76af De-@ reachable. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
6c42ef31dc De-@ trans contexts. 2014-03-17 09:53:07 +02:00
Eduard Burtescu
869c96dbf0 De-@ type checking contexts. 2014-03-17 09:53:06 +02:00
Eduard Burtescu
6879916a06 De-@ liveness. 2014-03-17 09:53:06 +02:00
Eduard Burtescu
0ba5f1b8f4 De-@ tyencode::ctxt and related parts of astencode. 2014-03-17 09:53:06 +02:00
Eduard Burtescu
9b1fee898f De-@ ty::ctxt usage. 2014-03-17 09:53:06 +02:00
Eduard Burtescu
4fae06824c De-@ Session usage. 2014-03-17 09:53:06 +02:00
bors
4e1172ebbd auto merge of #12937 : sinistersnare/rust/method-error-message, r=huonw
its a common (yet easily fixable) error to just forget parens at the end of getter-like methods without any arguments.

The current error message for that case asks for an anonymous function, this patch adds a note asking for either an anonymous function, or for trailing parens.

This is my first contribution! do i need to do anything else?
2014-03-16 17:01:54 -07:00
Davis Silverman
8b6592ef1a Asked if missing (), then asks about an anonymous function. Also added test. 2014-03-16 16:46:02 -04:00
bors
d73c899383 auto merge of #12929 : sfackler/rust/automatically-derived, r=cmr
This will enable rustdoc to treat them specially.

I also got rid of `std::cmp::cmp2`, which is isomorphic to the `TotalOrd` impl for 2-tuples and never used.
2014-03-16 03:21:21 -07:00
bors
f6fcdbb687 auto merge of #12791 : alexcrichton/rust/liblog, r=brson
The rationale and modifications can be found in the first commit message.

This does make logging a bit more painful to use initially because it involves a feature gate and some `phase` attributes, but I think it may be reasonable to not require the `phase` attribute for loading `macro_rules!` macros because defining them will still be gated.
2014-03-15 23:01:24 -07:00
Alex Crichton
0015cab1fd Test fixes and rebase conflicts
This commit switches over the backtrace infrastructure from piggy-backing off
the RUST_LOG environment variable to using the RUST_BACKTRACE environment
variable (logging is now disabled in libstd).
2014-03-15 22:56:46 -07:00
Steven Fackler
05c73233e4 Tag derived impls with #[automatically_derived]
This will enable rustdoc to treat them specially.
2014-03-15 22:49:41 -07:00
Alex Crichton
17ad504fef rustc: Topographically sort rust dependencies
This commit starts to topographically sort rust dependencies on the linker
command line. The reason for this is that linkers use right-hand libraries to
resolve left-hand libraries symbols, which is especially crucial for us because
we're using --as-needed on linux.
2014-03-15 22:26:36 -07:00
Alex Crichton
0b3df19c6a rustc: Tweak where -lmorestack is on link commands
In removing many fields from the crate map, executables no longer always have an
explicit dependency on all upstream libraries. This means that the linker is no
longer picking them up as it used to.

To the best of my knowledge, the current situation is happening:

* On linux, we're passing the --as-needed flag to the linker, meaning that
  libraries are stripped out if there are no references to symbols in them.
* Executables may not reference libstd at all, such as "fn main() {}"
* When linking, the linker will discard libstd because there are no references
  to symbols in it. I presume that this means that all previous libs have had
  all their symbols resolved, so none of the libs are pulling in libstd as a
  dependency.
* The only real dependence on libstd comes from the rust_stack_exhausted symbol
  (which comes from libmorestack), but -lmorestack is at the end so by the time
  this comes up libstd is completely gone, leading to undefined references to
  rust_stack_exhausted

I'm not entirely convinced that this is what's happening, but it appears to be
along these lines. The one thing that I'm sure of is that removing the crate map
(and hence implicit dependency on all upstream libraries) has changed how
objects depend on upstream libraries.
2014-03-15 22:26:36 -07:00
Alex Crichton
a921dc4873 rustc: Remove compiler support for __log_level()
This commit removes all internal support for the previously used __log_level()
expression. The logging subsystem was previously modified to not rely on this
magical expression. This also removes the only other function to use the
module_data map in trans, decl_gc_metadata. It appears that this is an ancient
function from a GC only used long ago.

This does not remove the crate map entirely, as libgreen still uses it to hook
in to the event loop provided by libgreen.
2014-03-15 22:26:36 -07:00
Alex Crichton
cc6ec8df95 log: Introduce liblog, the old std::logging
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level <= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level <= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
2014-03-15 22:26:36 -07:00
Steven Fackler
2a35c08501 Squash test ~[] warning
The use of `std::os::args` creates a deprecated_owned_vector warning
with a bogus span.
2014-03-15 20:03:29 -07:00
bors
fc7a112808 auto merge of #12896 : alexcrichton/rust/goodbye-extra, r=brson
This commit shreds all remnants of libextra from the compiler and standard
distribution. Two modules, c_vec/tempfile, were moved into libstd after some
cleanup, and the other modules were moved to separate crates as seen fit.

Closes #8784
Closes #12413
Closes #12576
2014-03-14 23:11:31 -07:00
bors
26fdfa124c auto merge of #12878 : crabtw/rust/mips, r=alexcrichton
I ignored AtomicU64 methods on MIPS target
because libgcc doesn't implement MIPS32 64-bit atomic operations.
Otherwise it would cause link failure.

By the way, the patched LLVM doesn't have MIPS split stack anymore.
Should I file an issue about that?
2014-03-14 15:16:31 -07:00
Alex Crichton
58e4ab2b33 extra: Put the nail in the coffin, delete libextra
This commit shreds all remnants of libextra from the compiler and standard
distribution. Two modules, c_vec/tempfile, were moved into libstd after some
cleanup, and the other modules were moved to separate crates as seen fit.

Closes #8784
Closes #12413
Closes #12576
2014-03-14 13:59:02 -07:00
bors
2585803ec1 auto merge of #12764 : Kimundi/rust/partial_typehint, r=nikomatsakis
# Summary

This patch introduces the `_` token into the type grammar, with the meaning "infer this type".
With this change, the following two lines become equivalent:
```
let x = foo();
let x: _ = foo();
```
But due to its composability, it enables partial type hints like this:
```
let x: Bar<_> = baz();
```

Using it on the item level is explicitly forbidden, as the Rust language does not enable global type inference by design.

This implements the feature requested in https://github.com/mozilla/rust/issues/9508.

# Things requiring clarification

- The change to enable it is very small, but I have only limited understanding of the related code, so the approach here might be wrong.
  - In particular, while this patch works, it does so in a way not originally intended according to the code comments.
- This probably needs more tests, or rather feedback for which tests are still missing.
- I'm unsure how this interacts with lifetime parameters, and whether it is correct in regard to them.
- Partial type hints on the right side of `as` like `&foo as *_` work in both a normal function contexts and in constexprs like `static foo: *int = &'static 123 as *_`. The question is whether this should be allowed in general.

# Todo for this PR

- The manual and tutorial still needs updating.

# Bugs I'm unsure how to fix

- Requesting inference for the top level of the right hand side of a `as` fails to infer correctly, even if all possible hints are given:

  ```
.../type_hole_1.rs:35:18: 35:22 error: the type of this value must be known in this context
.../type_hole_1.rs:35     let a: int = 1u32 as _;
                                           ^~~~
```
2014-03-14 08:01:28 -07:00
Marvin Löbel
eb69eb36f8 Added support for type placeholders (explicit requested type
inference in a type with `_` ). This enables partial type inference.
2014-03-14 14:57:31 +01:00
bors
339f8163d6 auto merge of #12875 : alexcrichton/rust/demangle-more-things, r=brson
Add some more infrastructure support for demangling `$`-sequences, as well as fixing demangling of closure symbol names if there's more than one closure in a function.
2014-03-14 06:41:26 -07:00
bors
a1c7ebee1a auto merge of #12874 : huonw/rust/printier-rustc, r=alexcrichton
rustc: make stack traces print for .span_bug/.bug.

Previously a call to either of those to diagnostic printers would defer
to the `fatal` equivalents, which explicitly silence the stderr
printing, including a stack trace from `RUST_LOG=std::rt::backtrace`.

This splits the bug printers out to their own diagnostic type so that
things work properly.

Also, this removes the `Ok(...)` that was being printed around the
subtask's stderr output.
2014-03-14 05:26:29 -07:00
bors
b35e8fbfcb auto merge of #12861 : huonw/rust/lint-owned-vecs, r=thestinger
lint: add lint for use of a `~[T]`.

This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-13 22:26:35 -07:00
Jyun-Yan You
6d7e86d099 fix MIPS target
I ignored AtomicU64 methods on MIPS target
because libgcc doesn't implement MIPS32 64-bit atomic operations.
Otherwise it would cause link failure.
2014-03-14 11:13:36 +08:00
bors
98fa0f89b1 auto merge of #12798 : pczarn/rust/inline-asm, r=alexcrichton
## read+write modifier '+'
This small sugar was left out in the original implementation (#5359).
 
When an output operand with the '+' modifier is encountered, we store the index of that operand alongside the expression to create and append an input operand later. The following lines are equivalent:
```
asm!("" : "+m"(expr));
asm!("" : "=m"(expr) : "0"(expr));
```
## misplaced options and clobbers give a warning
It's really annoying when a small typo might change behavior without any warning.
```
asm!("mov $1, $0" : "=r"(x) : "r"(8u) : "cc" , "volatile");
//~^ WARNING expected a clobber, but found an option
```
## liveness
Fixed incorrect order of propagation.
Sometimes it caused spurious warnings in code: `warning: value assigned to `i` is never read, #[warn(dead_assignment)] on by default`

~~Note: Rebased on top of another PR. (uses other changes)~~

* [x] Implement read+write
* [x] Warn about misplaced options
* [x] Fix liveness (`dead_assignment` lint)
* [x] Add all tests
2014-03-13 18:41:35 -07:00
Huon Wilson
62792f09f2 lint: add lint for use of a ~[T].
This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-14 11:28:39 +11:00
Alex Crichton
a07149b138 rustc: Prevent collisions in names of closures
This commit goes back to using `gensym` to generate unique tokens to put into
the names of closures, allowing closures to be able to get demangled in
backtraces.

Closes #12400
2014-03-13 16:24:46 -07:00
Huon Wilson
edb6b025c4 rustc: make stack traces print for .span_bug/.bug.
Previously a call to either of those to diagnostic printers would defer
to the `fatal` equivalents, which explicitly silence the stderr
printing, including a stack trace from `RUST_LOG=std::rt::backtrace`.

This splits the bug printers out to their own diagnostic type so that
things work properly.

Also, this removes the `Ok(...)` that was being printed around the
subtask's stderr output.
2014-03-14 10:17:14 +11:00
Piotr Czarnecki
2a1bd2ff9f Fix and improve inline assembly.
Read+write modifier
Some documentation in asm.rs
rpass and cfail tests
2014-03-13 22:38:15 +01:00
bors
b4d324334c auto merge of #12815 : alexcrichton/rust/chan-rename, r=brson
* Chan<T> => Sender<T>
* Port<T> => Receiver<T>
* Chan::new() => channel()
* constructor returns (Sender, Receiver) instead of (Receiver, Sender)
* local variables named `port` renamed to `rx`
* local variables named `chan` renamed to `tx`

Closes #11765
2014-03-13 14:06:37 -07:00
Alex Crichton
7858065113 std: Rename Chan/Port types and constructor
* Chan<T> => Sender<T>
* Port<T> => Receiver<T>
* Chan::new() => channel()
* constructor returns (Sender, Receiver) instead of (Receiver, Sender)
* local variables named `port` renamed to `rx`
* local variables named `chan` renamed to `tx`

Closes #11765
2014-03-13 13:23:29 -07:00
bors
3fbee34a89 auto merge of #12238 : ktt3ja/rust/lifetime-error-msg, r=nikomatsakis
For the following code snippet:

```rust
struct Foo { bar: int }
fn foo1(x: &Foo) -> &int {
    &x.bar
}
```

This PR generates the following error message:

```rust
test.rs:2:1: 4:2 note: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a int
test.rs:2 fn foo1(x: &Foo) -> &int {
test.rs:3     &x.bar
test.rs:4 }
test.rs:3:5: 3:11 error: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
test.rs:3     &x.bar
              ^~~~~~
```

Currently it does not support methods.
2014-03-13 09:41:35 -07:00
Niko Matsakis
01a15d5870 Tweak comments 2014-03-13 14:21:46 +02:00
Eduard Burtescu
27c62449db Region + borrow checker support and tests for overloaded autoderef. 2014-03-13 14:21:46 +02:00
Eduard Burtescu
feedd37653 Apply @nikomatsakis' nits and comments patch. 2014-03-13 14:21:45 +02:00
Eduard Burtescu
26398b4f6d Introduce a common recursion limit for auto-dereference and monomorphization. 2014-03-13 14:21:45 +02:00
Eduard Burtescu
20b4e159ed Implement automatic overloaded dereference.
Closes #7141.
2014-03-13 14:21:45 +02:00
Eduard Burtescu
cdc18b96d6 Remove Rc's borrow method to avoid conflicts with RefCell's borrow in Rc<RefCell<T>>. 2014-03-13 14:21:45 +02:00
bors
a53242a1a3 auto merge of #12756 : pongad/rust/remove_owned_str_pat, r=alexcrichton
match-drop-strs-issue-4541.rs deleted as it's the same with issue-4541.rs
2014-03-12 19:21:44 -07:00
Michael Darakananda
f079c94f72 rustc: Remove matching on ~str from the language
The `~str` type is not long for this world as it will be superseded by the
soon-to-come DST changes for the language. The new type will be
`~Str`, and matching over the allocation will no longer be supported.
Matching on `&str` will continue to work, in both a pre and post DST world.
2014-03-12 19:17:36 -04:00
lpy
aac6e31763 Remove remaining nolink usages.(fixes #12810) 2014-03-12 15:01:25 -07:00
Kiet Tran
9faa2a58f2 Suggest explicit lifetime parameter on some errors
Some types of error are caused by missing lifetime parameter on function
or method declaration. In such cases, this commit generates some
suggestion about what the function declaration could be. This does not
support method declaration yet.
2014-03-12 16:34:05 -04:00
bors
18356675e5 auto merge of #12816 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
Fixes #12811 as described in the issue.
2014-03-12 07:42:03 -07:00
Felix S. Klock II
742e458102 Add proper support for early/late distinction for lifetime bindings.
Uses newly added Vec::partition method to simplify resolve_lifetime.
2014-03-12 08:05:28 +01:00
Felix S. Klock II
586b619c76 Changed lists of lifetimes in ast and ty to use Vec instead of OptVec.
There is a broader revision (that does this across the board) pending
in #12675, but that is awaiting the arrival of more data (to decide
whether to keep OptVec alive by using a non-Vec internally).

For this code, the representation of lifetime lists needs to be the
same in both ScopeChain and in the ast and ty structures.  So it
seemed cleanest to just use `vec_ng::Vec`, now that it has a cheaper
empty representation than the current `vec` code.
2014-03-12 08:05:20 +01:00
Felix S. Klock II
28ebec5160 Introduce Scope<'a> shorthand for &'a ScopeChain<'a>. 2014-03-12 08:02:38 +01:00
Felix S. Klock II
189c0085d1 alpha-rename .ident to .name in Lifetime, including in rustdoc. 2014-03-12 08:02:32 +01:00
Felix S. Klock II
460ca4f037 Alpha-rename .ident fields of type Name to .name. 2014-03-12 07:51:49 +01:00
Huon Wilson
198caa87cd Update users for the std::rand -> librand move. 2014-03-12 11:31:43 +11:00
Michael Woerister
3ea50f0e36 debuginfo: Improve commandline option handling for debuginfo (fixes #12811)
The `-g` flag does not take an argument anymore while the argument to `--debuginfo` becomes mandatory. This change makes it possible again to run the compiler like this:

`rustc -g ./file.rs`

This did not work before because `./file.rs` was misinterpreted as the argument to `-g`. In order to get limited debuginfo, one now has to use `--debuginfo=1`.
2014-03-11 18:15:35 +01:00
bors
9f3ebd8fc5 auto merge of #12556 : alexcrichton/rust/weak-linkage, r=brson
It is often convenient to have forms of weak linkage or other various types of
linkage. Sadly, just using these flavors of linkage are not compatible with
Rust's typesystem and how it considers some pointers to be non-null.

As a compromise, this commit adds support for weak linkage to external symbols,
but it requires that this is only placed on extern statics of type `*T`.
Codegen-wise, we get translations like:

```rust
    // rust code
    extern {
        #[linkage = "extern_weak"]
        static foo: *i32;
    }

    // generated IR
    @foo = extern_weak global i32
    @_some_internal_symbol = internal global *i32 @foo
```

All references to the rust value of `foo` then reference `_some_internal_symbol`
instead of the symbol `_foo` itself. This allows us to guarantee that the
address of `foo` will never be null while the value may sometimes be null.

An example was implemented in `std::rt::thread` to determine if
`__pthread_get_minstack()` is available at runtime, and a test is checked in to
use it for a static value as well. Function pointers a little odd because you
still need to transmute the pointer value to a function pointer, but it's
thankfully better than not having this capability at all.

Thanks to @bnoordhuis for the original patch, most of this work is still his!
2014-03-11 09:56:57 -07:00
Alex Crichton
699b33d060 rustc: Support various flavors of linkages
It is often convenient to have forms of weak linkage or other various types of
linkage. Sadly, just using these flavors of linkage are not compatible with
Rust's typesystem and how it considers some pointers to be non-null.

As a compromise, this commit adds support for weak linkage to external symbols,
but it requires that this is only placed on extern statics of type `*T`.
Codegen-wise, we get translations like:

    // rust code
    extern {
        #[linkage = "extern_weak"]
        static foo: *i32;
    }

    // generated IR
    @foo = extern_weak global i32
    @_some_internal_symbol = internal global *i32 @foo

All references to the rust value of `foo` then reference `_some_internal_symbol`
instead of the symbol `_foo` itself. This allows us to guarantee that the
address of `foo` will never be null while the value may sometimes be null.

An example was implemented in `std::rt::thread` to determine if
`__pthread_get_minstack()` is available at runtime, and a test is checked in to
use it for a static value as well. Function pointers a little odd because you
still need to transmute the pointer value to a function pointer, but it's
thankfully better than not having this capability at all.
2014-03-11 08:25:42 -07:00
Edward Wang
abfde39b0e borrowck: classify expressions as assignees, uses or both
- Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so
  that borrowck effectively classifies all expressions into assignees,
  uses or both.
- Removes two `span_err` in liveness analysis, which are now borrowck's
  responsibilities.

Closes #12527.
2014-03-09 23:23:28 +08:00
bors
5d1d285623 auto merge of #12758 : rgawdzik/rust/master, r=alexcrichton
Refactored get_metadata_section to return a Result<MetadataBlob,~str> instead of a Option<MetadataBlob>. This provides more clarity to the user through the debug output when using --ls.

This is kind of a continuation of my original closed pull request 2 months ago (#11544), but I think the time-span constitutes a new pull request.
2014-03-08 20:51:48 -08:00
Robert Gawdzik
3bf724e44b Refactored get_metadata_section to return a Result<T,~str>, added error messages. Closes #6615. 2014-03-08 20:46:18 -05:00
Felix S. Klock II
43c07244b3 librustc: Fix up fallout from the automatic conversion. 2014-03-08 21:41:32 +01:00
Patrick Walton
3b6e9d4a7a librustc: Automatically change uses of ~[T] to Vec<T> in rustc. 2014-03-08 21:24:27 +01:00
Daniel Micay
4d7d101a76 create a sensible comparison trait hierarchy
* `Ord` inherits from `Eq`
* `TotalOrd` inherits from `TotalEq`
* `TotalOrd` inherits from `Ord`
* `TotalEq` inherits from `Eq`

This is a partial implementation of #12517.
2014-03-07 22:45:22 -05:00
bors
b1d104c644 auto merge of #12750 : liigo/rust/De-extern-mod, r=alexcrichton
rename ast::ViewItemExternMod to ast::ViewItemExternCrate
rename rustdoc::clean::ExternMod to rustdoc::clean::ExternCrate
because `extern mod` is out.
2014-03-07 01:01:40 -08:00
Liigo Zhuang
2271860af1 rename ast::ViewItemExternMod to ast::ViewItemExternCrate, and clean::ExternMod to clean::ExternCrate 2014-03-07 15:57:45 +08:00
Ted Horst
0bdd31cc61 change FVN hash function to the FVN-1a variant 2014-03-07 01:25:25 -06:00
Alex Crichton
0a84132928 syntax: Conditionally deriving(Hash) with Writers
If #[feature(default_type_parameters)] is enabled for a crate, then
deriving(Hash) will expand with Hash<W: Writer> instead of Hash<SipState> so
more hash algorithms can be used.
2014-03-06 18:11:02 -08:00
Alex Crichton
bec7b766fb rustc: Move to FNV hashing for node/def ids
This leverages the new hashing framework and hashmap implementation to provide a
much speedier hashing algorithm for node ids and def ids. The hash algorithm
used is currentl FNV hashing, but it's quite easy to swap out.

I originally implemented hashing as the identity function, but this actually
ended up in slowing down rustc compiling libstd from 8s to 13s. I would suspect
that this is a result of a large number of collisions.

With FNV hashing, we get these timings (compiling with --no-trans, in seconds):

|           |  before  |  after  |
|-----------|---------:|--------:|
| libstd    |   8.324  |  6.703  |
| stdtest   |  47.674  | 46.857  |
| libsyntax |   9.918  |  8.400  |
2014-03-06 17:45:48 -08:00
Flavio Percoco
abfc6db4c2 rustc: Move mut slice check to check_static
This is a follow-up patch that moves the mut slice check to the recently
added `check_static`

Closes #11411
2014-03-06 22:50:39 +01:00
xales
8b8d41d28a Allow mutable slices in statics.
Fixes #11411
2014-03-06 22:50:39 +01:00
bors
987de29865 auto merge of #12732 : klutzy/rust/this-is-windows, r=alexcrichton
On Windows, `LLVMRustGetLastError()` may return non-utf8 mojibake string
if system uses non-English locale. It caused ICE when llvm fails.
This patch doesn't fix the real problem, but just make rustc not die.
2014-03-06 12:37:01 -08:00
klutzy
f6afd40fc1 rustc: Get LLVM error message safely
On Windows, `LLVMRustGetLastError()` may return non-utf8 mojibake string
if system uses non-English locale. It caused ICE when llvm fails.
This patch doesn't fix the real problem, but just make rustc not die.
2014-03-07 00:18:32 +09:00
bors
fb80b384f4 auto merge of #12727 : lifthrasiir/rust/buffalo-buffalo, r=huonw
Cosmetic changes at best, but there are so many such typos that I couldn't ignore them. :) Some occurrences of typos are linked to the generated documentations but no changes should break the builds.
2014-03-06 06:51:35 -08:00
Kang Seonghoon
1c52c81846 fix typos with with repeated words, just like this sentence. 2014-03-06 20:19:14 +09:00
bors
68903f2cdf auto merge of #12719 : alexcrichton/rust/fix-llvm-33, r=brson
The llvm.copysign and llvm.round intrinsics weren't added until LLVM 3.4, so if
we're on LLVM 3.3 we lower these to calls in libm instead of LLVM intrinsics.

This should fix our travis failures.
2014-03-06 03:11:39 -08:00
bors
14c620719c auto merge of #12714 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
This PR brings back limited debuginfo which allows for nice backtraces and breakpoints, but omits any info about variables and types.

The `-g` and `--debuginfo` command line options have been extended to take an optional argument:
`-g0` means no debug info.
`-g1` means line-tables only.
`-g2` means full debug info.

Specifying `-g` without argument is equivalent to `-g2`.

Fixes #12280
2014-03-06 01:56:43 -08:00
Michael Woerister
e15fd400ba debuginfo: Expose limited debuginfo in command line options 2014-03-06 07:59:37 +01:00
Michael Woerister
1938e87393 debuginfo: Re-introduce the notion of line-table-only debuginfo. 2014-03-06 07:57:18 +01:00
Jed Davis
d90830221e Fix ICE on statics with fancy nullable enums.
Closes #8506.

The `trans::adt` code for statics uses fields with `C_undef` values to
insert alignment padding (because LLVM's own alignment padding isn't
always sufficient for aggregate constants), and assumes that all fields
in the actual Rust value are represented by non-undef LLVM values, to
distinguish them from that padding.

But for nullable pointer enums, if non-null variant has fields other
than the pointer used as the discriminant, they would be set to undef in
the null case, to reflect that they're never accessed.

To avoid the obvious conflict between these two items, the latter undefs
were wrapped in unary LLVM structs to distinguish them from the former
undefs.  Except this doesn't actually work -- LLVM, not unreasonably,
treats the "wrapped undef" as a regular undef.

So this commit just sets all fields to null in the null pointer case of
a nullable pointer enum static, because the other fields don't really
need to be undef in the first place.
2014-03-05 21:23:33 -08:00
Alex Crichton
9396452592 rustc: Fix support for LLVM 3.3
The llvm.copysign and llvm.round intrinsics weren't added until LLVM 3.4, so if
we're on LLVM 3.3 we lower these to calls in libm instead of LLVM intrinsics.

This should fix our travis failures.
2014-03-05 18:05:05 -08:00
bors
ff22e47c19 auto merge of #12715 : dmski/rust/no-extern-fn-pat, r=alexcrichton
Fixes #10877

There was another PR which attempted to fix this in the parser (#11804) and which was closed due to inactivity.
This PR modifies typeck instead (as suggested in #11804), which indeed seems to be simpler than modifying the parser and allows for a better error message.
2014-03-05 12:51:48 -08:00
Dmitry Promsky
53f3442ef7 Disallowed patterns in extern fn declarations.
Closes #10877
2014-03-06 00:01:16 +04:00
Edward Wang
2302ce903d Refactor and fix FIXME's in mtwt hygiene code
- Moves mtwt hygiene code into its own file
- Fixes FIXME's which leads to ~2x speed gain in expansion pass
- It is now @-free
2014-03-05 22:45:51 +08:00
bors
87a31f6f0f auto merge of #12491 : eddyb/rust/deref, r=nikomatsakis
Add the `Deref` and `DerefMut` traits and implement overloading explicit dereferences.
2014-03-04 23:21:42 -08:00
bors
712c630ab6 auto merge of #12300 : DaGenix/rust/uppercase-variable-lint, r=alexcrichton
I added a new lint for variables whose names contain uppercase characters, since, by convention, variable names should be all lowercase. What motivated me to work on this was when I ran into something like the following:

```rust
use std::io::File;
use std::io::IoError;

fn main() {
    let mut f = File::open(&Path::new("/something.txt"));
    let mut buff = [0u8, ..16];
    match f.read(buff) {
        Ok(cnt) => println!("read this many bytes: {}", cnt),
        Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_str()),
    }
}
```

I then got compile errors when I tried to add a wildcard match pattern at the end which I found very confusing since I believed that the 2nd match arm was only matching the EndOfFile condition. The problem is that I hadn't imported io::EndOfFile into the local scope. So, I thought that I was using EndOfFile as a sub-pattern, however, what I was actually doing was creating a new local variable named EndOfFile. This lint makes this error easier to spot by providing a warning that the variable name EndOfFile contains a uppercase characters which provides a nice hint as to why the code isn't doing what is intended.

The lint warns on local bindings as well:

```rust
let Hi = 0;
```

And also struct fields:

```rust
struct Something {
    X: uint
}
```
2014-03-04 22:06:38 -08:00
Palmer Cox
258dbd09ba Emit the uppercase variable lint for struct fields that have names with uppercase characters 2014-03-05 00:22:19 -05:00
bors
f1955e028c auto merge of #12688 : alexcrichton/rust/fix-some-link-args, r=brson
Linker argument order with respect to libraries is important enough that we
shouldn't be attempting to filter out libraries getting passed through to the
linker. When linking with a native library that has multiple dependant native
libraries, it's useful to have control over the link argument order.
2014-03-04 18:26:40 -08:00
Palmer Cox
a9798c25df Rename struct fields with uppercase characters in their names to use lowercase 2014-03-04 21:23:37 -05:00
Palmer Cox
935c912335 Add lint for variable names that contain uppercase characters 2014-03-04 21:23:37 -05:00
Palmer Cox
6d9bdf975a Rename all variables that have uppercase characters in their names to use only lowercase characters 2014-03-04 21:23:36 -05:00
bors
dcb24f5450 auto merge of #12697 : thestinger/rust/vec, r=huonw
This exists for the sake of compatibility during the ~[T] -> Vec<T>
transition. It will be removed in the future.
2014-03-04 17:11:39 -08:00
Daniel Micay
15adaf6f3e mark the map method on Vec<T> as deprecated
This exists for the sake of compatibility during the ~[T] -> Vec<T>
transition. It will be removed in the future.
2014-03-04 19:37:07 -05:00
Eduard Burtescu
bcc5486c17 Allow overloading explicit dereferences. 2014-03-05 00:26:51 +02:00
bors
0a5138c752 auto merge of #12667 : Kimundi/rust/any_improv, r=cmr
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed from 2 to 1.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.
- Added bench.

Bench before/after:
~~~
7 ns/iter (+/- 0)
4 ns/iter (+/- 0)
~~~
2014-03-04 13:16:41 -08:00
Marvin Löbel
3158047a45 Cleaned up std::any
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.

- Added bench for `Any`
2014-03-04 21:10:23 +01:00
Adrien Tétar
0106a04d70 doc: use the newer favicon 2014-03-04 18:37:51 +01:00
Eduard Burtescu
3b125ff3bb Add the DerefImm and DerefMut traits. 2014-03-04 16:41:48 +02:00
bors
19fadf6567 auto merge of #12678 : lifthrasiir/rust/pluralize, r=alexcrichton
While we are not yet ready for compiler i18n, this also keeps the error handling code clean. The set of altered error messages was obtained by grepping for `"s"` and `(s)`, so there might be some missing messages.
2014-03-04 00:31:40 -08:00
Kang Seonghoon
21454452b2 rustc: Streamline error messages for i18n, using plural whenever possible. 2014-03-04 16:41:57 +09:00
bors
dc18659160 auto merge of #12669 : huonw/rust/de-block-arms, r=alexcrichton
syntax: make match arms store the expr directly.

Previously `ast::Arm` was always storing a single `ast::Expr` wrapped in an
`ast::Block` (for historical reasons, AIUI), so we might as just store
that expr directly.

Closes #3085.
2014-03-03 23:16:40 -08:00
Alex Crichton
b0e0cb5e32 Register new snapshots
This should fix the travis builds.
2014-03-03 18:00:52 -08:00
Huon Wilson
c3b9047040 syntax: make match arms store the expr directly.
Previously `ast::Arm` was always storing a single `ast::Expr` wrapped in an
`ast::Block` (for historical reasons, AIUI), so we might as just store
that expr directly.

Closes #3085.
2014-03-03 22:48:42 +11:00
Steven Fackler
4c2353adee Make visible types public in rustc 2014-03-02 15:26:39 -08:00
bors
910012aaba auto merge of #12637 : pcwalton/rust/devecing, r=alexcrichton
r? @alexcrichton
2014-03-02 08:31:33 -08:00
bors
b5ad3022da auto merge of #12645 : alexcrichton/rust/invalid-libraries, r=brson
When the metadata format changes, old libraries often cause librustc to abort
when reading their metadata. This should all change with the introduction of SVH
markers, but the loader for crates should gracefully handle libraries without
SVH markers still.

This commit adds support for tripping fewer assertions when loading libraries by
using maybe_get_doc when initially parsing metadata. It's still possible for
some libraries to fall through the cracks, but this should deal with a fairly
large number of them up front.
2014-03-02 00:26:26 -08:00
Alex Crichton
997ff7abd4 rustc: Better error when loading invalid libraries
When the metadata format changes, old libraries often cause librustc to abort
when reading their metadata. This should all change with the introduction of SVH
markers, but the loader for crates should gracefully handle libraries without
SVH markers still.

This commit adds support for tripping fewer assertions when loading libraries by
using maybe_get_doc when initially parsing metadata. It's still possible for
some libraries to fall through the cracks, but this should deal with a fairly
large number of them up front.
2014-03-01 23:36:28 -08:00
Patrick Walton
c1ed4d7d41 librustc: Fix errors arising from the automated ~[T] conversion 2014-03-01 22:40:53 -08:00
bors
c81b3fb21a Merge pull request #12636 from chromatic/fixup_trans_fail
Cleaned up trans_fail(), per eddyb request.

Reviewed-by: huonw
2014-03-01 19:44:37 -08:00
Alex Crichton
2cb83fdd7e std: Switch stdout/stderr to buffered by default
Similarly to #12422 which made stdin buffered by default, this commit makes the
output streams also buffered by default. Now that buffered writers will flush
their contents when they are dropped, I don't believe that there's no reason why
the output shouldn't be buffered by default, which is what you want in 90% of
cases.

As with stdin, there are new stdout_raw() and stderr_raw() functions to get
unbuffered streams to stdout/stderr.
2014-03-01 10:06:20 -08:00
bors
3d117cf3ca auto merge of #12639 : luqmana/rust/struct-variant-pat, r=pcwalton
We weren't passing the node id for the enum and hence it couldn't retrieve the field types for the struct variant we were trying to destructure.

Fixes #11577.
2014-03-01 03:06:31 -08:00
bors
d60e43d9e9 auto merge of #12638 : luqmana/rust/op-no-ref, r=alexcrichton
From my comment on #11450:

The reason for the ICE is because for operators `rustc` does a little bit of magic. Notice that while you implement the `Mul` trait for some type `&T` (i.e a reference to some T), you can simply do `Vec2 {..} * 2.0f32`. That is, `2.0f32` is `f32` and not `&f32`. This works because `rustc` will automatically take a reference. So what's happening is that with `foo * T`, the compiler is expecting the `mul` method to take some `&U` and then it can compare to make sure `T == U` (or more specifically that `T` coerces to `U`). But in this case, the argument of the `mul` method is not a reference and hence the "no ref" error.

I don't think we should ICE in this case since we do catch the mismatched trait/impl method and hence provide a better error message that way.

Fixes #11450
2014-03-01 01:51:35 -08:00
bors
cb498cc40d auto merge of #12627 : alexcrichton/rust/issue-12623, r=brson
This helps prevent the unfortunate interleavings found in #12623.
2014-03-01 00:36:35 -08:00
Alex Crichton
02882fbd7e std: Change assert_eq!() to use {} instead of {:?}
Formatting via reflection has been a little questionable for some time now, and
it's a little unfortunate that one of the standard macros will silently use
reflection when you weren't expecting it. This adds small bits of code bloat to
libraries, as well as not always being necessary. In light of this information,
this commit switches assert_eq!() to using {} in the error message instead of
{:?}.

In updating existing code, there were a few error cases that I encountered:

* It's impossible to define Show for [T, ..N]. I think DST will alleviate this
  because we can define Show for [T].
* A few types here and there just needed a #[deriving(Show)]
* Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
* `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
  I don't think this is much of a regression though because {:?} on paths looks
  awful (it's a byte array).

Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
significant for smaller binaries.
2014-02-28 23:01:54 -08:00
chromatic
e2afa1cd5c Cleaned up trans_fail functions, per eddyb request. 2014-02-28 21:54:07 -08:00
Luqman Aden
a174941392 librustc: Don't ICE when operator traits are not implemented properly. Fixes #11450 2014-03-01 00:27:02 -05:00
Luqman Aden
715e618577 librustc: Pass the node id so we don't fail on destructing struct variants. Fixes #11577. 2014-02-28 23:35:10 -05:00
Alex Crichton
324547140e syntax: Refactor diagnostics to focus on Writers
This commit alters the diagnostic emission machinery to be focused around a
Writer for emitting errors. This allows it to not hard-code emission of errors
to stderr (useful for other applications).
2014-02-28 11:37:04 -08:00
Alex Crichton
ec57db083f rustc: Add the concept of a Strict Version Hash
This new SVH is used to uniquely identify all crates as a snapshot in time of
their ABI/API/publicly reachable state. This current calculation is just a hash
of the entire crate's AST. This is obviously incorrect, but it is currently the
reality for today.

This change threads through the new Svh structure which originates from crate
dependencies. The concept of crate id hash is preserved to provide efficient
matching on filenames for crate loading. The inspected hash once crate metadata
is opened has been changed to use the new Svh.

The goal of this hash is to identify when upstream crates have changed but
downstream crates have not been recompiled. This will prevent the def-id drift
problem where upstream crates were recompiled, thereby changing their metadata,
but downstream crates were not recompiled.

In the future this hash can be expanded to exclude contents of the AST like doc
comments, but limitations in the compiler prevent this change from being made at
this time.

Closes #10207
2014-02-28 10:48:04 -08:00
Alex Crichton
8213e18447 rustc: Simplify crate loading constraints
The previous code passed around a {name,version} pair everywhere, but this is
better expressed as a CrateId. This patch changes these paths to store and pass
around crate ids instead of these pairs of name/version. This also prepares the
code to change the type of hash that is stored in crates.
2014-02-28 10:47:41 -08:00
Huon Wilson
218eae06ab Publicise types/add #[allow(visible_private_types)] to a variety of places.
There's a lot of these types in the compiler libraries, and a few of the
older or private stdlib ones. Some types are obviously meant to be
public, others not so much.
2014-03-01 00:12:34 +11:00
Huon Wilson
859277dfdb rustc: implement a lint for publicly visible private types.
These are types that are in exported type signatures, but are not
exported themselves, e.g.

    struct Foo { ... }

    pub fn bar() -> Foo { ... }

will warn about the Foo.

Such types are not listed in documentation, and cannot be named outside
the crate in which they are declared, which is very user-unfriendly.

cc #10573
2014-03-01 00:11:56 +11:00
bors
31e9c947a3 auto merge of #12544 : erickt/rust/hash, r=acrichto
This PR allows `HashMap`s to work with custom hashers. Also with this patch are:

* a couple generic implementations of `Hash` for a variety of types.
* added `Default`, `Clone` impls to the hashers.
* added a `HashMap::with_hasher()` constructor.
2014-02-28 00:26:34 -08:00
bors
53e90c15a6 auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichton
Closes #12546 (Add new target 'make dist-osx' to create a .pkg installer for OS X) r=brson
Closes #12575 (rustc: Move local native libs back in link-args) r=brson
Closes #12587 (Provide a more helpful error for tests that fail due to noexec) r=brson
Closes #12589 (rustc: Remove codemap and reachable from metadata encoder) r=alexcrichton
Closes #12591 (Fix syntax::ext::deriving{,::*} docs formatting.) r=huonw
Closes #12592 (Miscellaneous Vim improvements) r=alexcrichton
Closes #12596 (path: Implement windows::make_non_verbatim()) r=alexcrichton
Closes #12598 (Improve the ctags function regular expression) r=alexcrichton
Closes #12599 (Tutorial improvement (new variant of PR #12472).) r=pnkfelix
Closes #12603 (std: Export the select! macro) r=pcwalton
Closes #12605 (Fix typo in doc of Binary trait in std::fmt) r=alexcrichton
Closes #12613 (Fix bytepos_to_file_charpos) r=brson
2014-02-27 23:01:55 -08:00
bors
f203fc7daf auto merge of #12348 : brunoabinader/rust/libcollections-list-refactory, r=alexcrichton
This PR includes:
- Create an iterator for ```List<T>``` called ```Items<T>```;
- Move all list operations inside ```List<T>``` impl;
- Removed functions that are already provided by ```Iterator``` trait;
- Refactor on ```len()``` and ```is_empty``` using ```Container``` trait;
- Bunch of minor fixes;

A replacement for using @ is intended, but still in discussion.

Closes #12344.
2014-02-27 21:46:53 -08:00
Brian Anderson
c5fbc5048b rustc: Remove codemap and reachable from metadata encoder 2014-02-27 21:04:01 -08:00
Alex Crichton
cdc5729ea2 rustc: Move local native libs back in link-args
With linkers on unix systems, libraries on the right of the command line are
used to resolve symbols in those on the left of the command line. This means
that arguments must have a right-to-left dependency chain (things on the left
depend on things on the right).

This is currently done by ordering the linker arguments as

  1. Local object
  2. Local native libraries
  3. Upstream rust libraries
  4. Upstream native libraries

This commit swaps the order of 2 and 3 so upstream rust libraries have access to
local native libraries. It has been seen that some upstream crates don't specify
the library that they link to because the name varies per platform (e.g.
lua/glfw/etc).

This commit enables building these libraries by allowing the upstream rust crate
to have access to local native libraries. I believe that the failure mode for
this scheme is when an upstream rust crate depends on a symbol in an upstream
library which is then redefined in a local library. This failure mode is
incredibly uncommon, and the failure mode also varies per platform (OSX behaves
differently), so I believe that a change like this is fine to make.

Closes #12446
2014-02-27 19:59:02 -08:00
Erick Tryzelaar
72b5e30f6c collections: allow HashMap to work with generic hashers 2014-02-27 19:02:52 -08:00
Flavio Percoco
59a04f5b12 Immutable static items should be Freeze Fixes #12432 2014-02-27 18:09:35 +01:00
Flavio Percoco
ee2f001a42 Forbid certain types for static items
- For each *mutable* static item, check that the **type**:
    - cannot own any value whose type has a dtor
    - cannot own any values whose type is an owned pointer

- For each *immutable* static item, check that the **value**:
    - does not contain any ~ or box expressions
        (including ~[1, 2, 3] sort of things)
    - does not contain a struct literal or call to an enum
        variant / struct constructor where
        - the type of the struct/enum has a dtor
2014-02-27 18:09:33 +01:00
Bruno de Oliveira Abinader
43bc6fcc62 Replaced list::each with iter() in get_region 2014-02-27 08:35:18 -04:00
Flavio Percoco
8784d2fa95 Forbid moves out of static items Closes #10577 2014-02-27 09:24:17 +01:00
Flavio Percoco
c75dd78ccb Keep track of Enum's with destructors 2014-02-27 09:24:16 +01:00
Flavio Percoco
a22539b083 Implement has_dtor method in TypeContents 2014-02-27 09:24:16 +01:00
Flavio Percoco
4cb3bd558f Remove unused type_is_pod function 2014-02-27 09:24:16 +01:00
Alex Crichton
4cdc6ce337 rustc: Don't deduplicate libraries linked to
Linker argument order with respect to libraries is important enough that we
shouldn't be attempting to filter out libraries getting passed through to the
linker. When linking with a native library that has multiple dependant native
libraries, it's useful to have control over the link argument order.
2014-02-26 16:58:37 -08:00
Kang Seonghoon
9083cb24b2 rustc: Explicitly mention type params with missing 'static bounds
Also renames `check_durable` to `check_static` and removes the outdated
comment.
2014-02-27 02:14:46 +09:00
Eduard Burtescu
05e4d944a9 Replace callee_id with information stored in method_map. 2014-02-26 16:06:45 +02:00
Eduard Burtescu
7a588ceff2 Rename a few typeck method-related structures to UpperCamelCase. 2014-02-26 16:01:36 +02:00
Eduard Burtescu
39504719b4 resolve: Don't use @RefCell in trait_map, nothing modifies its entries. 2014-02-25 19:08:55 +02:00
Eduard Burtescu
9d5532618f resolve: Remove all the operator overloads from trait_map. 2014-02-25 19:08:55 +02:00
Eduard Burtescu
d096eefd80 Use only the appropriate trait when looking up operator overloads. 2014-02-25 19:08:54 +02:00
Eduard Burtescu
818203e9d2 typeck: Remove old diagnostic that refers to do. 2014-02-25 19:08:54 +02:00
bors
25d68366b7 auto merge of #12522 : erickt/rust/hash, r=alexcrichton
This patch series does a couple things:

* replaces manual `Hash` implementations with `#[deriving(Hash)]`
* adds `Hash` back to `std::prelude`
* minor cleanup of whitespace and variable names.
2014-02-25 06:41:36 -08:00
bors
d222f03f42 auto merge of #12525 : eddyb/rust/gate-default-type-param-usage, r=alexcrichton
Also reverted `#[deriving(Hash)]` to implement `Hash` only for `SipState`, until we decide what to do about default type params.
2014-02-25 05:26:36 -08:00
Edward Wang
4690ab0ea8 Match binding is assignment
In its first pass, namely gather_loans, the borrow checker tracks the
initialization sites among other things it does. It does so for let
bindings with initializers but not for bindings in match arms, which are
effectively also assignments. This patch does that for borrow checker.

Closes #12452.
2014-02-24 21:22:27 -08:00
Björn Steinbrink
0309104cc5 Mark by-value parameters that are passed on the stack as nocapture
The by-value argument is a copy that is only valid for the duration of
the function call, therefore keeping any pointer to it that outlives the
call is illegal.
2014-02-24 21:22:26 -08:00
Alex Crichton
53b9484daf Use lines_any() when parsing output form "ar"
On windows lines are delimited with \r\n while on unix they're delimited with
\n.

cc #12471
2014-02-24 21:22:26 -08:00
Alex Crichton
8922fa0122 rustc: Don't error on the rlib symlinks
This commit implements a layman's version of realpath() for metadata::loader to
use in order to not error on symlinks pointing to the same file.

Closes #12459
2014-02-24 21:22:25 -08:00
Erick Tryzelaar
6335a76b6e rustc: rename hash to the proper name state 2014-02-24 19:56:10 -08:00
Erick Tryzelaar
f12ff1964b std: minor whitespace cleanup 2014-02-24 19:52:29 -08:00
bors
994b48cf52 auto merge of #12453 : alexcrichton/rust/move-json, r=brson
This also inverts the dependency between libserialize and libcollections.

cc #8784
2014-02-24 15:57:13 -08:00
bors
b48bc9ec93 auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichton
Commits for details. Highlights:

- `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]`
- a lot of `transmute`s removed outright or replaced with `as` (etc.)
2014-02-24 14:37:01 -08:00
Eduard Burtescu
3e531ed0ed Gate default type parameter overrides.
Fixes #12423.
2014-02-24 22:45:31 +02:00
Alex Crichton
6485917d7c Move extra::json to libserialize
This also inverts the dependency between libserialize and libcollections.

cc #8784
2014-02-24 09:51:39 -08:00
bors
672097753a auto merge of #12412 : alexcrichton/rust/deriving-show, r=huonw
This commit removes deriving(ToStr) in favor of deriving(Show), migrating all impls of ToStr to fmt::Show.

Most of the details can be found in the first commit message.

Closes #12477
2014-02-24 04:11:53 -08:00
bors
a5342d5970 auto merge of #12380 : alexcrichton/rust/run-rewrite, r=brson
The std::run module is a relic from a standard library long since past, and
there's not much use to having two modules to execute processes with where one
is slightly more convenient. This commit merges the two modules, moving lots of
functionality from std::run into std::io::process and then deleting
std::run.

New things you can find in std::io::process are:

* Process::new() now only takes prog/args
* Process::configure() takes a ProcessConfig
* Process::status() is the same as run::process_status
* Process::output() is the same as run::process_output
* I/O for spawned tasks is now defaulted to captured in pipes instead of ignored
* Process::kill() was added (plus an associated green/native implementation)
* Process::wait_with_output() is the same as the old finish_with_output()
* destroy() is now signal_exit()
* force_destroy() is now signal_kill()

Closes #2625
Closes #10016
2014-02-23 22:06:50 -08:00
Alex Crichton
a9bd447400 Roll std::run into std::io::process
The std::run module is a relic from a standard library long since past, and
there's not much use to having two modules to execute processes with where one
is slightly more convenient. This commit merges the two modules, moving lots of
functionality from std::run into std::io::process and then deleting
std::run.

New things you can find in std::io::process are:

* Process::new() now only takes prog/args
* Process::configure() takes a ProcessConfig
* Process::status() is the same as run::process_status
* Process::output() is the same as run::process_output
* I/O for spawned tasks is now defaulted to captured in pipes instead of ignored
* Process::kill() was added (plus an associated green/native implementation)
* Process::wait_with_output() is the same as the old finish_with_output()
* destroy() is now signal_exit()
* force_destroy() is now signal_kill()

Closes #2625
Closes #10016
2014-02-23 21:51:17 -08:00
Alex Crichton
b78b749810 Remove all ToStr impls, add Show impls
This commit changes the ToStr trait to:

    impl<T: fmt::Show> ToStr for T {
        fn to_str(&self) -> ~str { format!("{}", *self) }
    }

The ToStr trait has been on the chopping block for quite awhile now, and this is
the final nail in its coffin. The trait and the corresponding method are not
being removed as part of this commit, but rather any implementations of the
`ToStr` trait are being forbidden because of the generic impl. The new way to
get the `to_str()` method to work is to implement `fmt::Show`.

Formatting into a `&mut Writer` (as `format!` does) is much more efficient than
`ToStr` when building up large strings. The `ToStr` trait forces many
intermediate allocations to be made while the `fmt::Show` trait allows
incremental buildup in the same heap allocated buffer. Additionally, the
`fmt::Show` trait is much more extensible in terms of interoperation with other
`Writer` instances and in more situations. By design the `ToStr` trait requires
at least one allocation whereas the `fmt::Show` trait does not require any
allocations.

Closes #8242
Closes #9806
2014-02-23 20:51:56 -08:00
bors
3c2650b4d5 auto merge of #12328 : nick29581/rust/abi, r=alexcrichton 2014-02-23 19:26:53 -08:00
bors
7cc6b5e0a3 auto merge of #12510 : huonw/rust/fix-compiler-docs, r=alexcrichton
This includes blocks made by indentation, so they need to be changed to
explicitly have ```notrust ... ``` fences..
2014-02-23 18:06:54 -08:00
Huon Wilson
b48833d6db Update rustc/syntax docs now that rustdoc lexes all non-notrust code blocks.
This includes blocks made by indentation, so they need to be changed to
explicitly have ```notrust ... ``` fences..
2014-02-24 12:35:57 +11:00
Nick Cameron
317a253b22 All uses of extern fn should mean extern "C" fn. Closes #9309. 2014-02-24 13:24:57 +13:00
bors
329fcd48e5 auto merge of #12338 : edwardw/rust/hygienic-break-continue, r=cmr
Makes labelled loops hygiene by performing renaming of the labels defined in e.g. `'x: loop { ... }` and then used in break and continue statements within loop body so that they act hygienically when used with macros.
    
Closes #12262.
2014-02-23 15:37:05 -08:00
Huon Wilson
efaf4db24c Transition to new Hash, removing IterBytes and std::to_bytes. 2014-02-24 07:44:10 +11:00
Huon Wilson
06e3e63c90 flate: return CVec<u8> rather than copying into a new vector.
This trades an O(n) allocation + memcpy for a O(1) proc allocation (for
the destructor). Most users only need &[u8] anyway (all of the users in
the main repo), and so this offers large gains.
2014-02-24 01:15:39 +11:00
Edward Wang
386db05df8 Make break and continue hygienic
Makes labelled loops hygiene by performing renaming of the labels
defined in e.g. `'x: loop { ... }` and then used in break and continue
statements within loop body so that they act hygienically when used with
macros.

Closes #12262.
2014-02-23 21:20:37 +08:00
Huon Wilson
5444da54fd Register snapshots. 2014-02-23 22:50:17 +11:00
bors
551da06157 auto merge of #12311 : brson/rust/unstable, r=alexcrichton
With the stability attributes we can put public-but unstable modules next to others, so this moves `intrinsics` and `raw` out of the `unstable` module (and marks both as `#[experimental]`).
2014-02-23 02:21:53 -08:00
Brian Anderson
3e57808a01 std: Move raw to std::raw
Issue #1457
2014-02-23 01:07:53 -08:00
Alex Crichton
2a14e084cf Move std::{trie, hashmap} to libcollections
These two containers are indeed collections, so their place is in
libcollections, not in libstd. There will always be a hash map as part of the
standard distribution of Rust, but by moving it out of the standard library it
makes libstd that much more portable to more platforms and environments.

This conveniently also removes the stuttering of 'std::hashmap::HashMap',
although 'collections::HashMap' is only one character shorter.
2014-02-23 00:35:11 -08:00
bors
edf351e9f7 auto merge of #12451 : edwardw/rust/ident-2-name, r=cmr
Closes #7743.
2014-02-22 22:01:54 -08:00
bors
4995a85f40 auto merge of #12448 : alexcrichton/rust/smaller-rust, r=brson
Two optimizations:

1. Compress `foo.bc` in each rlib with `flate`. These are just taking up space and are only used with LTO, no need for LTO to be speedy.
2. Stop install `librustc.rlib` and friends, this is a *huge* source of bloat. There's no need for us to install static libraries for these components.

cc #12440
2014-02-22 17:46:53 -08:00
bors
22d3669b9e auto merge of #11863 : erickt/rust/hash, r=acrichto
This PR merges `IterBytes` and `Hash` into a trait that allows for generic non-stream-based hashing. It makes use of @eddyb's default type parameter support in order to have a similar usage to the old `Hash` framework.

Fixes #8038.

Todo:

- [x] Better documentation
- [ ] Benchmark
- [ ] Parameterize `HashMap` on a `Hasher`.
2014-02-22 15:01:58 -08:00
bors
2ba0a8a096 auto merge of #11603 : alexcrichton/rust/issue-11591, r=brson
This prevents linker errors as found in #11591

Closes #11591
2014-02-22 11:41:48 -08:00
Alex Crichton
351d0ffaa1 Force all lang items to be reachable
This prevents linker errors as found in #11591

Closes #11591
2014-02-22 10:29:06 -08:00
bors
eb5ba4d269 auto merge of #12366 : aepsil0n/rust/feature/unnecessary_parens_around_assigned_values, r=alexcrichton
Fixes #12350.

Parentheses around assignment statements such as

```rust
let mut a = (0);
a = (1);
a += (2);
```

are not necessary and therefore an unnecessary_parens warning is raised when
statements like this occur.

NOTE: In `let` declarations this does not work as intended. Is it possible that they do not count as assignment expressions (`ExprAssign`)? (edit: this is fixed by now)

Furthermore, there are some cases that I fixed in the rest of the code, where parentheses could potentially enhance readability. Compare these lines:

```rust
a = b == c;
a = (b == c);
```

Thus, after having worked on this I'm not entirely sure, whether we should go through with this patch or not. Probably a matter of debate. ;)
2014-02-22 10:26:46 -08:00
bors
87e3b5fe7f auto merge of #12441 : kud1ing/rust/backticks, r=brson
Not all of those messages are covered by tests. I am not sure how to trigger them and where to put those tests.

Also some message patterns in the existing tests are not complete.
For example, i find `error: mismatched types: expected "i32" but found "char" (expected i32 but found char)` a bit repetitive, but as i can see there is no test covering that.
2014-02-22 09:11:47 -08:00
Eduard Bopp
9982de6397 Warn about unnecessary parentheses upon assignment
Closes #12366.

Parentheses around assignment statements such as

    let mut a = (0);
    a = (1);
    a += (2);

are not necessary and therefore an unnecessary_parens warning is raised when
statements like this occur.

The warning mechanism was refactored along the way to allow for code reuse
between the routines for checking expressions and statements.

Code had to be adopted throughout the compiler and standard libraries to comply
with this modification of the lint.
2014-02-22 16:32:48 +01:00
Erick Tryzelaar
d223dd1e57 std: rewrite Hash to make it more generic
This patch merges IterBytes and Hash traits, which clears up the
confusion of using `#[deriving(IterBytes)]` to support hashing.
Instead, it now is much easier to use the new `#[deriving(Hash)]`
for making a type hashable with a stream hash.

Furthermore, it supports custom non-stream-based hashers, such as
if a value's hash was cached in a database.

This does not yet replace the old IterBytes-hash with this new
version.
2014-02-21 21:33:23 -08:00
bors
56cf237ee2 auto merge of #12411 : Arcterus/rust/time, r=alexcrichton
More work towards finishing #8784.
2014-02-21 19:46:51 -08:00
bors
d2f73abf10 auto merge of #12382 : bjz/rust/fmt-int, r=alexcrichton
This is PR is the beginning of a complete rewrite and ultimate removal of the `std::num::strconv` module (see #6220), and the removal of the `ToStrRadix` trait in favour of using the `std::fmt` functionality directly. This should make for a cleaner API, encourage less allocation, and make the implementation more comprehensible .

The `Formatter::{pad_integral, with_padding}` methods have also been refactored make things easier to understand.

The formatting tests for integers have been moved out of `run-pass/ifmt.rs` in order to provide more immediate feedback when building using `make check-stage2-std NO_REBUILD=1`.

Arbitrary radixes are now easier to use in format strings. For example:

~~~rust
assert_eq!(format!("{:04}", radix(3, 2)), ~"0011");
~~~

The benchmarks have been standardised between `std::num::strconv` and `std::num::fmt` to make it easier to compare the performance of the different implementations.

~~~
 type | radix | std::num::strconv      | std::num::fmt
======|=======|========================|======================
 int  | bin   | 1748 ns/iter (+/- 150) | 321 ns/iter (+/- 25)
 int  | oct   |  706 ns/iter (+/- 53)  | 179 ns/iter (+/- 22)
 int  | dec   |  640 ns/iter (+/- 59)  | 207 ns/iter (+/- 10)
 int  | hex   |  637 ns/iter (+/- 77)  | 205 ns/iter (+/- 19)
 int  | 36    |  446 ns/iter (+/- 30)  | 309 ns/iter (+/- 20)
------|-------|------------------------|----------------------
 uint | bin   | 1724 ns/iter (+/- 159) | 322 ns/iter (+/- 13)
 uint | oct   |  663 ns/iter (+/- 25)  | 175 ns/iter (+/- 7)
 uint | dec   |  613 ns/iter (+/- 30)  | 186 ns/iter (+/- 6)
 uint | hex   |  519 ns/iter (+/- 44)  | 207 ns/iter (+/- 20)
 uint | 36    |  418 ns/iter (+/- 16)  | 308 ns/iter (+/- 32)
~~~
2014-02-21 16:36:52 -08:00
Edward Wang
7607332805 Represent lifetimes as Names instead of Idents
Closes #7743.
2014-02-22 04:05:33 +08:00
Alex Crichton
991d466c18 rustc: Compress bytecode files in rlibs
These are only ever used with LTO, so there's no need for reading them to be
speedy.
2014-02-21 10:54:00 -08:00
Brendan Zabarauskas
6943acd1a5 Reduce reliance on to_str_radix
This is in preparation to remove the implementations of ToStrRadix in integers, and to remove the associated logic from `std::num::strconv`.

The parts that still need to be liberated are:

- `std::fmt::Formatter::runplural`
- `num::{bigint, complex, rational}`
2014-02-22 03:56:16 +11:00
Arcterus
66f93291ec Move time out of extra (cc #8784) 2014-02-21 07:44:11 -08:00
bors
c6aaf2c7bd auto merge of #12419 : huonw/rust/compiler-unsafe, r=alexcrichton
Previously an `unsafe` block created by the compiler (like those in the
formatting macros) would be "ignored" if surrounded by `unsafe`, that
is, the internal unsafety would be being legitimised by the external
block:

    unsafe { println!("...") } =(expansion)=> unsafe { ... unsafe { ... } }

And the code in the inner block would be using the outer block, making
it considered used (and the inner one considered unused).

This patch forces the compiler to create a new unsafe context for
compiler generated blocks, so that their internal unsafety doesn't
escape to external blocks.

Fixes #12418.
2014-02-21 07:06:51 -08:00
bors
2fa7d6b44f auto merge of #12415 : HeroesGrave/rust/move-enum-set, r=alexcrichton
Part of #8784

Also removed the one glob import.
2014-02-21 05:26:58 -08:00
kud1ing
766e138aa2 backticks 2014-02-21 08:26:20 +01:00
mr.Shu
70319f7b25 Changed NonCamelCaseTypes lint to warn by default
Added allow(non_camel_case_types) to librustc where necesary

Tried to fix problems with non_camel_case_types outside rustc

fixed failing tests

Docs updated

Moved #[allow(non_camel_case_types)] a level higher.

markdown.rs reverted

Fixed timer that was failing tests

Fixed another timer
2014-02-21 08:11:52 +01:00
bors
d70f909fa3 auto merge of #12164 : alexcrichton/rust/rlibs-and-dylibs, r=cmr
The first commit improves error messages during linking, and the second commit improves error messages during crate-loading time.

Closes #12297
Closes #12377
2014-02-20 18:51:57 -08:00
Alex Crichton
afa5f574ff Re-work loading crates with nicer errors
This commit rewrites crate loading internally in attempt to look at less
metadata and provide nicer errors. The loading is now split up into a few
stages:

1. Collect a mapping of (hash => ~[Path]) for a set of candidate libraries for a
   given search. The hash is the hash in the filename and the Path is the
   location of the library in question. All candidates are filtered based on
   their prefix/suffix (dylib/rlib appropriate) and then the hash/version are
   split up and are compared (if necessary).

   This means that if you're looking for an exact hash of library you don't have
   to open up the metadata of all libraries named the same, but also in your
   path.

2. Once this mapping is constructed, each (hash, ~[Path]) pair is filtered down
   to just a Path. This is necessary because the same rlib could show up twice
   in the path in multiple locations. Right now the filenames are based on just
   the crate id, so this could be indicative of multiple version of a crate
   during one crate_id lifetime in the path. If multiple duplicate crates are
   found, an error is generated.

3. Now that we have a mapping of (hash => Path), we error on multiple versions
   saying that multiple versions were found. Only if there's one (hash => Path)
   pair do we actually return that Path and its metadata.

With this restructuring, it restructures code so errors which were assertions
previously are now first-class errors. Additionally, this should read much less
metadata with lots of crates of the same name or same version in a path.

Closes #11908
2014-02-20 17:48:32 -08:00
bors
7e9bcc5456 auto merge of #12401 : alexcrichton/rust/if-ok-2-try, r=brson
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 16:56:51 -08:00
Alex Crichton
7bb498bd7a Mass rename if_ok! to try!
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 09:16:52 -08:00
bors
1366e04cf4 auto merge of #12405 : kud1ing/rust/backticks, r=huonw 2014-02-20 08:21:45 -08:00
bors
06e1281198 auto merge of #12403 : eddyb/rust/generic-dtors-with-bounds, r=nikomatsakis
Fix generic Drop impls with trait bounds.
Fixes #4252.
2014-02-20 07:06:49 -08:00
bors
5f324aaf20 auto merge of #12399 : michaelwoerister/rust/simd-fix, r=alexcrichton
Fixes  #12333.
I also re-enabled the *function-arg-initialization* test case, so if it passes again, fixes #12021.
2014-02-20 05:46:48 -08:00
bors
882c25fa2d auto merge of #12398 : alexcrichton/rust/rlibs-and-dylibs-2, r=cmr
The new methodology can be found in the re-worded comment, but the gist of it is
that -C prefer-dynamic doesn't turn off static linkage. The error messages
should also be a little more sane now.

Closes #12133
2014-02-20 04:31:49 -08:00
Huon Wilson
5ec118383b rustc: avoid compiler generated unsafe blocks leaking.
Previously an `unsafe` block created by the compiler (like those in the
formatting macros) would be "ignored" if surrounded by `unsafe`, that
is, the internal unsafety would be being legitimised by the external
block:

    unsafe { println!("...") } =(expansion)=> unsafe { ... unsafe { ... } }

And the code in the inner block would be using the outer block, making
it considered used (and the inner one considered unused).

This patch forces the compiler to create a new unsafe context for
compiler generated blocks, so that their internal unsafety doesn't
escape to external blocks.

Fixes #12418.
2014-02-20 23:29:57 +11:00
Liigo Zhuang
53b9d1a324 move extra::test to libtest 2014-02-20 16:03:58 +08:00
HeroesGrave
5bf8d3289f move enum_set to libcollections. #8784 2014-02-20 19:38:01 +13:00
bors
0cc8ba0c20 auto merge of #12244 : pcwalton/rust/deuniquevectorpatterns, r=pcwalton
Preparatory work for removing unique vectors from the language, which is
itself preparatory work for dynamically sized types.

r? @brson
2014-02-19 21:56:51 -08:00
bors
801f8f67f8 auto merge of #12394 : huonw/rust/transmute--, r=pnkfelix
These can all be done by implicit or explicit &T -> *T casts, which are
more restricted and so are safer.
2014-02-19 20:41:51 -08:00
Patrick Walton
33923f47e3 librustc: Remove unique vector patterns from the language.
Preparatory work for removing unique vectors from the language, which is
itself preparatory work for dynamically sized types.
2014-02-19 16:35:31 -08:00
bors
879e8aa7be auto merge of #12387 : cmr/rust/ast-json, r=alexcrichton
See the commits
2014-02-19 16:21:48 -08:00
Eduard Burtescu
efaa1ea979 Resolve the vtables for method calls to generic Drop impls with trait bounds. 2014-02-20 00:12:09 +02:00
kud1ing
4ad57513f4 adjust to currently used style 2014-02-19 22:38:15 +01:00
Eduard Burtescu
efef078cfa Replaced method_map_entry with method_origin and cleaned up vtable checking a bit. 2014-02-19 23:26:40 +02:00
Eduard Burtescu
1ca1ff23d3 Don't recurse twice into ExprParen in vtable checking. 2014-02-19 23:26:40 +02:00
Corey Richardson
34ffe3cc1c rustc: support dumping the AST as JSON
This is mostly useful for working on rustc, when one is unfamiliar with the
AST a particular construct will produce. It's a -Z flag as it's very much for
debugging.

Closes #10485
2014-02-19 13:32:26 -05:00
bors
209b47f248 auto merge of #12379 : alexcrichton/rust/fix-ar-thing, r=brson
When creating a staticlib, it unzips all static archives it finds and then
inserts the files manually into the output file. This process is done through
`ar`, and `ar` doesn't like if you specify you want to add files and you don't
give it any files.

This case arose whenever you linked to an archive that didn't have any contents
or all of the contents were filtered out. This just involved ignoring the case
where the number of inputs we have is 0, because we don't have any files to add
anyway.
2014-02-19 10:21:50 -08:00
Alex Crichton
35c6e22fab Tweak how preference factors into linkage
The new methodology can be found in the re-worded comment, but the gist of it is
that -C prefer-dynamic doesn't turn off static linkage. The error messages
should also be a little more sane now.

Closes #12133
2014-02-19 08:33:08 -08:00
Michael Woerister
5f9e32ad68 debuginfo: Add support for simd types 2014-02-19 17:12:37 +01:00
Huon Wilson
dcee327c35 rustc: remove some unnecessary transmutes.
These can all be done by implicit or explicit &T -> *T casts, which are
more restricted and so are safer.
2014-02-20 01:31:39 +11:00