Commit Graph

2037 Commits

Author SHA1 Message Date
Alex Crichton
b29c368674 Removing a lot of usage of '&const' 2013-06-29 08:35:48 -07:00
Corey Richardson
71b1c6ab60 Warning cleanup 2013-06-29 11:20:04 -04:00
Corey Richardson
95d22a3c81 Fix merge fallout 2013-06-29 11:20:04 -04:00
Corey Richardson
1662bd371c Great renaming: propagate throughout the rest of the codebase 2013-06-29 11:20:02 -04:00
Björn Steinbrink
2a40c5db46 Avoid extra casts for "self" arguments
"self" is always passed as an opaque box, so there's no point in using
the concrete self type when translating the argument. All it does it
causing the value to be casted back to an opaque box right away.
2013-06-29 17:08:20 +02:00
Björn Steinbrink
08a5278bb5 Add missing argument to a debug! call in trans_arg_expr 2013-06-29 15:59:33 +02:00
bors
132cfcdd88 auto merge of #7363 : bblum/rust/soundness, r=nikomatsakis
The commit f9a5453 is meant to be a temporary hold-over. Whether or not there is added a way for the compiler to "implicitly borrow" stack closures in this way, there should be a codegen optimization that prevents having to traverse possibly-very-many function pointers to find the function you ultimately wanted to call. I tried to separate out the changes so this particular commit could be straight-up reverted if auto-borrowing happens in the future.

r? @nikomatsakis
2013-06-29 04:22:53 -07:00
bors
c80e3bac3e auto merge of #7244 : bblum/rust/once, r=nikomatsakis
@graydon suggested that once closures not be part of the language for 1.0, but that they might be hidden behind a -Z compile flag as an "experimental feature" in case people decide they need them.

Regardless of whether ```-Z once-fns``` is set, this PR will parse the ```once``` keyword and will prevent closures labelled with it from being called more than once. It will also permit moving out of captured vars in heap closures, just to let the runtime writers stop using ```Cell``` sooner. Setting ```-Z once-fns``` only toggles whether the move-out-from-capture privilege is also given for stack closures.

r? @nikomatsakis
2013-06-29 02:34:43 -07:00
Ben Blum
d4722e5333 Trade stack closure copyability for type soundness. 2013-06-29 04:39:37 -04:00
Ben Blum
ff4ab9e147 'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep for making them noncopyable. 2013-06-29 04:39:34 -04:00
Ben Blum
89110fdf55 Use more deriving(IterBytes) in librustc. 2013-06-29 03:58:50 -04:00
bors
4e78c1e2a8 auto merge of #7479 : mozilla/rust/rollup, r=thestinger
22b7eb3 r=thestinger 
28a3613 r=cmr
a0c31ec r=bstrie
ee7307e r=thestinger
b9cf6a3 r=thestinger
2013-06-28 22:25:48 -07:00
Young-il Choi
21cc0ccea1 librustc: fix #7467 for android 2013-06-29 01:22:35 -04:00
Brian Anderson
22b7eb3802 Rename #[mutable] to #[no_freeze] 2013-06-29 00:56:36 -04:00
Brian Anderson
4af7ebcd8f Rename #[non_sendable] to #[no_send] 2013-06-29 00:56:36 -04:00
bors
d681bccb6a auto merge of #7471 : msullivan/rust/default-methods, r=graydon
This fixes a bunch of default method bugs and restructures how vtable resolutions are represented.

(It also adds a depth counter to llvm::type_to_str as a hacky work around for our circular llvm types. This is related in the sense that I needed to do it to make debug tracing not cause rustc to crash after running out of stack space.)
2013-06-28 20:16:56 -07:00
Michael Sullivan
c05165bf93 Drop the impl_id field from fn_ctxt. 2013-06-28 18:09:02 -07:00
Michael Sullivan
5943118728 Drop an unused field from param_substs. 2013-06-28 18:09:02 -07:00
Michael Sullivan
0252693db2 Improve handling of trait bounds on a trait in default methods.
This is work on #7460.
It does not properly handle certain cross crate situations,
because we don't properly export vtable resolution information.
2013-06-28 18:09:02 -07:00
bors
e23934645a auto merge of #7466 : thestinger/rust/passes, r=cmr 2013-06-28 16:49:49 -07:00
Michael Sullivan
649b26f7c6 Rework vtable_res to not be flattened. It is now a list of the resolutions for each param. 2013-06-28 16:12:08 -07:00
Michael Sullivan
57ee34c2bf Actually resolve trait bounds on impls. Closes #7266. 2013-06-28 16:12:08 -07:00
Michael Sullivan
817f98085f Make calling methods parameterized on the trait work from default methods.
This is done by adding a new notion of "vtable_self".
We do not yet properly handle super traits.

Closes #7183.
2013-06-28 16:12:08 -07:00
Michael Sullivan
a9e51f5f70 Make default method handling not choke on self region params. Closes #7341. 2013-06-28 16:12:08 -07:00
Michael Sullivan
050d0e6b29 Add a depth counter to llvm::type_to_str to work around infinite llvm types. 2013-06-28 16:12:04 -07:00
Michael Sullivan
47afb33981 Add Float to llvm::type_to_str. 2013-06-28 16:12:04 -07:00
Daniel Micay
2bdc88b652 copy the optimization passes from clang 2013-06-28 18:18:09 -04:00
Philipp Brüschweiler
a2227f9e0c librustc: don't skip ahead when computing register types of SSEFloatVectors
Also fixes an unrelated typo (found by comparing to the original code
of the clay project) and some cleanup.

Fixes #7415.
2013-06-28 21:28:58 +02:00
James Miller
fae4a9e5ba Rename Const/Owned in more places 2013-06-28 10:47:59 -04:00
Patrick Walton
10bcb60e8f librustc: Fix even *MORE* merge fallout! 2013-06-28 10:47:59 -04:00
Patrick Walton
f25f466afe librustc: Fix even *more* merge fallout! 2013-06-28 10:47:59 -04:00
Patrick Walton
3625781cfe librustc: Fix more merge fallout. 2013-06-28 10:44:17 -04:00
Patrick Walton
bb830558d1 librustc: Fix merge fallout and test cases. 2013-06-28 10:44:17 -04:00
Patrick Walton
e015bee286 Rewrite each_path to allow performance improvements in the future.
Instead of determining paths from the path tag, we iterate through
modules' children recursively in the metadata. This will allow for
lazy external module resolution.
2013-06-28 10:44:16 -04:00
Patrick Walton
89eb995195 librustc: Fix merge fallout. 2013-06-28 10:44:16 -04:00
Patrick Walton
03ab6351cc librustc: Rewrite reachability and forbid duplicate methods in type implementations.
This should allow fewer symbols to be exported.
2013-06-28 10:44:16 -04:00
Patrick Walton
a1531ed946 librustc: Remove the broken overloaded assign-ops from the language.
They evaluated the receiver twice. They should be added back with
`AddAssign`, `SubAssign`, etc., traits.
2013-06-28 10:44:16 -04:00
Patrick Walton
f463e69d20 librustc: Add a small vector optimization for GEPi. Shaves a second off trans, I think? 2013-06-28 10:44:15 -04:00
Patrick Walton
f9b54541ee librustc: Disallow "mut" from distributing over bindings.
This is the backwards-incompatible part of per-binding-site "mut".
2013-06-28 10:44:15 -04:00
Patrick Walton
1c0aa78481 librustc: Change "Owned" to "Send" everywhere 2013-06-28 10:44:15 -04:00
Patrick Walton
1eec3bba13 librustc: Rename Const to Freeze 2013-06-28 10:44:15 -04:00
Patrick Walton
d350981c0e librustc: Change Const to Freeze in the compiler 2013-06-28 10:44:15 -04:00
Patrick Walton
607b91d5f9 librustc: Rename Owned to Send in the compiler 2013-06-28 10:44:07 -04:00
bors
811e045c60 auto merge of #7426 : thestinger/rust/zero-size-noncopyable, r=catamorphism
4885918 r=huonw
42a63fc r=thestinger
7ec5a08 r=catamorphism
fb1e5f1 r=thestinger
659cd55 r=cmr
2013-06-28 05:28:32 -07:00
bors
8600c18812 auto merge of #7272 : Aatch/rust/namegen_thunk, r=thestinger
This removes the `namegen` thunk that was in `common.rs`. I also take the opportunity to refactor a few uses where we had a `str -> ident -> str` chain that seemed somewhat redundant to me.

Also cleans up some warnings that made their way in already.
2013-06-28 01:01:52 -07:00
James Miller
a897a9ab9f Remove useless namegen thunk 2013-06-28 18:00:20 +12:00
Birunthan Mohanathas
dcf1dc060a Rename #[no_drop_flag] to #[unsafe_no_drop_flag] 2013-06-27 23:20:42 -04:00
bors
61dc7760d0 auto merge of #7410 : luqmana/rust/bare-self, r=catamorphism
Finally sorted this out. Fixes #5321, #4439, and #4850.
2013-06-27 20:19:38 -07:00
Luqman Aden
767374976b librustc: Always pass self ByRef. 2013-06-27 21:36:30 -04:00
bors
927f454ac1 auto merge of #7432 : michaelwoerister/rust/WP3, r=jdm 2013-06-27 17:22:42 -07:00
bors
63afb8ccc8 auto merge of #7430 : huonw/rust/vec-kill, r=thestinger 2013-06-27 15:01:58 -07:00
Michael Woerister
2f5e33d02f debuginfo: Some corrections after review. 2013-06-27 19:28:37 +02:00
Michael Woerister
6af78610e7 debuginfo: Added support for region pointers. 2013-06-27 19:28:37 +02:00
Michael Woerister
46d28c874c debuginfo: Replaced many instances of @ with &. 2013-06-27 19:28:17 +02:00
Michael Woerister
4d8f2fd871 debuginfo: Many little formatting improvements. 2013-06-27 19:28:17 +02:00
Michael Woerister
7bb189e56c Fixed debug information bug regarding struct padding. 2013-06-27 19:28:17 +02:00
bors
36527360a6 auto merge of #7429 : Blei/rust/delete-shared, r=huonw
Mostly just low-haning fruit, i.e. function arguments that were @ even
though & would work just as well.

