Commit Graph

4114 Commits

Author SHA1 Message Date
Brian Anderson
6f7ef1e293 rustc: Fix tests for sysroot changes 2014-03-26 20:53:01 -07:00
Brian Anderson
545f012527 rustc: Fix detection of lib64 directory
Instead of just looking for its presence we need to see if it actually
contains rust stuffs.
2014-03-26 19:21:23 -07:00
bors
c83994e0f4 auto merge of #13145 : alexcrichton/rust/flip-some-defaults, r=brson
This change prepares `rustc` to accept private fields by default. These changes will have to go through a snapshot before the rest of the changes can happen.
2014-03-26 16:37:03 -07:00
Kiet Tran
1d99d37f87 Visit type parameter in lifetime suggestion
Previously, Rebuilder did not visit type parameters when rebuilding
generics and path, so in some cases the suggestion turns out to be
erroneous.
2014-03-26 19:13:30 -04:00
bors
2c71cdf64b auto merge of #13071 : ktt3ja/rust/deterministic-lifetime-suggestion, r=cmr
Close #13057
2014-03-26 10:26:55 -07:00
Alex Crichton
7de48419ee syntax: Permit visibility on tuple fields
This change is in preparation for #8122. Nothing is currently done with these
visibility qualifiers, they are just parsed and accepted by the compiler.

RFC: 0004-private-fields
2014-03-26 10:20:15 -07:00
Alex Crichton
104aaa44e8 rustc: Relax restriction on privacy for fields
This is a necessary change in preparation for switching the defaults as part
of #8122.

RFC: 0004-private-fields
2014-03-26 10:20:12 -07:00
Felix S. Klock II
ab8e02616c Fix Repr impl for method::Candidate to include the method_ty. 2014-03-26 17:57:02 +01:00
Felix S. Klock II
6b5ca8b1aa Fix #13140: Early/Late Bound related ICEs.
The problem was that we need to apply the substitution, so that the
formal lifetime parameters get replaced with (unifiable)
free-lifetimes that can actually be fed into the constraint solver.

Also, refactor code os that substitution for `check_item` and
`check_method`, moving both down the control flow into `check_bare_fn`.

----

Finally, there was another (similar) spot where we needed to
substitute early-bound lifetimes when invoking an object method of a
trait.
2014-03-26 17:54:49 +01:00
bors
de85948ac0 auto merge of #13117 : alexcrichton/rust/no-crate-map, r=brson
This can be done now that logging has been moved out and libnative is the default (not libgreen)
2014-03-26 01:41:57 -07:00
Brian Anderson
ce1e48a52b install: Support --libdir and --mandir correctly
This adds a hack to rustc to make it find the library directory
regardless of whether it is named lib/lib64/lib32.
2014-03-25 23:57:39 -07:00
Brian Anderson
d252539990 mk: Rename CFG_COMPILER to CFG_COMPILER_HOST_TRIPLE
Much clearer
2014-03-25 21:35:10 -07:00
Brian Anderson
f772e31d64 rustc: Stop relying on CFG_LIBDIR_RELATIVE
This is not sufficient for finding the library directory for binary
installs, but it does make the build more complex by requiring
env vars be set to build rustc.
2014-03-25 21:35:10 -07:00
Brian Anderson
6f9b30c6c1 configure: Make rustlibdir non-configurable
Trying to reduce the complexity of installation
2014-03-25 21:35:10 -07:00
Marvin Löbel
6200e761f0 Changed iter::Extendable and iter::FromIterator to take a Iterator by value 2014-03-25 21:49:55 +01:00
bors
1f5571abc2 auto merge of #13122 : sstewartgallus/rust/cleanup-10734-workarounds, r=alexcrichton
Cleanup old issue references. One of these workarounds no longer need to be used anymore and the others are out of date.
2014-03-25 06:36:55 -07:00
bors
5d5634ace0 auto merge of #13083 : FlaPer87/rust/issue-13005-borrow-unsafe-static, r=nikomatsakis
It was possible to borrow unsafe static items in static initializers.
This patch implements a small `Visitor` that walks static initializer's
expressions and checks borrows aliasability.

