Commit Graph

23452 Commits

Author SHA1 Message Date
Jed Davis c0190a9cfb Prevent unoptimized rustpkg tests from running out of stack.
The actual fix would be to make rustpkg use `rustc::monitor` so it picks
up anything special that rustc needs, but for now let's keep the tests
from breaking.
2013-10-29 09:09:20 -07:00
Jed Davis 49f851c2c9 Fix type_of for enums to not lose data in some cases when immediate.
The previous implementation, when combined with small discriminants and
immediate types, caused problems for types like `Either<u8, i16>` which
are now small enough to be immediate and can have fields intersecting
the highest-alignment variant's alignment padding (which LLVM doesn't
preserve).  So let's not do that.
2013-10-29 09:09:20 -07:00
Jed Davis ac4644d7de Add another discriminant-size-related test, this time with fields. 2013-10-29 09:09:20 -07:00
Jed Davis 472d798dc1 Work around const_eval issues by changing signed integer `min_value`s.
Otherwise, run-pass/deriving-primitive.rs breaks on 32-bit platforms,
because `int::min_value` is `0xffffffff7fffffff` when evaluated for the
discriminant declaration.
2013-10-29 09:09:20 -07:00
Jed Davis de9bb9738d Add tests for enum discriminant sizing. 2013-10-29 09:09:20 -07:00
Jed Davis afab3307a0 C-like enums are not always immediate 2013-10-29 09:09:20 -07:00
Jed Davis fcfbfde0b7 Adjust reflection for the possibility of discriminants larger than int.
Not only can discriminants be smaller than int now, but they can be
larger than int on 32-bit targets.  This has obvious implications for the
reflection interface.  Without this change, things fail with LLVM
assertions when we try to "extend" i64 to i32.
2013-10-29 09:09:20 -07:00
Jed Davis 92109b1202 Yet more neatening 2013-10-29 09:09:20 -07:00
Jed Davis 727731f89e Assorted cleanups suggested by reviewers. 2013-10-29 09:09:20 -07:00
Jed Davis 01097cbab0 Unbreak the debuginfo tests.
The variant used in debug-info/method-on-enum.rs had its layout changed
by the smaller discriminant, so that the `u32` no longer overlaps both
of the `u16`s, and thus the debugger is printing partially uninitialized
data when it prints the wrong variant.

Thus, the test runner is modified to accept wildcards (using a string
that should be unlikely to occur literally), to allow for this.
2013-10-29 09:09:20 -07:00
Jed Davis a027f164bc Check repr attribute consistency at check time, not translation.
Note that raising an error during trans doesn't stop the compile or cause
rustc to exit with a failure status, currently, so this is of more than
cosmetic importance.
2013-10-29 09:09:20 -07:00
Jed Davis c8c08763ec Add repr attributes in various places that need them. 2013-10-29 09:09:20 -07:00
Jed Davis ac311ecaab Fix multiple mistakes in adt::is_ffi_safe 2013-10-29 09:09:20 -07:00
Jed Davis 25f953437d Lint non-FFI-safe enums. 2013-10-29 09:09:20 -07:00
Jed Davis 01740acd5a Initial implementation of enum discrimnant sizing.
Allows an enum with a discriminant to use any of the primitive integer
types to store it.  By default the smallest usable type is chosen, but
this can be overridden with an attribute: `#[repr(int)]` etc., or
`#[repr(C)]` to match the target's C ABI for the equivalent C enum.

This commit breaks a few things, due to transmutes that now no longer
match in size, or u8 enums being passed to C that expects int, or
reflection; later commits on this branch fix them.
2013-10-29 09:09:19 -07:00
Jed Davis f1124a2f55 Add parser for `#[repr(...)]`; nothing uses it yet.
Also export enum attrs into metadata, and add a convenient interface for
obtaining the repr hint from either a local or remote definition.
2013-10-29 09:09:19 -07:00
bors e6650c87a3 auto merge of #10142 : pythonesque/rust/issue-8263, r=catamorphism
This is, I think, the minimal change required.  I would have included a test but as far as I can tell there is currently no way to precisely test that the span for an error underlines the correct word.  I did verify it manually.
2013-10-29 07:41:48 -07:00
bors fc766efd16 auto merge of #10141 : kmcallister/rust/current_stack_segment, r=alexcrichton
This was done in 2145de8c and reverted in 0ada7c7f, but Servo needs it.

