Commit Graph

1852 Commits

Author SHA1 Message Date
Alex Crichton
f9bf69d253 Remove all external requirements of @ from TLS
Closes #6004
2013-07-11 00:37:13 -07:00
Brendan Cully
990dc435aa unused variable 2013-07-10 22:23:09 -07:00
Brendan Cully
202fcb29bd unnecessarily mutable variables 2013-07-10 22:12:30 -07:00
Brendan Cully
e6e4f52bcf remove unused imports 2013-07-10 22:08:50 -07:00
bors
e7040e8a24 auto merge of #7698 : nikomatsakis/rust/issue-2951-type-parameter-names, r=cmr
Fixes #2951
2013-07-10 14:37:39 -07:00
Niko Matsakis
4412df20ae Add an identifier to TypeParameterDefs and use it to pretty print type parameters 2013-07-10 14:42:53 -04:00
Seo Sanghyeon
2bc06b40ba Implement SIMD arithmetics 2013-07-10 23:35:59 +09:00
Seo Sanghyeon
f81986031c Add a lint to detect unnecessarily qualified names 2013-07-10 19:09:03 +09:00
Alex Crichton
cb5b9a477c Rename local_data methods/types for less keystrokes 2013-07-09 17:39:49 -07:00
bors
137d1fb210 auto merge of #7657 : thestinger/rust/rollup, r=thestinger
d3be8ab r=brson
05eb3cf r=thestinger
c80f4e1 r=huonw
8c27af1 r=huonw
0eee0b6 r=cmr
ea2756a r=thestinger
2013-07-09 15:13:40 -07:00
Alex Crichton
31114acdd7 Require extern "Rust" fn main() exactly 2013-07-09 16:56:16 -04:00
Daniel Micay
a4af0960bd remove the unused exchange_malloc align parameter
`malloc` already returns memory correctly aligned for every possible
type in standard C, and that's enough for all types in Rust too
2013-07-09 16:35:56 -04:00
bors
e388a80c23 auto merge of #7117 : jensnockert/rust/freestanding, r=cmr
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

This means that instead of having to know everywhere what the type is, like

~~~
f64::sin(x)
~~~

You can simply write code that uses the type-generic versions in num instead, this works for all types that implement the corresponding trait in num.

~~~
num::sin(x)
~~~

Note 1: If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note 2: If you were using a function that corresponds to an operator, use the
operator instead.

Note 3: This is just https://github.com/mozilla/rust/pull/7090 reopened against master.
2013-07-09 13:34:50 -07:00
Niko Matsakis
3b8c5a1a37 Constrain maximum lifetime of stack closures that capture variables to
be limited by the innermost repeating scope.

Fixes #7336.
2013-07-09 10:38:26 -04:00
bors
a48ca3290d auto merge of #7262 : nikomatsakis/rust/ref-bindings-in-irrefut-patterns, r=catamorphism
Correct treatment of irrefutable patterns. The old code was wrong in many, many ways. `ref` bindings didn't work, it sometimes copied when it should have moved, the borrow checker didn't even look at such patterns at all, we weren't consistent about preventing values with destructors from being pulled apart, etc.

Fixes #3224.
Fixes #3225.
Fixes #3255.
Fixes #6225.
Fixes #6386.

