Commit Graph

17454 Commits

Author SHA1 Message Date
Tim Chevalier
08109aa0ad core: Comments only -- move FIXME to correct location 2013-04-24 17:51:30 -07:00
bors
0c6f9a889b auto merge of #6052 : nikomatsakis/rust/remove-2811, r=catamorphism
r? whomever.
2013-04-24 17:48:27 -07:00
Niko Matsakis
a74aca5482 Remove needless FIXME. Fixes #2811. 2013-04-24 20:39:29 -04:00
Daniel Micay
11d04d452f add a Counter iterator 2013-04-24 19:57:02 -04:00
Brendan Zabarauskas
dcd49ccd0b Add Fractional, Real and RealExt traits 2013-04-25 08:20:01 +10:00
Brendan Zabarauskas
6fa054df96 Use borrowed pointers for Integer methods
This brings them in line with the quot and rem traits, and is be better for large Integer types like BigInt and BigUint because they don't need to be copied unnecessarily.
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
024bf2ec72 Rename Natural to Integer
'Natural' normally means 'positive integer' in mathematics. It is therefore strange to implement it on signed integer types. 'Integer' is probably a better choice.
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
d4868ee740 Use #[cfg(not(stage0))] to exclude items from stage0
As requested on the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003713.html
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
03932f0b84 Move impls of Num out of core::num and clean up imports 2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
593bdd9be3 Fix incorrect replacement of modulo with rem 2013-04-25 08:19:59 +10:00
bors
a784997750 auto merge of #6044 : Dretch/rust/run-remove-progrepr, r=graydon
...which was a legacy from the time when destructors were implemented using resource types.
2013-04-24 14:27:27 -07:00
bors
ee3789b4e4 auto merge of #6029 : Kimundi/rust/ascii-encoding, r=thestinger
Replaced {str, char, u8}::is_ascii
Replaced str::to_lower and str::to_upper
2013-04-24 13:33:29 -07:00
Marvin Löbel
3759b5711d Fixed typo... And a billion other things. 2013-04-24 22:28:02 +02:00
Marvin Löbel
dd74807957 Removed ascii functions from other modules
Replaced str::to_lowercase and str::to_uppercase
2013-04-24 22:26:09 +02:00
gareth
345d5b8235 Refactor core::run to remove the ProgRepr struct, which was
a legacy from the time when destructors were implemented
using resource types.
2013-04-24 21:06:26 +01:00
bors
e26f992d5e auto merge of #6036 : huonw/rust/core-less-at, r=nikomatsakis
From a cursory `git grep` this removes the last part of `core` that requires on `@` (other than `io` and the task local data section).

It renames `RandRes` to ~~StdRng~~ `IsaacRng` and `XorShiftState` to `XorShiftRng` as well as moving their constructors to static methods. To go with this, it adds `rng()` which is designed to be used when the programmer just wants a random number generator, without caring about which exact algorithm is being used.

It also removes all the `gen_int`, `gen_uint`, `gen_char` (etc) methods on `RngUtil` (by moving the defintions to the actual `Rand` instances). The replacement is using `RngUtil::gen`, either type-inferred or with an annotation (`rng.gen::<uint>()`).