Fixes #13005

cc @nikomatsakis r?
2014-03-25 03:01:48 -07:00
Steven Stewart-Gallus
451160fbfa Cleanup fixed issue #10734 workaround 2014-03-24 16:10:20 -07:00
Kiet Tran
19d913bf25 Prefer lifetime suggestion over generic error 2014-03-24 18:58:37 -04:00
Alex Crichton
3ccad75641 rustc: Remove all crate map support
The crate map is no longer necessary now that logging and event loop factories
have been moved out.

Closes #11617
Closes #11731
2014-03-24 11:19:28 -07:00
Flavio Percoco
9021a3f988 rustc: Completely forbid borrows of unsafe statics
Summary:
It was possible to borrow unsafe static items in static initializers.
This patch implements a small `Visitor` that walks static initializer's
expressions and checks borrows aliasability.

Fixes #13005

Test Plan: make check

Differential Revision: http://phabricator.octayn.net/D2
2014-03-24 18:04:10 +01:00
bors
841f31ecf9 auto merge of #13074 : pczarn/rust/build-rlib, r=alexcrichton
Fixes #12992

I tried to increase the number of deflate's probes. Reduction of 0.5% or 2% is not enough.
2014-03-23 14:01:52 -07:00
bors
cafb7ed6f6 auto merge of #13099 : FlaPer87/rust/master, r=huonw 2014-03-23 07:21:55 -07:00
Piotr Czarnecki
f0f5072566 rustc: Change the filename of compressed bitcode
Fixes #12992
Store compressed bitcode files in rlibs with a different extension. Compression doesn't interfere with --emit=bc.
Regression test compares outputs.
2014-03-23 13:36:49 +01:00
Flavio Percoco
576e36e674 Register new snapshots 2014-03-23 11:37:31 +01:00
bors
11c6817e13 auto merge of #13090 : thestinger/rust/iter, r=Aatch
This has been rendered obsolete by partial type hints. Since the `~[T]`
type is in the process of being removed, it needs to go away.
2014-03-23 02:41:53 -07:00
Daniel Micay
ae429056ff iter: remove to_owned_vec
This needs to be removed as part of removing `~[T]`. Partial type hints
are now allowed, and will remove the need to add a version of this
method for `Vec<T>`. For now, this involves a few workarounds for
partial type hints not completely working.
2014-03-23 05:41:23 -04:00
Daniel Micay
3829ac2a52 use TotalEq for HashMap
Closes #5283
2014-03-23 01:59:11 -04:00
bors
94e4e91724 auto merge of #13087 : eddyb/rust/fix-autoderef, r=cmr
Implements vtable support for generic Deref impls with trait bounds.
Also fixes cross-crate inlining when using autoderef.
2014-03-22 17:21:51 -07:00
Eduard Burtescu
087ec2aa24 Implement cross-crate support for autoderef.
Closes #13044.
2014-03-23 01:11:39 +02:00
bors
e68550e7ac auto merge of #13085 : edwardw/rust/saddest-cell, r=cmr 2014-03-22 16:06:51 -07:00
Eduard Burtescu
75d7d5210a Implement vtable support for autoderef.
Closes #13042.
2014-03-22 23:31:42 +02:00
bors
7e7a5e3d3e auto merge of #13076 : FlaPer87/rust/remove-freeze, r=alexcrichton
This PR removes the `Freeze` kind and the `NoFreeze` marker completely.

Fixes #12577

cc @nikomatsakis r?
2014-03-22 13:01:52 -07:00
Edward Wang
7c3ed86e5a Get rid of @Cell 2014-03-23 02:53:35 +08:00
Alex Crichton
3fb1ed0e04 rustc: Remove all usage of manual deref()
Favor using '*' instead
2014-03-22 08:48:34 -07:00
Alex Crichton
0dbb909bf7 rustc: Fix fallout of removing get() 2014-03-22 08:48:20 -07:00
Flavio Percoco
a1cb2f5d8c doc: Remove Freeze / NoFreeze from docs 2014-03-22 15:47:34 +01:00
Flavio Percoco
aa7519400e rustc: Remove special treatment for Freeze and NoFreeze
Fixes #12577
2014-03-22 15:44:13 +01:00
bors
30165e059c auto merge of #13052 : sfackler/rust/clean-refcell, r=alexcrichton
These are superfluous now that we have fixed rvalue lifetimes and Deref.