r? @catamorphism
2013-07-08 18:49:46 -07:00
Niko Matsakis
0c6d02f391 Correct merge errors 2013-07-08 13:55:11 -04:00
Niko Matsakis
979d3a54f9 Correct merge failures 2013-07-08 13:55:11 -04:00
Niko Matsakis
ce602c66b8 Add llvm instrumentation 2013-07-08 13:55:11 -04:00
Niko Matsakis
0e81072ded Move stats into an @mut stats 2013-07-08 13:55:11 -04:00
Niko Matsakis
541c45b0b7 Miscellaneous fixes and cleanup 2013-07-08 13:55:10 -04:00
Niko Matsakis
729b07f83c Modify borrow checker to visit irrefutable patterns that appear in
let and function arguments; modify type checker to store type
information for all patterns and handles some missing cases.
2013-07-08 13:55:10 -04:00
Niko Matsakis
2d3262ca7b Update trans to use type to decide when to move, not the moves table (simpler
for cases where it's hard to decide what id to use for the lookup); modify
irrefutable bindings code to move or copy depending on the type, rather than
threading through a flag. Also updates how local variables and arguments are
registered. These changes were hard to isolate.
2013-07-08 13:55:10 -04:00
Niko Matsakis
41efcdf299 Make all allocas named so we can see where they originate
in the generated LLVM code.
2013-07-08 13:55:10 -04:00
Brian Anderson
b0a9d8193f Bump version numbers to 0.8-pre 2013-07-08 10:25:45 -07:00
Jens Nockert
1aae28a57d Replaces the free-standing functions in f32, &c.
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note: If you were using a function that corresponds to an operator, use
the operator instead.
2013-07-08 18:05:17 +02:00
Björn Steinbrink
00ba8b3ac0 Improve handling of immediate return values
We currently still handle immediate return values a lot like
non-immediate ones. We provide a slot for them and store them into
memory, often just to immediately load them again. To improve this
situation, trans_call_inner has to return a Result which contains the
immediate return value.

Also, it also needs to accept "No destination" in addition to just
SaveIn and Ignore. Since "No destination" isn't something that fits
well into the Dest type, I've chosen to simply use Option<Dest>
instead, paired with an assertion that checks that "None" is only
allowed for immediate return values.
2013-07-08 13:34:13 +02:00
Björn Steinbrink
4a485f8cec Avoid unused allocas for immediate return values
There's no need to allocate a return slot for anykind of immediate
return value, not just not for nils. Also, when the return value is
ignored, we only have to copy it to a temporary alloca if it's actually
required to call drop_ty on it.
2013-07-08 13:17:46 +02:00
bors
48ad726f2a auto merge of #7605 : thestinger/rust/vec, r=Aatch
This is work continued from the now landed #7495 and #7521 pulls.

Removing the headers from unique vectors is another project, so I've separated the allocator.
2013-07-08 02:52:56 -07:00
Daniel Micay
90f1db10fa remove headers from exchange allocations 2013-07-08 04:54:41 -04:00
Daniel Micay
44770ae3a8 Merge pull request #7595 from thestinger/iterator
remove some method resolve workarounds
2013-07-08 01:42:07 -07:00
Daniel Micay
0aedecf96b add a temporary vector_exchange_malloc lang item 2013-07-08 03:41:21 -04:00
Alex Crichton
a02e37c397 Fix a warning when generating tests 2013-07-07 19:03:57 -07:00
Daniel Micay
641aec7407 remove some method resolve workarounds 2013-07-07 19:51:13 -04:00
bors
28643d4135 auto merge of #7456 : graydon/rust/better-trans-stats, r=cmr
This way when you compile with -Z trans-stats you'll get a per-function cost breakdown, sorted with the most expensive functions first. Should help highlight pathological code.
2013-07-07 12:53:06 -07:00
bors
52abd1cc32 auto merge of #7636 : dotdash/rust/scope_cleanup, r=graydon
Currently, scopes are tied to LLVM basic blocks. For each scope, there
are two new basic blocks, which means two extra jumps in the unoptimized
IR. These blocks aren't actually required, but only used to act as the
boundary for cleanups.

By keeping track of the current scope within a single basic block, we
can avoid those extra blocks and jumps, shrinking the pre-optimization
IR quite considerably. For example, the IR for trans_intrinsic goes
from ~22k lines to ~16k lines, almost 30% less.

The impact on the build times of optimized builds is rather small (about
1%), but unoptimized builds are about 11% faster. The testsuite for
unoptimized builds runs between 15% (CPU time) and 7.5% (wallclock time on
my i7) faster.

Also, in some situations this helps LLVM to generate better code by
inlining functions that it previously considered to be too large.
Likely because of the pointless blocks/jumps that were still present at
the time the inlining pass runs.

Refs #7462
2013-07-07 11:16:59 -07:00
Björn Steinbrink
e41e435851 Implement scopes independent of LLVM basic blocks
Currently, scopes are tied to LLVM basic blocks. For each scope, there
are two new basic blocks, which means two extra jumps in the unoptimized
IR. These blocks aren't actually required, but only used to act as the
boundary for cleanups.

By keeping track of the current scope within a single basic block, we
can avoid those extra blocks and jumps, shrinking the pre-optimization
IR quite considerably. For example, the IR for trans_intrinsic goes
from ~22k lines to ~16k lines, almost 30% less.

The impact on the build times of optimized builds is rather small (about
1%), but unoptimized builds are about 11% faster. The testsuite for
unoptimized builds runs between 15% (CPU time) and 7.5% (wallclock time on
my i7) faster.

Also, in some situations this helps LLVM to generate better code by
inlining functions that it previously considered to be too large.
Likely because of the pointless blocks/jumps that were still present at
the time the inlining pass runs.

Refs #7462
2013-07-07 14:53:57 +02:00
James Miller
280e4245c0 Fix merge-fallout-typo 2013-07-07 23:05:03 +12:00
James Miller
7ce68dc9e1 Clean up warnings 2013-07-07 22:51:10 +12:00
James Miller
47eca2113c De-share ast::Ty 2013-07-07 22:51:10 +12:00
James Miller
46a1f54666 De-manage OptVec<TyParamBounds> 2013-07-07 22:51:10 +12:00
James Miller
97c5a44d3e De-share trait_ref
Also, makes the pretty-printer use & instead of @ as much as possible,
which will help with later changes, though in the interim has produced
some... interesting constructs.
2013-07-07 22:51:09 +12:00
James Miller
62c83bb17b De-manage Lifetime 2013-07-07 22:51:09 +12:00
James Miller
cd1b6c8979 De-managed ast::Path 2013-07-07 22:51:09 +12:00
James Miller
a69eb95233 Stop allocating view_items with @ 2013-07-07 22:51:09 +12:00
bors
88487d8274 auto merge of #7557 : michaelwoerister/rust/enum_structs, r=pcwalton
After getting an ICE trying to use the `Repr` enum from middle::trans::adt (see issue #7527), I tried to implement the missing case for struct-like enum variants in `middle::ty::enum_variants()`. It seems to work now (and passes make check) but there are still some uncertainties that bother me:
+ I'm not sure I did everything, right. Especially getting the variant constructor function from the variant node id is just copied from the tuple-variant case. Someone with more experience in the code base should be able to see rather quickly whether this OK so.
+ It is kind of strange that I could not reproduce the ICE with a smaller test case. The unimplemented code path never seems to be hit in most cases, even when using the exact same `Repr` enum, just with `ty::t` replaced by an opaque pointer. Also, within the `adt` module, `Repr` and matching on it is used multiple times, again without running into problems. Can anyone explain why this is the case? That would be much appreciated. 

Apart from that, I hope this PR is useful.
2013-07-06 23:59:05 -07:00
bors
d243e0047d auto merge of #7572 : Dretch/rust/missing-trait-message-followup, r=pcwalton
This a followup to #7510. @catamorphism requested a test - so I have created one, but in doing so I noticed some inconsistency in the error messages resulting from referencing nonexistent traits, so I changed the messages to be more consistent.
2013-07-06 20:32:09 -07:00
bors
a9f178c148 auto merge of #7570 : kballard/rust/iterator-size-hint, r=thestinger
Change the signature of Iterator.size_hint() to always have a lower bound.

Implement .size_hint() on all remaining iterators (if it differs from the default).
2013-07-06 14:59:09 -07:00
bors
e9897cd08a auto merge of #7598 : sanxiyn/rust/rollup-1, r=sanxiyn
c9b9462 r=z0w0
2e65782 r=cmr
2045889 r=thestinger
30fca57 r=huonw
2013-07-06 06:50:16 -07:00
bors
58eb70a5e2 auto merge of #7554 : jld/rust/rm-ssoe, r=catamorphism 2013-07-05 04:28:56 -07:00
Kevin Ballard
dc9b3ff1b3 Change signature of Iterator.size_hint
Remove the Option wrapper around the lower bound. None is semantically
the same as Size(0), so there's no point in having a distinction.
2013-07-05 01:56:48 -07:00
Seo Sanghyeon
2e65782c17 Do not rely on newtype enum dereference 2013-07-05 13:03:04 +09:00
Seo Sanghyeon
c9b9462e8f Remove visit_struct_method 2013-07-05 13:02:43 +09:00
bors
b055a10662 auto merge of #7545 : msullivan/rust/default-methods, r=catamorphism
r?
2013-07-04 13:49:53 -07:00
bors
e07e9bbf36 auto merge of #7543 : sanxiyn/rust/newtype-immediates, r=catamorphism
Fix #6612. Rebase of #6725. Fixed an additional bug and added a test.
2013-07-03 23:31:56 -07:00
Graydon Hoare
f80d6dc4c1 rustc: improve -Z trans-stats to report per-fn LLVM instruction counts and translation timing 2013-07-03 18:06:36 -07:00
Gareth Smith
908a22b626 Address @catamorphism's error message grammar nit. 2013-07-03 23:43:03 +01:00
bors
648c5e9c92 auto merge of #7534 : bblum/rust/soundness-messages, r=catamorphism 2013-07-03 15:25:55 -07:00
Gareth Smith
656c8f9143 Make the error messages that result from referencing
nonexistent traits consistent, and add a test.
2013-07-03 22:16:08 +01:00
Michael Sullivan
7238d5a141 Make privacy checking on default methods for cross crate structs not fail. Closes #7481.
It is unclear to me that the way method call privacy checking is done
makes any sense, though. It is only performed if the type is a
struct...
2013-07-03 09:59:45 -07:00
Michael Sullivan
419a14772a Fix make_mono_id to take into account self types. Closes #7536. 2013-07-03 09:59:45 -07:00
bors
0c6fc46c03 auto merge of #7566 : huonw/rust/vec-kill, r=cmr
The last remaining internal iterator in `vec` is `each_permutation`.
2013-07-03 08:16:54 -07:00
Huon Wilson
cdea73cf5b Convert vec::{as_imm_buf, as_mut_buf} to methods. 2013-07-04 00:46:50 +10:00
Huon Wilson
f19fb2459f Remove standalone comparison functions in vec, make the trait impls better. 2013-07-04 00:46:50 +10:00
Huon Wilson
9207802589 Remove vec::reversed, replaced by iterators. 2013-07-04 00:46:50 +10:00
Huon Wilson
de0d696561 Remove vec::{filter, filtered, filter_map, filter_mapped}, replaced by iterators. 2013-07-04 00:46:49 +10:00
Huon Wilson
eee6775642 Implement consuming iterators for ~[], remove vec::{consume, consume_reverse, map_consume}. 2013-07-04 00:46:49 +10:00
bors
1cee9d4c38 auto merge of #7531 : sankha93/rust/master, r=bblum
This pull request fixes #7118.
2013-07-03 06:34:56 -07:00
bors
55f155521d auto merge of #7523 : huonw/rust/uppercase-statics-lint, r=cmr
Adds a lint for `static some_lowercase_name: uint = 1;`. Warning by default since it causes confusion, e.g. `static a: uint = 1; ... let a = 2;` => `error: only refutable patterns allowed here`.
2013-07-03 04:31:50 -07:00
bors
ea31b9cca1 auto merge of #7474 : Seldaek/rust/clean-iter, r=thestinger
I think it's WIP - but I wanted to ask for feedback (/cc @thestinger)

I had to move the impl of FromIter for vec into extra::iter because I don't think std can depend on extra, but that's a bit messed up. Similarly some FromIter uses are gone now, not sure if this is fixable or if I made a complete mess here..
2013-07-03 01:07:55 -07:00
bors
025dc6e64e auto merge of #7510 : Dretch/rust/missing-trait-message, r=catamorphism 2013-07-02 22:40:56 -07:00
Michael Woerister
866a5b1c78 Added support for struct-like enum variants in middle::ty::enum_variants(). 2013-07-02 23:35:36 +02:00
Jed Davis
2f27d43166 GC static_size_of_enum, which was unused 2013-07-02 09:27:11 -07:00
Niko Matsakis
ef5c439fb0 Correct merge errors, broken tests 2013-07-01 20:43:55 -04:00
Niko Matsakis
4a0469e3d7 Add copyright notice and kill broken test 2013-07-01 20:43:55 -04:00
Niko Matsakis
e416c9fa17 Adjust documentation to describe how closures and closure bounds
affect things.
2013-07-01 20:43:54 -04:00
Niko Matsakis
d7522fec15 Move existing docs into doc.rs 2013-07-01 20:43:54 -04:00
Niko Matsakis
9d48a7d550 convert region_inference into a module, so I can attach docs 2013-07-01 20:43:54 -04:00
Niko Matsakis
79ea26630d move docs into doc.rs 2013-07-01 20:43:54 -04:00
Niko Matsakis
42344af713 Correct handling of if/match, and make explicit computation of
common supertypes.

This was breaking with the change to regions because of the
(now incorrect) assumpton that our inference code makes,
which is that if a <: b succeeds, there is no need to compute
the LUB/GLB.
2013-07-01 20:43:54 -04:00
Niko Matsakis
9e6d5e152e Defer reasoning about region relationships until after regionck.
This patch makes error handling for region inference failures more
uniform by not reporting *any* region errors until the reigon inference
step. This requires threading through more information about what
caused a region constraint, so that we can still give informative
error messages.

I have only taken partial advantage of this information: when region
inference fails, we still report the same error we always did, despite
the fact that we now know precisely what caused the various constriants
and what the region variable represents, which we did not know before.

This change is required not only to improve error messages but
because the region hierarchy is not in fact fully known until regionck,
because it is not clear where closure bodies fit in (our current
treatment is unsound). Moreover, the relationships between free variables
cannot be fully determined until type inference is otherwise complete.

cc #3238.
2013-07-01 20:43:54 -04:00
Ben Blum
313dd37acb Better error messages in report_use_of_moved_value; close #7286 2013-07-01 15:48:49 -04:00
Sankha Narayan Guria
af30fe25a5 Improve the attempted dynamic environment-capture error message 2013-07-02 01:05:57 +05:30
bors
e482856d76 auto merge of #7409 : alexcrichton/rust/threadsafe, r=cmr
@catamorphism, this re-enables threadsafe rustpkg tests, @brson this will fail unless the bots have LLVM rebuilt, so this is a good indicator of whether that happened or not.
2013-07-01 11:29:24 -07:00
Seo Sanghyeon
8aa26ad454 Fix dereference of temporary immediate newtype structs 2013-07-02 01:08:51 +09:00
Alex Crichton
5183a6cc6c Turn on using LLVM threadsafely 2013-07-01 08:30:05 -07:00
bors
b44953b8a3 auto merge of #7488 : yichoi/rust/sanitize_utf8, r=huonw
back:🔗:sanitize support escape_utf8
fix #7486
2013-07-01 08:03:15 -07:00
bors
0bd67f6891 auto merge of #7443 : yjh0502/rust/fix_field_dup, r=huonw
Check if there is duplicated field names in struct.
2013-07-01 04:37:59 -07:00
bors
d324014c6c auto merge of #7521 : thestinger/rust/vec, r=Aatch
continued from #7495
2013-07-01 02:26:46 -07:00
Huon Wilson
c437a16c5d rustc: add a lint to enforce uppercase statics. 2013-07-01 17:52:57 +10:00
Huon Wilson
da4384583b lint: make the non_camel_case_types lint work with scripts without a upper/lowercase distinction. 2013-07-01 17:46:57 +10:00
Young-il Choi
567cf30450 librustc: apply changes of char::escape_unicode 2013-07-01 16:11:32 +09:00
Young-il Choi
d387e78712 librustc: back:🔗:sanitize support esacpe_utf8 2013-07-01 16:10:10 +09:00
bors
07feeb95c5 auto merge of #7487 : huonw/rust/vec-kill, r=cmr
Continuation of #7430.

I haven't removed the `map` method, since the replacement `v.iter().transform(f).collect::<~[SomeType]>()` is a little ridiculous at the moment.
2013-06-30 21:14:13 -07:00
Seo Sanghyeon
fd19289108 Classify newtype structs S(T) as immediates if T is an immediate 2013-07-01 13:02:14 +09:00
Daniel Micay
5b40f2ae5b pass exchange_malloc an alignment, not a tydesc 2013-06-30 23:30:40 -04:00
bors
1c48aac9aa auto merge of #7517 : brson/rust/0.7, r=brson 2013-06-30 17:34:58 -07:00
Jordi Boggiano
3fe05a987c Move most iter functionality to extra, fixes #7343 2013-07-01 01:50:40 +02:00
Jordi Boggiano
0fc99f1997 Add an EnumSetIterator and EnumSet::iter 2013-07-01 01:50:27 +02:00
Brian Anderson
a766a955a9 Bump version from 0.7-pre to 0.7 2013-06-30 16:36:48 -07:00
bors
040ac2a932 auto merge of #7495 : thestinger/rust/exchange, r=cmr
With these changes, exchange allocator headers are never initialized, read or written to. Removing the header will now just involve updating the code in trans using an offset to only do it if the type contained is managed.

The only thing blocking removing the initialization of the last field in the header was ~fn since it uses it to store the dynamic size/types due to captures. I temporarily switched it to a `closure_exchange_alloc` lang item (it uses the same `exchange_free`) and #7496 is filed about removing that.

Since the `exchange_free` call is now inlined all over the codebase, I don't think we should have an assert for null. It doesn't currently ever happen, but it would be fine if we started generating code that did do it. The `exchange_free` function also had a comment declaring that it must not fail, but a regular assert would cause a failure. I also removed the atomic counter because valgrind can already find these leaks, and we have valgrind bots now.

Note that exchange free does not currently print an error an out-of-memory when it aborts, because our `io` code may allocate. We could probably get away with a `#[rust_stack]` call to a `stdio` function but it would be better to make a write system call.
2013-06-30 15:02:05 -07:00