I tried to have the `Rng` and `RngUtil` traits exported by `core::prelude` (since `core::rand` (except for `random()`) is useless without them), but this caused [an explosion of (seemingly unrelated) `error: unresolved import`'s](https://gist.github.com/5451839).
2013-04-24 06:48:50 -07:00
Huon Wilson
9860fe10a1 libcore: remove unnecessary deref 2013-04-24 23:03:04 +10:00
Huon Wilson
4a24f10ac6 libcore: unify gen_<type> methods on rand::RngUtil into the generic gen.
This moves all the basic random value generation into the Rand instances for
each type and then removes the `gen_int`, `gen_char` (etc) methods on RngUtil,
leaving only the generic `gen` and the more specialised methods.

Also, removes some imports that are redundant due to a `use core::prelude::*`
statement.
2013-04-24 22:34:19 +10:00
Huon Wilson
7b009210c6 libcore: convert the Program @-object to be a plain struct + impl.
Removes the dynamic @ indirection, and also converts the functions acting
on `ProgRepr`s to methods.
2013-04-24 22:34:19 +10:00
Huon Wilson
6c0a7c7b7d libcore: remove @Rng from rand, and use traits instead.
Also, rename RandRes -> IsaacRng, and make the constructors static
methods.
2013-04-24 22:34:10 +10:00
James Miller
507c200da1 Merge branch 'incoming' of git://github.com/mozilla/rust into unwind-fix 2013-04-24 18:34:00 +12:00
James Miller
286e571a63 Remove rust_unwind.h
Adds the required definitions in the correct place.
2013-04-24 18:27:56 +12:00
bors
c8ac057545 auto merge of #6041 : bjz/rust/numeric-traits, r=brson
As part of the numeric trait reform (see issue #4819), I have added the following traits to `core::num` and implemented them for the appropriate types:

~~~rust
pub trait Signed: Num
                + Neg<Self> {
    fn abs(&self) -> Self;
    fn signum(&self) -> Self;
    fn is_positive(&self) -> bool;
    fn is_negative(&self) -> bool;
}

pub trait Unsigned: Num {}

pub trait Natural: Num
                 + Ord
                 + Quot<Self,Self>
                 + Rem<Self,Self> {
    fn div(&self, other: Self) -> Self;
    fn modulo(&self, other: Self) -> Self;
    fn div_mod(&self, other: Self) -> (Self,Self);
    fn quot_rem(&self, other: Self) -> (Self,Self);

    fn gcd(&self, other: Self) -> Self;
    fn lcm(&self, other: Self) -> Self;
    fn divisible_by(&self, other: Self) -> bool;
    fn is_even(&self) -> bool;
    fn is_odd(&self) -> bool;
}
~~~

I have not implemented `Natural` for `BigInt` and `BigUInt` because they're a little over my head. Help with this would be most appreciated.
2013-04-23 22:12:47 -07:00
Brendan Zabarauskas
ab8068c9f2 Improve divide-by-zero error messages 2013-04-24 14:20:00 +10:00
Brendan Zabarauskas
f39152e07b Implement Natural trait
This adds the following methods to ints and uints:

- div
- modulo
- div_mod
- quot_rem
- gcd
- lcm
- divisible_by
- is_even
- is_odd

I have not implemented Natural for BigInt and BigUInt because they're a little over my head.
2013-04-24 14:18:01 +10:00
Brendan Zabarauskas
aef249056e Implement Signed and Unsigned traits and remove related predicate functions 2013-04-24 12:46:26 +10:00
bors
706096b319 auto merge of #6038 : alexcrichton/rust/more-unsafe, r=pcwalton
Because unsafe functions are never warned about, then all `unsafe` blocks in unsafe functions should definitely be warned about (no need to be redundant). This fixes this case, adds tests, cleans up remaining cases, and then fixes a few other import warnings being spit out.
2013-04-23 18:27:48 -07:00
Alex Crichton
0c2ab662b7 Fixing some various warnings about unused imports 2013-04-23 19:59:14 -04:00
Alex Crichton
4c08a8d6c3 Removing more unnecessary unsafe blocks throughout 2013-04-23 19:59:13 -04:00
Alex Crichton
c089a17854 Improve the unused unsafe block warning to include unsafe blocks in unsafe functions 2013-04-23 19:40:34 -04:00
bors
8708e0c099 auto merge of #6010 : Dretch/rust/run-windows, r=brson
This fixes #5976.

It also removes `os::waitpid` in favour of (the existing) `run::waitpid`. I included this change because I figured it is kind of related.

r?
2013-04-23 14:12:48 -07:00
gareth
62befac51f Cleanup some mistakes made during rebasing/merging. 2013-04-23 21:23:16 +01:00
gareth
ceeffa1ec6 Oops, the should_fail test needs to be ignored on windows. 2013-04-23 21:23:16 +01:00
gareth
690120d6bc Remove os::waitpid because:
- The return value meant different things on different
   platforms (on windows, it was the exit code, on unix it was
   the status information returned from waitpid).
 - It was undocumented.
 - There also exists run::waitpid, which does much the same
   thing but has a more consistent return value and also some
   documentation.
2013-04-23 21:23:16 +01:00
gareth
91aeecf7e3 Fix issue #5976 - HANDLE leaks and undefined/bad behavour
on windows.
2013-04-23 21:23:15 +01:00
bors
0b90493f7e auto merge of #6034 : thestinger/rust/num, r=catamorphism,pcwalton 2013-04-23 12:27:47 -07:00
bors
d9896d592b auto merge of #6028 : Kimundi/rust/strconv-test-fixup, r=brson
r? @brson 

Can't test atm, but it probably failed because of 32bit float precision loss of the float literal.
2013-04-23 11:30:54 -07:00
Daniel Micay
a3e33cfb6e inline the primitive numeric operations 2013-04-23 14:05:41 -04:00
bors
88ccee78a8 auto merge of #6022 : catamorphism/rust/warning-police, r=catamorphism 2013-04-23 10:36:50 -07:00
Tim Chevalier
7169907e9f rustc: Remove dead code 2013-04-23 10:17:41 -07:00
Tim Chevalier
aac73b24ae rustc: Comments only: change XXX to FIXME 2013-04-23 10:17:41 -07:00
Tim Chevalier
52d3f5558e core, rustc: Warning police 2013-04-23 10:17:38 -07:00
bors
8cadcc47ee auto merge of #6027 : alexcrichton/rust/more-backticks, r=catamorphism
It seems that the general convention of error messages is to have keywords in backticks, so it's probably a good idea to keep doing that.
2013-04-23 09:48:49 -07:00
bors
0290caa885 auto merge of #6026 : isanbard/rust/ca73fbf72615575f106ee18160580711aca89d85, r=catamorphism
When the number of parameters is 1, then 'parameter' should remain singular.
Otherwise pluralize it.
2013-04-23 02:33:49 -07:00
Marvin Löbel
b813d68abe Attempt to fix x86 only strconv test failure 2013-04-23 11:10:37 +02:00
bors
212256b1a0 auto merge of #6025 : alexcrichton/rust/issue-2697, r=catamorphism
Closes #2697

I guess all of the uses weren't around any more, because everything continued to compile (at least on OSX). If bors doesn't like it for another platform I can try to track it down as well.
2013-04-23 01:36:48 -07:00
bors
54b0cbf86e auto merge of #6020 : yichoi/rust/pull-0423, r=brson
fix for missing ARM support to pass make stage of rpass
2013-04-23 00:06:49 -07:00
bors
da601be9f2 auto merge of #6017 : brson/rust/revert-span-merge, r=catamorphism
This reverts commit 6030e3982a.

This reorders error messages in ways that aren't intended. A more satisfying solution will require an interface that allows diagnostics to be grouped together, so that messages that logically belong together aren't reordered.

#4569
2013-04-22 23:09:51 -07:00
Alex Crichton
8884c6abdb Use backticks for the unsafe keyword in error messages 2013-04-23 02:06:47 -04:00
Bill Wendling
ca73fbf726 Use correct grammar for error message.
When the number of parameters is 1, then 'parameter' should remain singular.
Otherwise pluralize it.
2013-04-22 22:08:09 -07:00