Closes #10065.

r? @brson
2013-10-29 06:36:43 -07:00
bors 73091583dd auto merge of #10135 : alexcrichton/rust/snapshots, r=thestinger
Plus some migration from `let mut this = self` to `mut self` (yay!)
2013-10-29 02:01:50 -07:00
Joshua Yanovski a71665798b #8263 part 2: Adding struct name. 2013-10-28 23:51:10 -07:00
Joshua Yanovski 01ab8542fb Field identifiers now include specific spans (Closes #8263). 2013-10-28 22:57:34 -07:00
bors 671ab42a3b auto merge of #10127 : thestinger/rust/cold, r=pcwalton
This allows a function to marked as infrequently called, resulting in
any branch calling it to be considered colder.
2013-10-28 22:51:51 -07:00
Keegan McAllister f6b236b9d2 rt::task: Make current_stack_segment public again
This was done in 2145de8c and reverted in 0ada7c7f, but Servo needs it.

Closes #10065.
2013-10-28 20:59:45 -07:00
bors dba6070080 auto merge of #10117 : huonw/rust/dead-visits, r=sanxiyn
Used nowhere, and these are likely incorrect anyway: self needs to be
dereferenced once more otherwise the method calls will be reusing the
current impl... bam! Infinite recursion.
2013-10-28 20:51:30 -07:00
bors c0222cda27 auto merge of #10133 : alexcrichton/rust/another-error, r=thestinger
This cropped up on the bsd bot, and if it's an error that gets thrown then it's
fine to just whitelist another type of error in the test.
2013-10-28 19:26:23 -07:00
Alex Crichton 2290131543 Register new snapshots 2013-10-28 16:56:24 -07:00
bors 8852cb7713 auto merge of #10113 : thestinger/rust/expect, r=cmr
LLVM is unable to determine this for most cases.

http://llvm-reviews.chandlerc.com/D2034 needs to land upstream before
this is going to have an effect. It's harmless to start generating the
expect hint now.
2013-10-28 16:07:14 -07:00
bors cd6e9f4f83 auto merge of #10110 : catamorphism/rust/rustpkg-dependency-build-dir, r=metajack
r? @metajack When invoked with the --rust-path-hack flag, rustpkg was correctly building
the package into the default workspace (and not into the build/ subdirectory of the
parent directory of the source directory), but not correctly putting the output
for any dependencies into the default workspace as well.

Spotted by Jack.
2013-10-28 13:51:39 -07:00
Daniel Micay 541e5f84d7 add support for the `cold` function attribute
This allows a function to marked as infrequently called, resulting in
any branch calling it to be considered colder.
2013-10-28 15:34:50 -04:00
bors 2ab4a6fab0 auto merge of #10095 : huonw/rust/master, r=cmr
Currently each line is a separate bullet point in a list: http://static.rust-lang.org/doc/master/std/task/fn.spawn_sched.html
2013-10-28 12:06:26 -07:00
Alex Crichton 6c75b73a6a Handle another possible error in a unix pipe test
This cropped up on the bsd bot, and if it's an error that gets thrown then it's
fine to just whitelist another type of error in the test.
2013-10-28 11:47:20 -07:00
bors e6102fc2fa auto merge of #10079 : alexcrichton/rust/no-reader-util, r=brson
These methods are all excellent candidates for default methods, so there's no need to require extra imports of various traits. Additionally, this was able to remove all the weird underscores after the method names. Yay!
2013-10-28 10:56:34 -07:00
Alex Crichton 72557d8312 Remove the extension traits for Readers/Writers
These methods are all excellent candidates for default methods, so there's no
need to require extra imports of various traits.
2013-10-28 10:16:45 -07:00
bors 0a9a706b20 auto merge of #10089 : pythonesque/rust/issue-7718, r=catamorphism
Seems pretty straightforward, but please let me know if I'm doing something wrong or the test needs to be rewritten.
2013-10-28 09:51:32 -07:00
bors 560d9999bc auto merge of #10107 : thestinger/rust/immediate, r=huonw 2013-10-28 08:36:33 -07:00
bors bee40a9f98 auto merge of #10094 : alexcrichton/rust/issue-8704, r=pcwalton
This drops more of the old C++ runtime to rather be written in rust. A few
features were lost along the way, but hopefully not too many. The main loss is
that there are no longer backtraces associated with allocations (rust doesn't
have a way of acquiring those just yet). Other than that though, I believe that
the rest of the debugging utilities made their way over into rust.

Closes #8704
2013-10-28 06:41:40 -07:00
bors 672edb21d9 auto merge of #10093 : alexcrichton/rust/issue-8811, r=pcwalton
Closes #8811
2013-10-28 05:36:31 -07:00
Huon Wilson 17b87d2030 syntax: remove dead @mut Visitor impl (only used in tests).
Also, move some code only uses in the tests into the test module, and
replace some needless @mut ~[] with plain ~[].
2013-10-28 22:39:08 +11:00
bors de3d36a763 auto merge of #10083 : alexcrichton/rust/timer-port, r=pcwalton
In addition to being able to sleep the current task, timers should be able to
create ports which get notified after a period of time.

Closes #10014
2013-10-28 02:41:18 -07:00
bors 9ef23e9060 auto merge of #9967 : Kimundi/rust/fail_cause_two, r=huonw
# Summary

This PR allows the cause of a failure to be received in a task's future result and as the `Err` case of `task::try`, and also implements dynamic typing in form of an `Any` trait.

# Task failure

- `fail!` and related macros now accept 5 kinds of types: `~str`, `&'static str`, `std::send_str::SendStr`, `~std::any::Any` and `~T` where `T: Any + Send + 'static`
- `std::task::TaskResult` got transformed into an internal enum `std::rt::task::UnwindResult`,  and it's `Failure` variant now contains a value of enum type `UnwindReason`:
  - `UnwindReasonStr(SendStr)` maps to failing with a value of type `~str`, `&'static str` or `SendStr`.
  - `UnwindReasonAny(~Any)` maps to failing with an `~Any` or `~T` with `T: Send + 'static`.
  - `UnwindReasonLinked` maps to failing because the task got killed by linked failure.
- Instead, `std::task::TaskResult` is now a typedef for `Result<(), ~Any>`, and both `TaskBuilder`'s `future_result()` and `task::try` now work with a value of this type.
- `future_result()` no longer returns a `Port<TaskResult>`, instead it returns a wrapper `TaskResultPort` that implements `GenericPort` and `Peekable`, and which lazily allocates a `~` box and casts to `~Any` in case of failure with a `SendStr` or linked failure (for the latter case a unit struct `LinkedFailure` got added.)
- Because `fail!` collapses both `~str` and `&'static str` into a `SendStr`, checking if a task error value is a string will just require a `.is::<SendStr>()` check, with `~str` and `&'static str` only being possible in case of an explicit `fail!(~~"...")` or `fail!(~ (&"...") as ~Any)`:

# Any

- In order to allow failing with arbitrary data, the `Any` trait got implemented.
- It is being used in form of a trait object, usually `~Any` or `&Any`.
- `&Any`, `~Any` and `&mut Any` have a few extension methods implemented on them:
  - `is<T>(self) -> bool` returns true if the `Any` object contains type `T`
  - `as_ref<T>(self) -> Option<&T>` returns a reference to the contained type, if it is `T`
  - `as_mut<T>(self) -> Option<&mut T>` returns a mutable reference to the contained type, if it is `T`
  - `move<T>(self) -> Option<~T>` allows to get the `~T` out of an `~Any` again.
- `Any` currently uses type descriptors as a type id for comparisons, which is 
    - not reliable, as it is not guaranteed that every type has only one type descriptor.
    - But safe, as no two types share the same type descriptor.
- The implementation also a few `transmute`s, mostly to cast a `*Void` of the wrapped type into it's actual type `&T`, `&mut T` or `~T`.

# Other changes

- `std::unstable::UnsafeArc::try_unwrap` no longer uses `Either`, bringing us one step closer to removing that type.
- A few of the touched modules got their import lines sorted.
- A few stylistic cleanups here and there.
2013-10-28 01:26:16 -07:00
Marvin Löbel fa8e71a825 Allow fail messages to be caught, and introduce the Any trait
Some code cleanup, sorting of import blocks

Removed std::unstable::UnsafeArc's use of Either

Added run-fail tests for the new FailWithCause impls

Changed future_result and try to return Result<(), ~Any>.

- Internally, there is an enum of possible fail messages passend around.
- In case of linked failure or a string message, the ~Any gets
  lazyly allocated in future_results recv method.
- For that, future result now returns a wrapper around a Port.
- Moved and renamed task::TaskResult into rt::task::UnwindResult
  and made it an internal enum.
- Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-28 08:50:32 +01:00
bors cb5b21eba7 auto merge of #10050 : gifnksm/rust/ratio-methods, r=pcwalton
After merging 0ada7c7, user code have not been able to access to `Ratio`'s numerator and denominator fields.
In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that `Ratio` numbers are irreducible.
So, I added the getter methods `numer()` and `denom()`.

As a bonus, this commit adds utility methods relating to the ratio-integer conversion.
2013-10-27 22:41:18 -07:00
bors 9293a4127b auto merge of #9744 : DaGenix/rust/remove-crypto, r=alexcrichton
Remove the Sha1, Sha2, MD5, and MD4 algorithms. SipHash is also cryptographically secure hash function and IsaacRng is a cryptographically secure RNG - I left those alone but removed comments that implied they were suitable for cryptographic use. I thought that MD4 was used for something by the compiler, but everything still seems to work with it removed, so, I guess not.

One thing that I'm not sure about - workcache.rs and workcache_support.rs (in librustpkg) both depend on Sha1. Without Sha1, the only hash function left is SipHash, so I switched that code over to use SipHash. The output size of SipHash is only 64-bits, however - much less than 160 for Sha1. I'm not sure this is a problem. Without other cryptographic hashes in the tree, I'm not sure what else to do. I considered moved Sha1 into librustpkg, but I don't know if that makes sense.

If merged, this closes #9300.
2013-10-27 21:36:31 -07:00
bors d664ca2635 auto merge of #10080 : brson/rust/sched_queue, r=brson
Rebase and update of #9710
2013-10-27 20:21:29 -07:00
bors a120011827 auto merge of #10098 : alexcrichton/rust/attempts, r=alexcrichton
It was pretty much a miracle that these tests were ever passing. They would
never have passed in the single threaded case because only one sigint in the
tests is ever generated, but when run in parallel two sigints will be generated.
2013-10-27 18:41:25 -07:00
Palmer Cox 2d5cb5d99a Integrate the code in the digest and cryptoutil modules directly into the sha1 module. 2013-10-27 21:25:19 -04:00
Palmer Cox ff9e573a67 Remove MD4. 2013-10-27 21:25:19 -04:00
Palmer Cox ca132006a0 Remove dead code from cryptoutil.rs and remove macro_rules feature flag. 2013-10-27 21:25:19 -04:00
Palmer Cox 72a9482b3f Add a comment to Sha1 that its not suitable for cryptogrpahic uses. 2013-10-27 21:25:19 -04:00
Palmer Cox 653ee13839 Remove MD5 and Sha2. Move Sha1 and support code into librustpkg. 2013-10-27 21:25:19 -04:00