I'd also like to kill off `get` and `set`, but that'll be a large change so I want to make sure that we actually want to do that first.
2014-03-22 04:56:49 -07:00
bors
069cede305 auto merge of #13036 : alexcrichton/rust/atomics, r=alexcrichton
Closes #11583, rebasing of #12430 now that we've got `Share` and better analysis with statics.
2014-03-21 21:31:42 -07:00
bors
f5357cf3ce auto merge of #13016 : huonw/rust/new-opt-vec, r=cmr
Replace syntax::opt_vec with syntax::owned_slice

The `owned_slice::OwnedSlice` is  `(*T, uint)` (i.e. a direct equivalent to DSTs `~[T]`).

This shaves two words off the old OptVec type; and also makes substituting in other implementations easy, by removing all the mutation methods. (And also everything that's very rarely/never used.)
2014-03-21 20:06:44 -07:00
Huon Wilson
e33676b793 Migrate all users of opt_vec to owned_slice, delete opt_vec.
syntax::opt_vec is now entirely unused, and so can go.
2014-03-22 09:54:18 +11:00
Alex Crichton
ab1dd09d73 rustc: Switch defaults from libgreen to libnative
The compiler will no longer inject libgreen as the default runtime for rust
programs, this commit switches it over to libnative by default. Now that
libnative has baked for some time, it is ready enough to start getting more
serious usage as the default runtime for rustc generated binaries.

We've found that there isn't really a correct decision in choosing a 1:1 or M:N
runtime as a default for all applications, but it seems that a larger number of
programs today would work more reasonable with a native default rather than a
green default.

With this commit come a number of bugfixes:

* The main native task is now named "<main>"
* The main native task has the stack bounds set up properly
* #[no_uv] was renamed to #[no_start]
* The core-run-destroy test was rewritten for both libnative and libgreen and
  one of the tests was modified to be more robust.
* The process-detach test was locked to libgreen because it uses signal handling
2014-03-21 12:03:13 -07:00
Patrick Walton
af79a5aa7d test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-21 23:37:21 +11:00
Steven Fackler
181875ca50 Remove RefCell::{with, with_mut}
These are superfluous now that we have fixed rvalue lifetimes and Deref.
2014-03-20 19:55:52 -07:00
Huon Wilson
7785fe1916 syntax: make OptVec immutable.
This is the first step to replacing OptVec with a new representation:
remove all mutability. Any mutations have to go via `Vec` and then make
to `OptVec`.

Many of the uses of OptVec are unnecessary now that Vec has no-alloc
emptiness (and have been converted to Vec): the only ones that really
need it are the AST and sty's (and so on) where there are a *lot* of
instances of them, and they're (mostly) immutable.
2014-03-21 10:52:48 +11:00
Brian Anderson
eb25c42fc8 std: Make the generic atomics take unsafe pointers
These mutate values behind references that are Freeze, which is not
allowed.
2014-03-20 13:33:43 -07:00
Alex Crichton
11ac4df4d2 Register new snapshots 2014-03-20 11:02:26 -07:00
bors
b568efc0cf auto merge of #13020 : alexcrichton/rust/vec, r=brson
The commits have the details.
2014-03-20 09:51:44 -07:00
Brian Anderson
f3fef9a649 std: Make atomics immutable. #11583
In Rust, the strongest guarantee that `&mut` provides is that the memory
pointed to is *not aliased*, whereas `&`'s guarantees are much weaker:
that the value can be aliased, and may be mutated under proper precautions
(interior mutability).

Our atomics though use `&mut` for mutation even while creating multiple
aliases, so this changes them to use 'interior mutability', mutating
through immutable references.
2014-03-20 09:44:29 -07:00
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