Reduces librustc.so size by 200k when compiling without -O, by 100k when
compiling with -O.
2013-06-27 08:28:37 -07:00
Huon Wilson
29b0649a6a Convert vec::{push, push_all, push_all_move} to methods. 2013-06-28 00:20:42 +10:00
Huon Wilson
1cb0a567d1 Convert vec::{pop, shift, unshift, insert, remove, swap_remove} to methods. 2013-06-28 00:20:42 +10:00
Philipp Brüschweiler
7295a6da92 Remove many shared pointers
Mostly just low-haning fruit, i.e. function arguments that were @ even
though & would work just as well.

Reduces librustc.so size by 200k when compiling without -O, by 100k when
compiling with -O.
2013-06-27 15:06:19 +02:00
bors
c440743dcc auto merge of #7403 : catamorphism/rust/package-scripts, r=brson
r? @brson (or @graydon if available) rustpkg/api.rs provides functions intended for package scripts to call.
It will probably need more functionality added to it later, but this is
a start.

Added a test case checking that a package script can use the API.

Closes #6401
2013-06-27 06:01:30 -07:00
Huon Wilson
d2e3e1e52b Convert vec::{head, tail, init, last} (and similar fns) to methods. 2013-06-27 22:37:00 +10:00
Huon Wilson
d0512b1055 Convert vec::[mut_]slice to methods, remove vec::const_slice. 2013-06-27 22:36:09 +10:00
bors
a28f9ba526 auto merge of #7361 : brson/rust/incoming, r=brson 2013-06-27 01:04:33 -07:00
bors
f1e09d6f1f auto merge of #7420 : mozilla/rust/rollup, r=thestinger 2013-06-26 23:07:41 -07:00
bors
36d7f601d8 auto merge of #7354 : bblum/rust/trait-bounds, r=pcwalton
r? @nikomatsakis
2013-06-26 17:37:29 -07:00
Corey Richardson
394d28cac5 Fix old .each usage 2013-06-26 18:22:15 -04:00
Ben Blum
ffc8c0ba21 Looser restrictions on what can be captured in unbounded heap closures. 2013-06-26 18:14:43 -04:00
Ben Blum
f8c892ab96 Make closure contents call out to trait_contents. 2013-06-26 18:14:43 -04:00
Ben Blum
108739f533 Looser restrictions on what can be captured in unbounded traits. 2013-06-26 18:14:43 -04:00
Ben Blum
7b968783d7 Infer default static/Owned bounds for unbounded heap fns/traits (#7264) 2013-06-26 18:14:43 -04:00
bors
32adc0e730 auto merge of #7382 : msullivan/rust/cleanup, r=bblum 2013-06-26 15:13:37 -07:00
Tim Chevalier
2b17e4775c rustc: Eliminate extra failing case in metadata::loader::crate_from_metas
Closes #2406
2013-06-26 18:08:34 -04:00
Philipp Brüschweiler
2234f61038 Remove the last traces of shapes 2013-06-26 18:08:23 -04:00
bors
23fb2278c7 auto merge of #7356 : msullivan/rust/default-methods, r=bblum
r?
2013-06-26 12:08:33 -07:00
bors
4e5b4807a5 auto merge of #7297 : huonw/rust/strip-expand-strip, r=cmr
This allows macros to both be conditionally defined, and expand
to items with #[cfg]'s.

This seems to have a performance improvement, e.g. for `std`:

```
# Before 
time: 1.660 s   expansion
time: 0.125 s   configuration
# After
time: 0.080 s   configuration 1
time: 1.127 s   expansion
time: 0.132 s   configuration 2
```

And for `extra`:

```
# Before
time: 0.593 s   expansion
time: 0.062 s   configuration
# After
time: 0.047 s   configuration 1
time: 0.147 s   expansion
time: 0.058 s   configuration 2
```

(This seems a little peculiar, but it is possibly because the expansion AST traversal is very slow, so removing as much as possible as early as possible has big benefits.)
2013-06-26 07:32:14 -07:00
Huon Wilson
73e3dbf9c0 driver: perform stripping before and after macro expansion.
This allows macros to both be conditionally defined, and expand
to items with #[cfg]'s.
2013-06-26 23:02:14 +10:00
bors
a30ab764e1 auto merge of #7255 : michaelwoerister/rust/debuginfo, r=jdm
This PR contains no real code changes. Just some documentation additions in the form of comments and some internal reordering of functions within debuginfo.rs.
2013-06-26 05:20:06 -07:00
Tim Chevalier
3789433b4f rustpkg: Begin allowing package scripts to call the default build logic
rustpkg/api.rs provides functions intended for package scripts to call.
It will probably need more functionality added to it later, but this is
a start.

Added a test case checking that a package script can use the API.

Closes #6401
2013-06-25 22:29:38 -07:00
bors
22408d9ad5 auto merge of #7269 : luqmana/rust/drop, r=thestinger
Finally rename finalize to drop.
Closes #4332.
2013-06-25 20:29:06 -07:00
Brian Anderson
5d3ca4b843 Merge remote-tracking branch 'mozilla/master' into incoming
Conflicts:
	src/librustc/middle/astencode.rs
	src/librustc/middle/check_const.rs
2013-06-25 19:32:00 -07:00
Luqman Aden
ca2966c6d0 Change finalize -> drop. 2013-06-25 21:14:39 -04:00
bors
efd1438770 auto merge of #7373 : thestinger/rust/iterator, r=huonw 2013-06-25 15:22:55 -07:00
Daniel Micay
e67c48a591 remove each from vec, HashMap and HashSet 2013-06-25 16:28:02 -04:00
Daniel Micay
5242e8d2ba remove the redundant each method from OptVec 2013-06-25 16:26:23 -04:00
bors
4967bd0508 auto merge of #7325 : artagnon/rust/resolve-module, r=cmr
Fix #7322.

I started out with a band-aid approach to special-case the duplicate module error using `is_duplicate_module`, but thought this would be better in the long term.
2013-06-25 13:11:11 -07:00
Ramkumar Ramachandra
f982f42f3c resolve: make error message strings more consistent
The "first definition of ..." error string reported by add_child() looks
different from similar messages reported by other functions.  Fix this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-06-25 23:58:48 +05:30
Ramkumar Ramachandra
9f80591d84 resolve: report duplicate module definitions
add_child() is responsible for reporting errors about type, value, and
module duplicate definitions.  Although it checks for all three, it uses
namespace_to_str() to convert a Namespace value into a string before
printing an error like:

  error: duplicate definition of type `foo`
                                 ^^^^
  note: first definition of type foo here:
                            ^^^^

Unfortunately, this string can only be one of "type" or
"value" (corresponding to TypeNS and ValueNS respectively), and it
reports duplicate modules as duplicate types.

To alleviate the problem, define a special NamespaceError enum to define
more specialized errors, and use it instead of attempting to reuse the
Namespace enum.

Reported-by: Corey Richardson <corey@octayn.net>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-06-25 23:58:48 +05:30
Michael Sullivan
276463f064 Fix another generics bug with default methods. Closes #7295. 2013-06-25 11:20:02 -07:00
bors
032dcc57e8 auto merge of #7371 : alexcrichton/rust/trying, r=cmr
This is an attempt at a smaller request than #7113, it's just the first two commits
2013-06-25 10:47:01 -07:00
Michael Sullivan
663f298183 Get rid of cast on every self reference. 2013-06-25 10:17:34 -07:00
Michael Sullivan
13e5f0ebdf Remove some essentially dead code in method handling. 2013-06-25 10:17:33 -07:00
Michael Sullivan
5e26808141 Get rid of terrible way for iterating over provided methods. 2013-06-25 10:17:33 -07:00
Alex Crichton
92424f0670 Add the warnings lint attribute 2013-06-25 08:55:15 -07:00
Alex Crichton
42b44b21b1 Rename all files with the 'rc' extension 2013-06-25 08:55:15 -07:00
bors
d161e630d8 auto merge of #7317 : Aatch/rust/no-drop-flag, r=thestinger
This adds a `#[no_drop_flag]` attribute. This attribute tells the compiler to omit the drop flag from the struct, if it has a destructor. When the destructor is run, instead of setting the drop flag, it instead zeroes-out the struct. This means the destructor can run multiple times and therefore it is up to the developer to use it safely.

The primary usage case for this is smart-pointer types like `Rc<T>` as the extra flag caused the struct to be 1 word larger because of alignment.

This closes #7271 and #7138
2013-06-25 07:23:06 -07:00
bors
7aee5da08d auto merge of #7254 : Blei/rust/intrinsic-overhaul, r=cmr
This sets the `get_tydesc()` return type correctly and removes the intrinsic module. See #3730, #3475.

Update: this now also removes the unused shape fields in tydescs.
2013-06-25 04:38:06 -07:00
bors
b11346bb5d auto merge of #7291 : alexcrichton/rust/static-mut, r=huonw
This adds both `static mut` items and `static mut` foreign items. This involved changing far less code than I thought it was going to, but the tests seem to pass and the variables seem functional.

I'm more than willing to write more tests, so suggestions are welcome!

Closes #553
2013-06-25 01:59:05 -07:00
James Miller
6ad31ffb53 Warning police 2013-06-25 17:13:52 +12:00
James Miller
721164d5ec Zero the struct in the take glue, not the drop glue 2013-06-25 16:39:56 +12:00
James Miller
d9f6dd263c Set #[no_drop_flag] on Rc<T> and AtomicOption. Add Test 2013-06-25 16:11:34 +12:00
James Miller
0cca08a21a Add support for #[no_drop_flag] attribute 2013-06-25 16:11:33 +12:00
Brian Anderson
c06ee9f7a7 Merge remote-tracking branch 'cmr/various-cleanup' into incoming 2013-06-24 15:11:36 -07:00
Brian Anderson
f48068657a Merge remote-tracking branch 'sstewartgallus/cleanup_middle' into incoming 2013-06-24 15:10:50 -07:00
Brian Anderson
051fbcea72 Merge remote-tracking branch 'artagnon/abi-dead-code' into HEAD 2013-06-24 14:08:03 -07:00
Daniel Micay
e2e39234cc remove old_iter
the `test/run-pass/class-trait-bounded-param.rs` test was xfailed and
written in an ancient dialect of Rust so I've just removed it

this also removes `to_vec` from DList because it's provided by
`std::iter::to_vec`

an Iterator implementation is added for OptVec but some transitional
internal iterator methods are still left
2013-06-24 01:35:11 -04:00
Alex Crichton
8fdc8f392c Support foreign 'static mut' variables as well 2013-06-23 18:00:32 -07:00
Alex Crichton
1841b31c61 Add 'static mut' items to the language 2013-06-23 17:59:35 -07:00
Ben Blum
ba3f43e506 Fix pretty-printing builtin bounds on closures and traits 2013-06-23 17:54:25 -04:00
Ben Blum
1d2b20ee2c Check existential type contents against destination trait bounds. 2013-06-23 17:54:24 -04:00
Ben Blum
1ffcc6fc82 Allow ~fn:Copy() to be copied. 2013-06-23 17:54:21 -04:00
Ben Blum
7c0a0404d5 Check closure freevar kinds against destination environment bounds (#3569) 2013-06-23 14:40:18 -04:00
Ben Blum
ce857e3d60 Parse and typecheck (not kindcheck) bounds on trait paths. 2013-06-23 14:40:14 -04:00
Ramkumar Ramachandra
8cadca4e41 abi: remove dead code
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-06-24 00:04:46 +05:30
bors
c17ff80e01 auto merge of #7267 : luqmana/rust/issue-5792, r=cmr
Fixes #5792
2013-06-23 07:52:55 -07:00
Philipp Brüschweiler
e2f1049bd5 Remove unused TyDesc parameter from the glue functions
To remove the environment pointer, support for function pointers without
an environment argument is needed (i.e. a fixed version of #6661).
2013-06-23 13:02:00 +02:00
Philipp Brüschweiler
273f90566c Small cleanups 2013-06-23 12:49:16 +02:00
Philipp Brüschweiler
8bf0033345 Remove unused shape fields from typedescs 2013-06-23 12:49:16 +02:00
Philipp Brüschweiler
469f394b25 Remove intrinsic module
To achieve this, the following changes were made:
* Move TyDesc, TyVisitor and Opaque to std::unstable::intrinsics
* Convert TyDesc, TyVisitor and Opaque to lang items instead of specially
  handling the intrinsics module
* Removed TypeDesc, FreeGlue and get_type_desc() from sys

Fixes #3475.
2013-06-23 12:49:16 +02:00
Philipp Brüschweiler
f2c5642d13 Fix get_tydesc() return type
This fixes part of #3730, but not all.
Also changes the TyDesc struct to be equivalent with the generated
code, with the hope that the above issue may one day be closed for good,
i.e. that the TyDesc type can completely be specified in the Rust
sources and not be generated.
2013-06-23 12:46:28 +02:00
bors
3b126e4d6d auto merge of #7274 : thestinger/rust/size_hint, r=huonw
I ran into a weird lifetime bug blocking updating the `collect` method to use `FromIterator`, but everything here works fine.
2013-06-22 23:07:55 -07:00
Daniel Micay
d2e9912aea vec: remove BaseIter implementation
I removed the `static-method-test.rs` test because it was heavily based
on `BaseIter` and there are plenty of other more complex uses of static
methods anyway.
2013-06-23 02:05:20 -04:00
Steven Stewart-Gallus
0f55c9cc7e Cleaned up middle a bit.
The only really tricky change is that a long chain of ifs, and elses
was turned into a single if, and a match in astencode.rs. Some methods
can only be called in certain cases, and so have to come after the if.
2013-06-22 18:58:41 -07:00
bors
0739c6b5a0 auto merge of #7214 : Blei/rust/fix-owned-traits, r=pcwalton
This finishes the incomplete conversion of unique traits as two-word
allocations started in 211d038abc.

Fixes #5882, #6717, #7153, #7208.
2013-06-22 13:29:10 -07:00
Daniel Micay
ef07d7c46e Merge pull request #7270 from thestinger/doc
accumulated doc pull requests from the queue
2013-06-22 12:56:37 -07:00
Philipp Brüschweiler
de471a2eca Fix take glue of owned trait objects
This finishes the incomplete conversion of unique traits as two-word
allocations started in 211d038abc.

Fixes #5882, #6717, #7153, #7208.
2013-06-22 09:37:40 +02:00
Brian Anderson
dfc04e5edb rustc: Fix formatting of --help 2013-06-22 00:57:12 -04:00
bors
dc4560dc26 auto merge of #7182 : Aatch/rust/trans-refactor-pt2, r=graydon
This is another big refactoring of `trans` though this is unlikely to have much of an
impact on code size or speed.

The major change here is the implementation of a `Type` struct which is the new
home for all your LLVM `TypeRef` needs. It's a simple wrapper struct, with static
methods for constructing types, then regular methods for
manipulating/interrogating them. The purpose of this is mostly to make the code
surrounding them somewhat more ideomatic. A line like: `T_ptr(T_ptr(T_i8()))` is 
now `Type::i8().ptr_to().ptr_to()`,which is much more like regular Rust code.

There are a variety of smaller changes here and there:

* Remove address spaces. At least it doesn't generate them, I haven't spent much
  time looking for related code.
* Use a macro for declaring the LLVM intrinsics, makes it look much nicer.
* Make the type for a string slice actually create a named `str_slice` type in LLVM,
  this makes reading the appropriate code much easier.
* Change the way struct and enum type names are generated. This just means
  that a struct like `struct Foo { a: int }` now produces the IR 
  `%struct.Foo = type { i64 }`, which is much easier to read. Similarly, other structs
  are a bit tighter to make it easier to read.

--- --- ---

This PR did get away from me a little, as I occasionally got distracted or as I fixed
up problems with unrelated code that were stopping me from continuing. One major
thing is that this PR contains the work from #7168, since that would have conflicted
with this and it was broken anyway. Sorry for bundling it like this.

Fixes #3670 and #7063

--- --- ---

EDIT: This no longer removes the llvm insn stats.
2013-06-21 19:19:58 -07:00
James Miller
e3ef7504e9 Fix merge fallout 2013-06-22 13:41:52 +12:00
James Miller
fb6dc957d6 Remove remaining address space related code 2013-06-22 12:38:40 +12:00
James Miller
761fc16c60 Fix-up PP Code to reflect new lifetime param syntax 2013-06-22 12:38:40 +12:00
James Miller
048ed1486f Move count-llvm-insn code into task-local storage 2013-06-22 12:38:40 +12:00
James Miller
0b0c756c9c Fix warnings in trans 2013-06-22 12:38:40 +12:00
James Miller
81cf72c264 Finish up Type refactoring 2013-06-22 12:35:35 +12:00
James Miller
57a75374d6 Initial Type Refactoring done 2013-06-22 12:32:11 +12:00
James Miller
befbd3a680 Add the rest of the atomic operations.
This makes the handling of atomic operations more generic, which
does impose a specific naming convention for the intrinsics, but
that seems ok with me, rather than having an individual case for
each name.

It also adds the intrinsics to the the intrinsics file.
2013-06-22 12:26:33 +12:00
James Miller
fd83b92b59 More Type refactorings 2013-06-22 12:26:33 +12:00
James Miller
1968622798 Start refacting LLVM Type handling 2013-06-22 12:24:21 +12:00
James Miller
66d8e8b481 Make log_fn_time a method 2013-06-22 12:24:21 +12:00
James Miller
b4b2cbb299 Change calls for TypeName stuff to methods 2013-06-22 12:24:20 +12:00
James Miller
3dbdb3a364 Methodize TypeNames 2013-06-22 12:24:20 +12:00
bors
f886520d24 auto merge of #7219 : sstewartgallus/rust/cleanup, r=graydon 2013-06-21 16:01:59 -07:00
Corey Richardson
116897fa6c Remove ast::pure_fn and all concept of pure from the compiler 2013-06-21 18:10:56 -04:00
bors
544f6159f7 auto merge of #7259 : dotdash/rust/ir_improvement, r=graydon
The changes in these commits improve the IR codegen by removing unnecessary copies for certain function call arguments and stopping to allocate return values for functions returning nil. They reduce compile times by about 10% in total.
2013-06-21 07:52:55 -07:00
Björn Steinbrink
4fb2c09541 Avoid pointless allocas for "nil" return values
By using "void" instead of "{}" as the LLVM type for nil, we can avoid
the alloca/store/load sequence for the return value, resulting in less
and simpler IR code.

This reduces compile times by about 10%.
2013-06-21 13:36:25 +02:00
bors
b0e3ffd380 auto merge of #7263 : thestinger/rust/iterator, r=graydon 2013-06-21 01:49:50 -07:00
Daniel Micay
06bec77faf replace vec::find with the IteratorUtil method 2013-06-21 03:24:03 -04:00
Daniel Micay
883c966d5c vec: replace position with iter().position_ 2013-06-21 03:23:59 -04:00
Daniel Micay
49c74524e2 vec: rm old_iter implementations, except BaseIter
The removed test for issue #2611 is well covered by the `std::iterator`
module itself.

This adds the `count` method to `IteratorUtil` to replace `EqIter`.
2013-06-21 03:20:22 -04:00
Daniel Micay
cbad1da3db vec: remove eachi
replaced by the `enumerate` method from std::iterator
2013-06-21 03:20:22 -04:00
bors
ba05af7b1c auto merge of #7203 : msullivan/rust/default-methods, r=graydon
This fixes the large number of problems that prevented cross crate
methods from ever working. It also fixes a couple lingering bugs with
polymorphic default methods and cleans up some of the code paths.

Closes #4102. Closes #4103.

r? nikomatsakis
2013-06-20 22:28:52 -07:00
Luqman Aden
31b4b53797 librustc: Don't allow enum struct variants to shadow structs. 2013-06-20 19:14:57 -04:00
Michael Sullivan
1a8969f64b Get cross crate default methods working.
This fixes the large number of problems that prevented cross crate
methods from ever working. It also fixes a couple lingering bugs with
polymorphic default methods and cleans up some of the code paths.

Closes #4102. Closes #4103.
2013-06-20 15:42:16 -07:00
Björn Steinbrink
dc262d9aa7 Avoid unnecessary scratch datums for by-copy function arguments
Currently, by-copy function arguments are always stored into a scratch
datum, which serves two purposes.  First, it is required to be able to
have a temporary cleanup, in case that the call fails before the callee
actually takes ownership of the value. Second, if the argument is to be
passed by reference, the copy is required, so that the function doesn't
get a reference to the original value.

But in case that the datum does not need a drop glue call and it is
passed by value, there's no need to perform the extra copy.
2013-06-20 23:53:26 +02:00
James Miller
229a88217f librust: cleanup warnings (except 1) 2013-06-21 02:43:03 +12:00
James Miller
3bc4d1a120 Remove all #[cfg(stage0)]-protected code
New snapshot means this can all go. Also removes places that have
comments that say they are workarounds for stage0 errors.
2013-06-21 02:43:02 +12:00
Michael Woerister
6eb3c0f30d debuginfo.rs: Removed trailing whitespace. 2013-06-20 11:50:09 +02:00
Michael Woerister
60474f395c debuginfo.rs: Explained why a function is called although one could think it should not be. 2013-06-20 11:50:09 +02:00
Michael Woerister
38743f51ad debuginfo.rs: Removed some static constants not used anymore. 2013-06-20 11:50:09 +02:00
Michael Woerister
290d35312a Reordered debuginfo.rs and commented public fns 2013-06-20 11:50:09 +02:00
Michael Woerister
f1bd3e7ca2 Fixed compiler warnings about unnecessary string allocations in debuginfo.rs 2013-06-20 11:50:09 +02:00
Michael Woerister
5d5311dc74 Added overview of the debuginfo module at the beginning of debuginfo.rs. 2013-06-20 11:50:09 +02:00
Brian Anderson
b7a6919899 rustc: Dispose of LLVM passes in test cases 2013-06-19 15:18:25 -07:00
Ben Blum
3ba8404c88 Oops, hide 'unless once fn' error message hint behind -Z once-fns too. 2013-06-19 16:04:18 -04:00
Ben Blum
643be38cfe Hide the once-move-out privilege for stack fns behind '-Z once-fns' 2013-06-19 15:53:05 -04:00
Ben Blum
1496216db6 Permit moving out of captured upvars in once fns. Close #2549. 2013-06-19 14:25:51 -04:00
Ben Blum
2c7903d599 Consume once fns when calling them (#2549). 2013-06-19 14:25:51 -04:00
Steven Stewart-Gallus
b8efa2ebe0 Cleanup src/librustc/back 2013-06-18 18:50:37 -07:00
Graydon Hoare
d904c72af8 replace #[inline(always)] with #[inline]. r=burningtree. 2013-06-18 14:48:48 -07:00
bors
4bf074cc66 auto merge of #7134 : vadimcn/rust/DIBuilder, r=jdm
This commit fixes rustc's debug info generation and turns debug-info tests back on.

The old generator used to write out LLVM metadata directly, however it seems that debug metadata format is not stable and keeps changing from release to release.  So I wrapped LLVM's official debug info API - the DIBuilder class, and now rustc will use that.

One bit of old functionality that still doesn't work, is debug info for function arguments.  Someone more familiar with the compiler guts will need to look into that.

Also, unfortunately, debug info is still won't work on Windows,- due to a LLVM bug (http://llvm.org/bugs/show_bug.cgi?id=16249).

Resolves issues #5836, #5848, #6814
2013-06-17 14:01:35 -07:00
Brian Anderson
fd09e40f97 Revert "stop using an absolute rpath"
This reverts commit 708395d65d.
2013-06-17 12:37:06 -07:00
Graydon Hoare
6914ff9d01 rustc: map node ids through a table that ensures bitset indexes in dataflow are dense 2013-06-17 10:37:42 -07:00
Vadim Chugunov
adff46250e Fixed rebase fallout . 2013-06-17 08:42:05 -07:00
Vadim Chugunov
1e682e29eb Refactoring and tidy warnings cleanup. 2013-06-17 08:41:26 -07:00
Vadim Chugunov
2b45591daf Made unimplemented debuginfo a note rather than a compiler error. 2013-06-17 08:41:26 -07:00
Vadim Chugunov
65dd6218af Fixed remaining issues to pass debug-test/* tests.
Made debugger scripts source line insensitive.
2013-06-17 08:41:25 -07:00
Vadim Chugunov
62e86e044d Fixed compile warnings.
Fixed whitespace "errors".
2013-06-17 08:41:25 -07:00
Vadim Chugunov
00bb15bf72 Removed extraneous string allocations.
Misc refactoring.
2013-06-17 08:41:24 -07:00
Vadim Chugunov
6db3302b35 Debug loc for local var declarations 2013-06-17 08:41:24 -07:00
Vadim Chugunov
1079e41143 Move "return" basic block after all other function blocks. 2013-06-17 08:41:23 -07:00
Vadim Chugunov
6cc3189787 Made the while DebugContext mutable, not just created_* hashes
Disabled create_arg
2013-06-17 08:41:23 -07:00
Vadim Chugunov
868f9a88d6 Use DIBuilder in debuginfo 2013-06-17 08:41:23 -07:00
bors
3495737291 auto merge of #7157 : sstewartgallus/rust/master, r=brson
I did a little bit of cleanup work in driver.rs. It's not much but hey little steps.
2013-06-16 17:48:58 -07:00
bors
81506a6b81 auto merge of #7186 : dotdash/rust/landing_pads, r=pcwalton
Currently, cleanup blocks are only reused when there are nested scopes, the
child scope's cleanup block will terminate with a jump to the parent
scope's cleanup block. But within a single scope, adding or revoking
any cleanup will force a fresh cleanup block. This means quadratic
growth with the number of allocations in a scope, because each
allocation needs a landing pad.

Instead of forcing a fresh cleanup block, we can keep a list chained
cleanup blocks that form a prefix of the currently required cleanups.
That way, the next cleanup block only has to handle newly added
cleanups. And by keeping the whole list instead of just the latest
block, we can also handle revocations more efficiently, by only
dropping those blocks that are no longer required, instead of all of
them.

Reduces the size of librustc by about 5% and the time required to build
it by about 10%.
2013-06-16 11:48:57 -07:00
Niko Matsakis
e014ab9023 Make it illegal to move from *T. This interacts poorly with moves-based-on-type,
since it creates moves that were not apparent. It also turns out to be not
widely used.
2013-06-16 12:47:36 -04:00
Niko Matsakis
a9012a2ad1 Make type parameters not implicitly copyable, even if they have the Copy bound.
Consider: T:Copy could be bound to ~T, which is not implicitly copyable.
2013-06-16 12:47:36 -04:00
Niko Matsakis
eb48c29681 Add copies to type params with Copy bound 2013-06-16 12:47:36 -04:00
Björn Steinbrink
642cd467c6 Avoid quadratic growth of cleanup blocks
Currently, cleanup blocks are only reused when there are nested scopes, the
child scope's cleanup block will terminate with a jump to the parent
scope's cleanup block. But within a single scope, adding or revoking
any cleanup will force a fresh cleanup block. This means quadratic
growth with the number of allocations in a scope, because each
allocation needs a landing pad.

Instead of forcing a fresh cleanup block, we can keep a list chained
cleanup blocks that form a prefix of the currently required cleanups.
That way, the next cleanup block only has to handle newly added
cleanups. And by keeping the whole list instead of just the latest
block, we can also handle revocations more efficiently, by only
dropping those blocks that are no longer required, instead of all of
them.

Reduces the size of librustc by about 5% and the time required to build
it by about 10%.
2013-06-16 17:52:46 +02:00
bors
03dff61d99 auto merge of #7159 : Blei/rust/free-glue-no-destructor, r=graydon
The free glue shouldn't be called for structs, and the drop glue already
contains the destructor.
2013-06-16 04:40:01 -07:00
bors
d0f88cd54e auto merge of #7155 : Blei/rust/drop-glue-alloca, r=graydon
Removes one alloca and store from the drop glue of @ boxes. This speeds
up the rustc build by 1s (might be noise, though).
2013-06-16 02:46:08 -07:00
bors
f74e1935aa auto merge of #7123 : huonw/rust/more-str, r=thestinger
Moves all the remaining functions that could reasonably be methods to be methods, except for some FFI ones (which I believe @erickt is working on, possibly) and `each_split_within`, since I'm not really sure the details of it (I believe @kimundi wrote the current implementation, so maybe he could convert it to an external iterator method on `StrSlice`, e.g. `word_wrap_iter(&self) -> WordWrapIterator<'self>`, where `WordWrapIterator` impls `Iterator<&'self str>`. It probably won't be too hard, since it's already a state machine.)

This also cleans up the comparison impls for the string types, except I'm not sure how the lang items `eq_str` and `eq_str_uniq` need to be handled, so they (`eq_slice` and `eq`) remain stand-alone functions.
2013-06-16 00:04:13 -07:00
Huon Wilson
bbcff95ac5 remove unused imports 2013-06-16 12:20:12 +10:00
Daniel Micay
e097d5eaba rm CopyableOrderedIter
replaced with OrdIterator
2013-06-15 22:16:21 -04:00
Huon Wilson
4b18fff2be std: convert str::{map,levdistance,subslice_offset} to methods.
The first two become map_chars and lev_distance. Also, remove a few
allocations in rustdoc.
2013-06-16 10:50:28 +10:00
bors
c989b79127 auto merge of #7132 : thestinger/rust/rpath, r=brson
This is a bad default, because the binaries will point at an absolute
path regardless of where they are moved. This opens up a security issue
for packages, because they will attempt to load libraries from a path
that's often owned by a regular user.

Every Rust binary is currently flagged by Debian, Fedora and Arch lint
checkers as having dangerous rpaths. They don't meet the requirements to
be placed in the repositories without manually stripping this from each
binary.

The relative rpath is still enough to keep the binaries working until
they are moved relative to the crates they're linked against.

http://wiki.debian.org/RpathIssue
https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
2013-06-15 16:13:09 -07:00
Daniel Micay
708395d65d stop using an absolute rpath
This is a bad default, because the binaries will point at an absolute
path regardless of where they are moved. This opens up a security issue
for packages, because they will attempt to load libraries from a path
that's often owned by a regular user.

Every Rust binary is currently flagged by Debian, Fedora and Arch lint
checkers as having dangerous rpaths. They don't meet the requirements to
be placed in the repositories without manually stripping this from each
binary.

The relative rpath is still enough to keep the binaries working until
they are moved relative to the crates they're linked against.

http://wiki.debian.org/RpathIssue
https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
2013-06-15 18:17:24 -04:00
James Miller
f2a7fc69da Fix Merge Fallout 2013-06-16 09:20:40 +12:00
James Miller
cc908b772c Remove @-fields from CrateContext
Remove all the explicit @mut-fields from CrateContext, though many
fields are still @-ptrs.
This required changing every single function call that explicitly
took a @CrateContext, so I took advantage and changed as many as I
could get away with to &-ptrs or &mut ptrs.
2013-06-16 09:20:40 +12:00
James Miller
01e098aa05 Make CrateContext::new() fn.
Move construction of a CrateContext into a static method on
CrateContext.
2013-06-16 09:17:50 +12:00
James Miller
b1f39ce403 Move CrateContext into it's own file 2013-06-16 09:17:50 +12:00
James Miller
98b1c9e207 Move trans mod items into trans/mod.rs 2013-06-16 09:17:50 +12:00
bors
998e41a11a auto merge of #7154 : dotdash/rust/glue, r=graydon
Currently, when calling glue functions, we cast the function to match
the argument type. This interacts very badly with LLVM and breaks
inlining of the glue code.

It's more efficient to use a unified function type for the glue
functions and always cast the function argument instead of the function.

The resulting code for rustc is about 13% faster (measured up to and
including the "trans" pass) and the resulting librustc is about 5%
smaller.
2013-06-15 12:58:06 -07:00
Steven Stewart-Gallus
f22580dd29 Fix up mingw32 case 2013-06-15 11:26:02 -07:00
Philipp Brüschweiler
4ee99a1c0c trans::glue: don't generate struct destructors in the free glue
The free glue shouldn't be called for structs, and the drop glue already
contains the destructor.
2013-06-15 20:13:23 +02:00
Björn Steinbrink
a08d768cd8 Fix inlining of glue code
Currently, when calling glue functions, we cast the function to match
the argument type. This interacts very badly with LLVM and breaks
inlining of the glue code.

It's more efficient to use a unified function type for the glue
functions and always cast the function argument instead of the function.

The resulting code for rustc is about 13% faster (measured up to and
including the "trans" pass) and the resulting librustc is about 5%
smaller.
2013-06-15 18:29:19 +02:00
Philipp Brüschweiler
3f69e20043 trans::glue: don't allocate a pointer variable if it already exists
Removes one alloca and store from the drop glue of @ boxes. This speeds
up the rustc build by 1s (might be noise, though).
2013-06-15 18:21:47 +02:00
bors
eac0200f18 auto merge of #7148 : catamorphism/rust/rustpkg_tests, r=graydon
r? @graydon Automate more tests described in the commands.txt file,
and add infrastructure for running them. Right now, tests shell
out to call rustpkg. This is not ideal.

Goes part of the way towards addressing #5683
2013-06-15 08:12:57 -07:00
bors
83d44f87e5 auto merge of #7125 : alexcrichton/rust/rusti-issues, r=brson
This un-reverts the reverts of the rusti commits made awhile back. These were reverted for an LLVM failure in rustpkg. I believe that this is not a problem with these commits, but rather that rustc is being used in parallel for rustpkg tests (in-process). This is not working yet (almost! see #7011), so I serialized all the tests to run one after another.

@brson, I'm mainly just guessing as to the cause of the LLVM failures in rustpkg tests. I'm confident that running tests in parallel is more likely to be the problem than those commits I made.

Additionally, this fixes two recently reported issues with rusti.
2013-06-15 01:04:05 -07:00
Steven Stewart-Gallus
5de67f9cc9 Cleaned up driver.rs 2013-06-15 00:43:19 -07:00
Tim Chevalier
1adbb4520b rustc: Don't continue to resolve if there's an error in lang_items
This confused me when it happened.
2013-06-14 22:45:43 -07:00
bors
1ba6fa4777 auto merge of #7110 : thestinger/rust/iterator, r=brson 2013-06-14 21:37:27 -07:00
bors
1104e659d5 auto merge of #7144 : dotdash/rust/caches, r=graydon
The lookups for these items in external crates currently cause repeated
decoding of the EBML metadata, which is pretty slow. Adding caches to
avoid the repeated decoding reduces the time required for the type
checking of librustc by about 25%.
2013-06-14 20:28:09 -07:00
Daniel Micay
585f5f7f79 add IteratorUtil to the prelude 2013-06-14 23:15:42 -04:00
Björn Steinbrink
a710e61903 Add caches for method and impl metadata
The lookups for these items in external crates currently cause repeated
decoding of the EBML metadata, which is pretty slow. Adding caches to
avoid the repeated decoding reduces the time required for the type
checking of librustc by about 25%.
2013-06-15 04:28:19 +02:00
bors
104e6120b1 auto merge of #7116 : thestinger/rust/whitespace, r=luqmana 2013-06-14 19:25:05 -07:00
Alex Crichton
dc18321ef5 Don't run passes again on JIT code
These passes are already run beforehand, no need to do them twice.
2013-06-13 22:53:10 -07:00
Alex Crichton
a90fffe367 Revert "Revert "Have JIT execution take ownership of the LLVMContextRef""
This reverts commit 19adece68b.
2013-06-13 21:25:18 -07:00
Alex Crichton
1a3edecbf2 Revert "Revert "Remove all usage of the global LLVMContextRef""
This reverts commit 541c657a73.
2013-06-13 21:25:12 -07:00
Brian Anderson
7755018074 Revert "std: convert {vec,str}::to_owned to methods."
This fixes the strange random crashes in compile-fail tests.

This reverts commit 96cd61ad03.

Conflicts:
	src/librustc/driver/driver.rs
	src/libstd/str.rs
	src/libsyntax/ext/quote.rs
2013-06-13 19:06:47 -07:00
Daniel Micay
ec27644870 automated whitespace fixes 2013-06-13 18:03:08 -04:00
Brian Anderson
541c657a73 Revert "Remove all usage of the global LLVMContextRef"
This reverts commit 779191cd4b.

Conflicts:
	src/librustc/middle/trans/base.rs
	src/librustc/middle/trans/common.rs
2013-06-13 13:08:57 -07:00
Brian Anderson
19adece68b Revert "Have JIT execution take ownership of the LLVMContextRef"
This reverts commit 5c5095d25e.

Conflicts:
	src/librusti/rusti.rc
2013-06-13 13:08:57 -07:00
Steven Stewart-Gallus
d9d50a5bd4 Remove unused imports
I was able to remove unused imports, and fix the following warnings

src/libstd/hashmap.rs:23:15: 23:23 warning: unused import [-W unused-imports (default)]
src/libstd/task/spawn.rs:95:15: 95:23 warning: unused import [-W unused-imports (default)]
src/libstd/rt/uv/mod.rs:42:0: 42:9 warning: unused import [-W unused-imports (default)]
src/libstd/rt/uv/mod.rs:45:0: 45:9 warning: unused import [-W unused-imports (default)]
src/librustc/middle/trans/meth.rs:26:0: 26:26 warning: unused import [-W unused-imports (default)]
src/librustc/back/link.rs:210:20: 210:25 warning: unused import [-W unused-imports (default)]

I was unable to fix the following unused import warnings. The code
here was weird.

src/libextra/std.rc:40:11: 40:14 warning: unused import [-W unused-imports (default)]
src/libextra/std.rc:40:16: 40:24 warning: unused import [-W unused-imports (default)]
2013-06-13 10:46:17 -07:00
Huon Wilson
5ebffd46d5 rustc: fix test failures after rebase. 2013-06-13 10:47:33 +10:00
Huon Wilson
096f6f56a8 Use @str instead of @~str in libsyntax and librustc. Fixes #5048.
This almost removes the StringRef wrapper, since all strings are
Equiv-alent now. Removes a lot of `/* bad */ copy *`'s, and converts
several things to be &'static str (the lint table and the intrinsics
table).

There are many instances of .to_managed(), unfortunately.
2013-06-13 10:20:52 +10:00
bors
84bed9769b auto merge of #7091 : msullivan/rust/default-methods, r=graydon
r? @nikomatsakis
2013-06-12 16:25:34 -07:00
Michael Sullivan
36e3d64c3e Fix a lot of the handling of default methods and type parameters. Closes #4099, #4102. 2013-06-12 13:50:45 -07:00
Michael Sullivan
5835158170 Drop some dead method handling code. 2013-06-12 13:50:45 -07:00
Michael Sullivan
a159f856d5 Properly translate calls to default methods in a number of cases. Closes #4350. 2013-06-12 13:50:15 -07:00
Felix S. Klock II
91bced8ae8 Fix linebreak and whitespace issues to placate make tidy. 2013-06-12 19:16:30 +02:00
Felix S. Klock II
ecef9ad75a Visitor refactoring: Step 1, couple (Env, vt<Env>) together in a tuple. 2013-06-12 13:04:37 +02:00
Luqman Aden
aa9a992f3e libsyntax: Remove duplicate methods. 2013-06-12 02:46:38 -04:00
Luqman Aden
47772bcb73 Add tests for duplicate methods on traits/impls. 2013-06-12 02:46:38 -04:00
Luqman Aden
c6f3103006 librustc: Don't allow duplicate methods on impls. 2013-06-12 02:46:38 -04:00
Luqman Aden
8fc14b6e62 librustc: Don't allow duplicate methods on a trait. 2013-06-12 02:46:38 -04:00
bors
cc80652e4a auto merge of #7060 : huonw/rust/more-str, r=thestinger
There are now only half-a-dozen or so functions left `std::str` that should be methods.

Highlights:
- `.substr` was removed, since most of the uses of it in the code base were actually incorrect (it had a weird mixing of a byte index and a unicode character count), adding `.slice_chars` if one wants to handle characters, and the normal `.slice` method to handle bytes.
- Code duplication between the two impls for `connect` and `concat` was removed via a new `Str` trait, that is purely designed to allow an explicit -> `&str` conversion (`.as_slice()`)
- Deconfuse the 5 different functions for converting to `[u8]` (3 of which had actually incorrect documentation: implying that they didn't have the null terminator), into 3: `as_bytes` (all strings), `as_bytes_with_null` (`&'static str`, `@str` and `~str`) and `as_bytes_with_null_consume` (`~str`). None of these allocate, unlike the old versions.

(cc @thestinger)
2013-06-11 21:37:43 -07:00
bors
7033dfcf91 auto merge of #7069 : dotdash/rust/cast_combine, r=graydon
Shaves off a percent or so from the LLVM passes for librustc.
2013-06-11 20:43:39 -07:00
bors
8761b1fb16 auto merge of #7067 : brson/rust/notasktrans, r=graydon 2013-06-11 19:37:39 -07:00
Huon Wilson
26d7b460a3 std: generalise .trim_chars to use CharEq. 2013-06-12 12:21:05 +10:00
Huon Wilson
9e60e2e297 std: convert str::replace to a method. 2013-06-12 12:21:04 +10:00
Huon Wilson
3ac00a9489 std: remove substr & str::count_*, methodise char_len, implement slice_chars.
The confusing mixture of byte index and character count meant that every
use of .substr was incorrect; replaced by slice_chars which only uses
character indices. The old behaviour of `.substr(start, n)` can be emulated
via `.slice_from(start).slice_chars(0, n)`.
2013-06-12 12:21:04 +10:00
Huon Wilson
efc71a8bdb std: unify the str -> [u8] functions as 3 methods: .as_bytes() and .as_bytes_with_null[_consume]().
The first acts on &str and is not nul-terminated, the last two act on strings
that are always null terminated (&'static str, ~str and @str).
2013-06-12 12:21:04 +10:00
Huon Wilson
ba4a4778cc std: convert str::{*shift,pop}* to methods. 2013-06-12 12:21:04 +10:00
Huon Wilson
96cd61ad03 std: convert {vec,str}::to_owned to methods. 2013-06-12 12:21:03 +10:00
bors
3f900dc7d1 auto merge of #7055 : thestinger/rust/iterator, r=catamorphism
This was a lot more painful than just changing `x.each` to `x.iter().advance` . I ran into my old friend #5898 and had to add underscores to some method names as a temporary workaround.

The borrow checker also had other ideas because rvalues aren't handled very well yet so temporary variables had to be added. However, storing the temporary in a variable led to dynamic `@mut` failures, so those had to be wrapped in blocks except where the scope ends immediately.

Anyway, the ugliness will be fixed as the compiler issues are fixed and this change will amount to `for x.each |x|` becoming `for x.iter |x|` and making all the iterator adaptors available.

I dropped the run-pass tests for `old_iter` because there's not much point in fixing a module that's on the way out in the next week or so.
2013-06-11 16:19:42 -07:00
bors
da9172af60 auto merge of #7040 : alexcrichton/rust/issue-6511-threadsafe-llvm, r=graydon
This is a reopening of #6570, and almost fixes #6511.

Note that this doesn't actually enable building a threadsafe LLVM, because that will require an LLVM rebuild which will be bundled with the upgrades in #6713.

What this does do, however, is removes all thread-unsafe usage of LLVM from the compiler.
2013-06-11 13:46:54 -07:00
Björn Steinbrink
f526434197 Codegen: Combine two PointerCasts into one
Shaves off a percent or so from the LLVM passes for librustc.
2013-06-11 22:45:13 +02:00
Brian Anderson
48c7bc17c6 rustc: Remove task type defs from trans 2013-06-11 12:36:42 -07:00
Daniel Micay
004816f4c6 option: remove redundant old_iter impls 2013-06-11 14:06:12 -04:00
Philipp Brüschweiler
3f62f9bccd ty: several small fixes to is_instantiable
* Don't return early, so logging is not skipped
* Remove one allocation
* Indent the match statement correctly
2013-06-11 11:44:53 +02:00
Philipp Brüschweiler
278b3beafe decoder: better error message when failing to look up an id 2013-06-11 11:44:53 +02:00
bors
df5b0c040c auto merge of #7046 : luqmana/rust/issue-7044, r=sanxiyn
Fixes #7044.
2013-06-10 20:52:32 -07:00
Luqman Aden
a95232a59e librustc: Better errors for duplicate definitions. 2013-06-10 18:00:57 -04:00
Luqman Aden
5a3e1cdaec librustc: Don't allow newtype or unit-like structs to shadow other names in the value namespace. 2013-06-10 17:29:48 -04:00
Alex Crichton
5c5095d25e Have JIT execution take ownership of the LLVMContextRef
Also stop leaking the ExecutionEngine created for jit code by forcibly disposing
of it after the JIT code has finished executing
2013-06-10 13:17:04 -07:00
Alex Crichton
779191cd4b Remove all usage of the global LLVMContextRef
This allows parallel usage of the rustc library
2013-06-10 13:17:04 -07:00
Huon Wilson
e8782eeb63 fix tests, remove some warnings 2013-06-11 02:34:14 +10:00
Huon Wilson
838191c40b std: replace str::{starts,ends}_with with the method. 2013-06-11 01:03:24 +10:00
Huon Wilson
248b6e38b5 std: replace str::substr with the method. 2013-06-11 00:52:47 +10:00
Huon Wilson
ccd0ac59e9 std: remove str::{connect,concat}*. 2013-06-10 23:57:03 +10:00
Huon Wilson
5a711ea7c3 clean-up unused import warnings 2013-06-10 23:15:01 +10:00
Huon Wilson
ec5a028ada std: convert str::char_at* to methods. 2013-06-10 23:02:55 +10:00
Huon Wilson
1553874149 std: convert str::reserve* to methods, and methodise str::push_*. 2013-06-10 23:02:55 +10:00
Huon Wilson
a64e886e3c std: remove str::contains in favour of the method 2013-06-10 23:02:55 +10:00
Huon Wilson
0cfc08d81e std: convert character-based str::find_* to methods. Add .slice_{to,from} methods. 2013-06-10 23:02:54 +10:00
Huon Wilson
76fc9be5a1 std: convert each_split_str to an iterator 2013-06-10 23:02:54 +10:00
Huon Wilson
c32fb53cf9 std: remove str::{len, slice, is_empty} in favour of methods. 2013-06-10 23:02:54 +10:00
Huon Wilson
1e8982bdb2 std: replace str::each_split* with an iterator 2013-06-10 23:02:54 +10:00
Alex Crichton
b6cccb3d81 Track the source of the type_target and value_target separately for ImportResolutions 2013-06-09 21:42:57 -07:00
Luqman Aden
618558a70f librustc: Allow adding static fn's in multiple impl's. 2013-06-09 08:00:40 -04:00
bors
88c318d28c auto merge of #7023 : thestinger/rust/vec, r=brson 2013-06-08 22:34:10 -07:00
Daniel Micay
de367157b5 remove deprecated vec::{is_empty, len} functions 2013-06-08 23:19:30 -04:00
bors
1f0c05ff74 auto merge of #7018 : bill-myers/rust/fix_7017, r=thestinger
Minimally fixes #7017, we were overwriting the result and thus ignoring attributes before the last.

csearch::get_item_attrs and decoder::get_item_attrs should probably also be changed to each_item_attrs using the for protocol, but that's just a minor performance/style issue.
2013-06-08 19:16:11 -07:00
Bill Myers
90ec4228be fix decoding of multiple attributes (fixes #7017)
We were just looking at the last because we were overwriting ret.
2013-06-09 02:36:31 +02:00
bors
470bf0dfb3 auto merge of #7016 : thestinger/rust/ptr, r=luqmana 2013-06-08 14:31:10 -07:00
bors
878a9b92eb auto merge of #7004 : dotdash/rust/allocs, r=thestinger
This removes some unnecessary allocations in the lexer, the typechecker and the metadata decoder. Reduces the time spent in the parsing and typechecking passes by about 10% for me.
2013-06-08 13:37:10 -07:00
bors
4aa77198cb auto merge of #6992 : Blei/rust/fix-autoderef-ice, r=catamorphism
Related to #5062, but doesn't fix that one.
2013-06-08 12:40:15 -07:00
Daniel Micay
fe3ad0a204 rm some uses of to_mut_unsafe_ptr 2013-06-08 15:02:32 -04:00
Huon Wilson
98ba91f81b remove unused import warnings 2013-06-09 02:22:23 +10:00
Huon Wilson
4b806b4d06 std: remove each_char* fns and methods from str, replaced by iterators. 2013-06-09 02:22:23 +10:00
Huon Wilson
513d2292e5 std: remove foldr and alli methods in vec 2013-06-09 02:22:23 +10:00
Huon Wilson
ed299af625 std: remove fold[lr] in favour of iterators 2013-06-09 02:22:23 +10:00
Huon Wilson
65c7c58c8f std: remove {all*,any*,count} in favour of iterators 2013-06-09 02:22:23 +10:00
Huon Wilson
ce4f63dcee std: add reverse vec iterators, replace vec::each*_reverse. 2013-06-09 02:22:23 +10:00
Philipp Brüschweiler
a99ba1180d rustc::regionck: fix ICE when getting signature of ty_err
Fixes #5062
2013-06-08 09:34:47 +02:00
Philipp Brüschweiler
f3f9db133a rustc: Fix an ICE "Autoderef but type not derefable"
Related to #5062 (same error message), but that test case causes
a different ICE than mentioned there (even without this fix).
2013-06-08 09:34:32 +02:00
Björn Steinbrink
2096d79626 Avoid unnecessary allocations in the metadata decoder 2013-06-08 03:27:48 +02:00
Björn Steinbrink
29e5aa0942 Remove some unnecessary closures 2013-06-08 03:24:47 +02:00
Björn Steinbrink
b65dc42b25 TypeChecker: Avoid unnecessary copies 2013-06-08 03:24:47 +02:00
Björn Steinbrink
96798f5e05 tydecode: Accept a plain borrowed pointer to the data 2013-06-08 03:24:47 +02:00
Björn Steinbrink
51e85f5e6e Avoid unnecessary heap allocations in the metadata ty decoder 2013-06-08 03:24:47 +02:00
Philipp Brüschweiler
080a462050 rustc::typeck: fix array out of bounds
Fixes #6155
2013-06-07 22:09:01 +02:00
Daniel Micay
d945543ebf Merge branch 'each-fn-kill' of https://github.com/huonw/rust into each-fn-kill 2013-06-07 14:43:02 -04:00
Huon Wilson
54d914a9a9 std: remove each[i]_mut functions, in favour of iterators. 2013-06-08 03:24:27 +10:00
Huon Wilson
bc81d279fa rustc: Convert a fail! to a useful error message. 2013-06-08 01:46:49 +10:00
Huon Wilson
f661a15b2b std: remove vec::each2 and vec::each2_mut in favour of iterators 2013-06-08 01:20:47 +10:00
Philipp Brüschweiler
9b3743938d rustc::metadata::decoder: cleanup and slightly speed up each_path 2013-06-07 10:00:48 +02:00
bors
4abd83b18d auto merge of #6985 : Aatch/rust/fixed-vec-6977, r=thestinger
This fixes #6977. Negative counts don't make sense anyway.
2013-06-06 20:34:32 -07:00
James Miller
de27064d84 Disallow negative counts in repeat expressions 2013-06-07 12:30:44 +12:00
bors
145279709d auto merge of #6980 : Kimundi/rust/iterator-collect3, r=thestinger 2013-06-06 14:46:41 -07:00
Marvin Löbel
cac4891154 Fixups 2013-06-06 22:40:35 +02:00
Michael Sullivan
8bbf83b62a Clean up a handful of build warnings. 2013-06-06 12:14:41 -07:00
Philipp Brüschweiler
13df1198d5 infer: remove superfluous call to try() 2013-06-06 11:53:09 +02:00
Alexei Sholik
e75572c879 Deduplicate words in code comments 2013-06-06 10:48:27 +03:00
bors
2c65e2e385 auto merge of #6956 : Blei/rust/fix-symbol-mangling, r=catamorphism
Handle more characters that appear in types, most notably <>): were
missing. Also the new scheme takes care that no two different input
strings result in the same mangled string, which was not the case before.

Fixes #6921
2013-06-05 14:13:43 -07:00
Philipp Brüschweiler
eb62781720 rustc:🔙🔗 redo symbol mangling
Handle more characters that appear in types, most notably <>): were
missing. Also the new scheme takes care that no two different input
strings result in the same mangled string, which was not the case before.

Fixes #6921
2013-06-05 22:21:25 +02:00
John Clements
8dad2bb281 removed unused imports (and one unused argument) 2013-06-05 12:01:39 -07:00
John Clements
04a691a511 token_to_ident takes argument by reference 2013-06-05 12:01:38 -07:00
John Clements
3203595471 interner just uses uints, not idents with syntax context 2013-06-05 12:01:38 -07:00
John Clements
ae02bf70e0 removed some interner fields 2013-06-05 12:01:38 -07:00
John Clements
22d21ab4c2 rename repr to name 2013-06-05 12:01:37 -07:00
bors
e2d0a30fa2 auto merge of #6947 : Blei/rust/fix-dup-freevars, r=bstrie 2013-06-05 05:19:41 -07:00
Philipp Brüschweiler
c08df70f2b rust::driver: remove accidental double freevar calculation 2013-06-05 13:31:19 +02:00
Patrick Walton
8114d0e950 librustc: Disallow multiple patterns from appearing in a "let" declaration.
You can still initialize multiple variables at once with "let (x, y) = (1, 2)".
2013-06-04 21:45:42 -07:00
bors
69511c219c auto merge of #6928 : Blei/rust/fix-constructors, r=bstrie
As part of #3853
2013-06-04 09:37:41 -07:00
Philipp Brüschweiler
e1c1c059c6 std::io: Modernize some constructors
Part of #3853
2013-06-04 12:47:45 +02:00
Philipp Brüschweiler
34ee63e93b std::cell: Modernize constructors
Part of #3853
2013-06-04 12:03:58 +02:00
Jed Davis
0c9510ac38 Use ABI alignment, not "preferred" alignment, to unify monomorphizations.
See the comment in the added test case for details.
2013-06-04 00:18:48 -07:00
Michael Sullivan
d85938f7c8 Make type_is_pod handle structs correctly. Closes #6868. 2013-06-03 17:16:12 -07:00
Philipp Brüschweiler
394ac1aae4 resolve: don't resolve paths that point to non-static methods
Fixes #6698
2013-06-03 13:31:43 +02:00
Björn Steinbrink
b51f44e21b Fix passing self by value for types passed by value
For types that are passed by value, we can't just cast the value to a
pointer, but have to use an alloca and copy the value there. This
handling is already present for all other arguments, but was missing
for "self".

Fixes #6682, #4850 and #4878
2013-06-03 00:06:09 +02:00
bors
fc5debd8fd auto merge of #6807 : catamorphism/rust/rustpkg-extern-mod, r=catamorphism
r? @graydon Addresses #5681
2013-06-01 19:22:42 -07:00
Tim Chevalier
c120464be0 rustc/rusti/rustpkg: Infer packages from extern mod directives
This commit won't be quite as useful until I implement RUST_PATH and
until we change `extern mod` to take a general string instead of
an identifier (#5682 and #6407).

With that said, now if you're using rustpkg and a program contains:

extern mod foo;

rustpkg will attempt to search for `foo`, so that you don't have to
provide a -L directory explicitly. In addition, rustpkg will
actually try to build and install `foo`, unless it's already
installed (specifically, I tested that `extern mod extra;` would
not cause it to try to find source for `extra` and compile it
again).

This is as per #5681.

Incidentally, I changed some driver code to infer the link name
from the crate link_meta attributes. If that change isn't ok, say
something. Also, I changed the addl_lib_search_paths field in the
session options to be an @mut ~[Path] so that it can be modified
after expansion but before later phases.
2013-06-01 18:48:07 -07:00
Tim Chevalier
341678b815 rustc: Call str::is_empty 2013-06-01 18:48:07 -07:00
Tim Chevalier
231aea6d6e rustc: Improve astconv error message 2013-06-01 18:48:07 -07:00
bors
63417daea4 auto merge of #6885 : erickt/rust/move-callee_id, r=catamorphism
The `callee_id` in `ast::expr` in only used in a couple expression variants. This moves the `callee_id` into those branches to make it more clear when its should be used.

Also, it fixes a bug in a std::run test when there is a symlink in the path rust where was checked out.
2013-06-01 17:13:39 -07:00
bors
24e85ac82d auto merge of #6880 : thomaslee/rust/issue-6745, r=catamorphism
This fixes #6745, which itself relates to #4202. Slightly ham-fisted -- feel particularly funny about using the typeck phase to gather the base -> impl mapping, and the separate code paths for traits vs. "real" bases feels like it could be avoided -- but it seems to work.

As always, open to suggestions if there's a better way to accomplish what I'm trying to do.

@catamorphism r?
2013-06-01 15:46:40 -07:00
Erick Tryzelaar
23808efd11 syntax: move callee_id into the expr_ variants 2013-06-01 15:31:56 -07:00
Luqman Aden
64759c9f25 librustc: Have destructor run for unit-like structs. 2013-06-01 17:41:07 -04:00
Patrick Walton
5fb254695b Remove all uses of pub impl. rs=style 2013-06-01 09:18:27 -07:00
Patrick Walton
1e52eede31 librustc: Don't require pub extern to make extern functions visible 2013-06-01 09:16:46 -07:00
bors
b8391ccea0 auto merge of #6881 : Aatch/rust/new-passes-2, r=thestinger
This is a better pipeline, both faster-running and produces faster code.

For some reason the `mergefunc` pass screws over resolve. I have no idea why though.
2013-06-01 06:13:40 -07:00
James Miller
6e075b6bb6 Better optimization pipeline 2013-06-02 00:08:38 +12:00
Tom Lee
42466949c2 Fix a small typo in a comment. 2013-06-01 04:24:31 -07:00
Tom Lee
f6fa5b91e2 Reexport static methods on structs & enums. 2013-06-01 04:14:58 -07:00
bors
2bf053c0a3 auto merge of #6851 : alexcrichton/rust/bugfixes, r=pcwalton
Closes #5090 by using the excellent new generic deriving code

Promotes the unreachable code attribute to a lint attribute (instead of always being a warning)

Fixes some edge cases when creating hashmaps/hashsets and also when consuming them. (fixes #5998)
2013-05-31 23:10:36 -07:00
bors
5028ac7396 auto merge of #6863 : huonw/rust/error-span, r=thestinger 2013-05-31 07:43:49 -07:00
Huon Wilson
4f92d3a11c rustc: adjust span for error message to not trim last letter 2013-06-01 00:39:02 +10:00
James Miller
85e3c96236 Remove the slow bb-vectorize pass 2013-05-31 09:01:13 -04:00
bors
030f471f26 auto merge of #6853 : bblum/rust/sized, r=pcwalton
r? @nikomatsakis @pcwalton
2013-05-31 02:01:44 -07:00
bors
1dd5cd9731 auto merge of #6833 : fdr/rust/fix-warnings, r=Aatch
Fix a laundry list of warnings involving unused imports that glutted
up compilation output.  There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
2013-05-31 00:43:45 -07:00
bors
6fcb483609 auto merge of #6848 : pcwalton/rust/issue-6352, r=pcwalton
r? @nikomatsakis
2013-05-30 23:31:48 -07:00
bors
3869f7a99c auto merge of #6818 : nikomatsakis/rust/irrefut-patterns-refactoring, r=graydon
Various bug fixes and simplifications I did as part of a patch to fix `let` patterns.

r? @catamorphism
2013-05-30 19:04:52 -07:00
Alex Crichton
aed53f9bf0 Promote unreachable code to being a lint attribute 2013-05-30 20:45:13 -05:00
Ben Blum
b8a53b5a4c Add 'Sized' builtin kind; doesn't do anything yet 2013-05-30 21:41:41 -04:00
Patrick Walton
40b455792d librustc: Bump the offset when translating const structs. Closes #6352. 2013-05-30 18:17:32 -07:00
Graydon Hoare
2bed5dc528 rustc: change 'use' to 'add' in error message, fix #2994 2013-05-30 13:45:53 -07:00
Daniel Farina
aef1e10eba Remove unnecessary 'use' forms
Fix a laundry list of warnings involving unused imports that glutted
up compilation output.  There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
2013-05-30 13:08:18 -07:00
Niko Matsakis
9c7eb068e5 Replace NDM with proper FIXME 2013-05-30 15:20:36 -04:00
Niko Matsakis
7a1a40890d Remove copy bindings from patterns. 2013-05-30 15:20:36 -04:00
Niko Matsakis
5209709e46 Fix matching of rvalues with destructors
Fixes #4542.
2013-05-30 15:20:36 -04:00
Niko Matsakis
c492a2126f Remove some spurious copies that are identified by later patches 2013-05-30 09:54:39 -04:00
Niko Matsakis
7dfb865339 Remove local_imm/local_mem since all variables are now by reference 2013-05-30 09:54:38 -04:00
Niko Matsakis
2616581863 Refactor helper routines to be less tied to match syntax 2013-05-30 09:47:15 -04:00
Niko Matsakis
dcd84901c6 Remove TrByImplicitRef and source field on datums 2013-05-30 09:47:14 -04:00
Björn Steinbrink
1720d9f663 Remove a bunch of unnecessary allocations and copies 2013-05-30 11:49:04 +02:00
Alex Crichton
4a5d887b58 Allow doc(hidden) and --test to disable doc linting 2013-05-30 01:02:55 -05:00
Alex Crichton
af995ce1e7 Make missing documentation linting more robust
Add some more cases for warning about missing documentation, and also add a test
to make sure it doesn't die in the future.
2013-05-30 01:02:55 -05:00
Erick Tryzelaar
b916e65f3e librustc: add some imports to back/passes.rs rs=burningtree 2013-05-29 20:00:43 -07:00
Patrick Walton
206ab89629 librustc: Stop reexporting the standard modules from prelude. 2013-05-29 19:04:53 -07:00
Patrick Walton
4e3d4b36dc libsyntax: Stop parsing mutable fields 2013-05-29 19:04:51 -07:00
Patrick Walton
aeda178011 librustc: Redo the unsafe checker and make unsafe methods not callable from safe code 2013-05-29 19:04:50 -07:00
bors
b5da389d36 auto merge of #6799 : Aatch/rust/pass-refactor, r=graydon
This refactors pass handling to use the argument names, so it can be used
in a similar manner to `opt`. This may be slightly less efficient than the
previous version, but it is much easier to maintain.

It also adds in the ability to specify a custom pipeline on the command
line, this overrides the normal passes, however. This should completely
close #2396.
2013-05-29 16:58:44 -07:00
bors
d2957091c4 auto merge of #6733 : alexcrichton/rust/issue-2400, r=brson
Most of the relevant information can be found in the commit messages.

r? @brson - I just wanted to make sure the make changes aren't completely bogus

This would close #2400, #6517, and #6489 (although a run through incoming-full on linux would have to confirm the latter two)
2013-05-29 12:13:49 -07:00
bors
844b5cff36 auto merge of #6794 : thestinger/rust/align_zero, r=pcwalton
This is unlikely to alter optimized codegen much but there's no point in downgrading the known alignment to 1.
2013-05-29 07:32:06 -07:00
James Miller
faf1afee16 Further refactor optimization pass handling
This refactors pass handling to use the argument names, so it can be used
in a similar manner to `opt`. This may be slightly less efficient than the
previous version, but it is much easier to maintain.

It also adds in the ability to specify a custom pipeline on the command
line, this overrides the normal passes, however. This should completely
close #2396.
2013-05-29 20:08:20 +12:00
bors
e3e55c5c04 auto merge of #6793 : graydon/rust/drop-ast-before-llvm, r=Aatch 2013-05-29 00:52:47 -07:00
bors
d80642b519 auto merge of #6784 : nikomatsakis/rust/moves-into-borrowck, r=pcwalton
Move the computation of what data is moved out of `liveness` and into `borrowck`. The resulting code is cleaner, since before we had a split distribution of responsibilities, and also this avoids having multiple implementations of the dataflow code. Liveness is still used to report warnings about useless writes. This will go away when we get the control-flow graph code landed (working on that).

Also adds borrow checker documentation.

Fixes #4384.
Required to support once fns and to properly fix closures (#2202).
First step to generalize our treatment of moves somewhat as well.
2013-05-28 22:16:50 -07:00
Alex Crichton
ff86830c9c Define rustc's host triple at compile time
This way a cross-compiled rustc's answer to host_triple() is correct. The return
value of host_triple() reflects the actual host triple that the compiler was
build for, not the triple the compiler is being built on
2013-05-28 21:23:42 -05:00
James Miller
6861d542a2 Remove now-unused import 2013-05-29 14:16:49 +12:00
James Miller
998e2ce4ff Remove passes that were causing bad optmizations 2013-05-29 14:16:49 +12:00
James Miller
4988c89e86 Move the initial dead prototype removal pass 2013-05-29 14:16:49 +12:00
James Miller
a5b87d71e0 Fix pass creation typo 2013-05-29 14:16:49 +12:00
James Miller
d694e283b3 Refactor optimization pass handling.
Refactor the optimization passes to explicitly use the passes. This commit
just re-implements the same passes as were already being run.

It also adds an option (behind `-Z`) to run the LLVM lint pass on the
unoptimized IR.
2013-05-29 14:16:49 +12:00
bors
e3d0c1eb0e auto merge of #6731 : thomaslee/rust/issue-6575, r=pcwalton
Fix for #6575. In the trans phase, rustc emits code for a function parameter that goes completely unused in the event the return type of the function in question happens to be an immediate.

This patch modifies rustc & parts of rustrt to ensure that the vestigial parameter is no longer present in compiled code.
2013-05-28 17:37:57 -07:00
Niko Matsakis
f30b538929 Update documentation for moves 2013-05-28 20:22:15 -04:00
Niko Matsakis
e35db1ab35 Reconcile treatment of &mut with the docs 2013-05-28 20:22:15 -04:00
Niko Matsakis
bf1647c92a Reconcile docs and code, adding examples and adding RESTR_CLAIM 2013-05-28 20:22:15 -04:00
Niko Matsakis
329f7a17e2 Update docs on the formal basis of the borrow checker. 2013-05-28 20:22:15 -04:00
Niko Matsakis
5851d3242c Move checking for moves and initialization of local variables and patterns into
borrow checker and generalize what moves are allowed. Fixes a nasty
bug or two in the pattern move checking code. Unifies dataflow code
used for initialization and other things. First step towards
once fns. Everybody wins.

Fixes #4384. Fixes #4715. cc once fns (#2202), optimizing local moves (#5016).
2013-05-28 20:22:14 -04:00
Daniel Micay
9ab2921300 use the type's alignment for generated memsets 2013-05-28 18:38:46 -04:00
Graydon Hoare
b4a3fe25c6 librustc: drop AST before running LLVM, frees 400mb on a librustc build 2013-05-28 15:31:32 -07:00
bors
d7e1f08b21 auto merge of #6774 : alexcrichton/rust/silence-warnings, r=graydon
Also as a bonus this fixes #6767
2013-05-28 13:35:05 -07:00
Alex Crichton
b04c40bb1c Silence various warnings throughout test modules 2013-05-28 15:27:35 -05:00
Daniel Micay
accc5272f8 noalias on all &mut parameters is too coarse
it can alias `&const` and `@mut`
2013-05-28 13:05:50 -04:00
bors
b738b5766e auto merge of #6754 : thestinger/rust/noalias, r=nikomatsakis
The compiler guarantees that there are no other references to a unique pointer when it's passed by-value to a function.

The existence of the header and annihilator don't matter since it's not relevant to the call:

> For a call to the parent function, dependencies between memory references from before or after the call and from those during the call are “irrelevant” to the noalias keyword for the arguments and return value used in that call.

@graydon's tracing garbage collector stores the metadata outside of the boxes, so that won't be a problem. I'm unsure if updating the header while inside a function where it's marked as `noalias` would be a problem anyway since you never actually read or write to the header.

@nikomatsakis: r?
2013-05-28 02:59:03 -07:00
bors
6264df5331 auto merge of #6777 : alexcrichton/rust/less-memory, r=graydon
Via my super-accurate timing (`/usr/bin/time -l`), I get 2431119360 => 1884430336 == ~520MB

Closes #6637.
2013-05-27 22:29:09 -07:00
Alex Crichton
ae7df57c5a Prevent refcount cycles during linting
Shaves off ~600MB of memory while compiling rustc
2013-05-27 22:22:09 -05:00
Graydon Hoare
3c4ce79518 rustc: Switch ty::node_type_table to smallintmap, cut 400mb memory use off a librustc build.
Smallintmap was being populated with sparse keys during ast deserialization.
2013-05-27 19:50:49 -07:00
Tom Lee
b7f71e1ee6 Implementing suggestions from @nikomatsakis 2013-05-27 19:34:25 -07:00
bors
2061ce9aff auto merge of #6741 : pcwalton/rust/intra-crate-start, r=graydon
r? @brson
2013-05-27 18:26:04 -07:00
Tom Lee
67283eaad2 Omit unused implicit argument if return type is immediate. 2013-05-27 17:13:01 -07:00
bors
dbc57584bd auto merge of #6724 : thestinger/rust/swap_fast, r=thestinger
Passing higher alignment values gives the optimization passes more freedom since it can copy in larger chunks. This change results in rustc outputting the same post-optimization IR as clang for swaps and most copies excluding the lack of information about padding.

Code snippet:

```rust
#[inline(never)]
fn swap<T>(x: &mut T, y: &mut T) {
    util::swap(x, y);
}
```

Original IR (for `int`):

```llvm
define internal fastcc void @_ZN9swap_283417_a71830ca3ed2d65d3_00E(i64*, i64*) #1 {
static_allocas:
  %2 = icmp eq i64* %0, %1
  br i1 %2, label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit, label %3

; <label>:3                                       ; preds = %static_allocas
  %4 = load i64* %0, align 1
  %5 = load i64* %1, align 1
  store i64 %5, i64* %0, align 1
  store i64 %4, i64* %1, align 1
  br label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit

_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit:  ; preds = %3, %static_allocas
  ret void
}
```

After #6710:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 1
  %3 = load i64* %1, align 1
  store i64 %3, i64* %0, align 1
  store i64 %2, i64* %1, align 1
  ret void
}
```

After this change:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 8
  %3 = load i64* %1, align 8
  store i64 %3, i64* %0, align 8
  store i64 %2, i64* %1, align 8
  ret void
}
```

Another example:

```rust
#[inline(never)]
fn set<T>(x: &mut T, y: T) {
    *x = y;
}
```

Before, with `(int, int)` (align 1):

```llvm
define internal fastcc void @_ZN8set_282517_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 1, i1 false)
  ret void
}
```

After, with `(int, int)` (align 8):

```llvm
define internal fastcc void @_ZN8set_282617_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  ret void
}
```
2013-05-27 15:56:08 -07:00
bors
5d04ee805b auto merge of #6715 : Xazax-hun/rust/incoming, r=graydon
Preliminary implementation for: https://github.com/mozilla/rust/issues/6275

This is my first (non hello world) rust code, so it may not be idiomatic.
2013-05-27 13:44:08 -07:00
bors
b0f3686515 auto merge of #6703 : sanxiyn/rust/allocation-lint, r=sanxiyn
Fix #6145. In particular, handle operator overloading.
2013-05-27 12:38:12 -07:00
Seo Sanghyeon
8f80323f09 Remove unnecessary allocations flagged by lint 2013-05-28 03:14:44 +09:00
Seo Sanghyeon
363e672736 Use adjustments table for allocation lint 2013-05-28 03:12:13 +09:00
gareth
76c31217be Refactor core::run in order to address many of the issues
mentioned in #2625.

This change makes the module more oriented around
Process values instead of having to deal with process ids
directly.

Apart from issues mentioned in #2625, other changes include:
- Changing the naming to be more consistent - Process/process
  is now used instead of a mixture of Program/program and
  Process/process.
- More docs/tests.

Some io/scheduler related issues remain (mentioned in #2625).
2013-05-27 13:50:33 +01:00
bors
d577eafff3 auto merge of #6688 : graydon/rust/issue-3396-mystery-bug-in-metadata, r=Aatch
Whatever it was, it is no longer a problem here.
2013-05-27 04:38:04 -07:00
bors
fa67e091e4 auto merge of #6719 : kud1ing/rust/rustc_w, r=bstrie
Fixes #6697
2013-05-26 22:26:06 -07:00