Commit Graph

17434 Commits

Author SHA1 Message Date
John Clements
915e76a974 rename parse_single_class_item as well 2013-04-28 09:51:15 -07:00
John Clements
968089e422 rename parse_class_item to parse_struct_decl_field
two problems with the old name: they're not called classes any more, and
the word "item" has a specific connotation in the parser
2013-04-28 09:51:15 -07:00
John Clements
b82724db22 needs_comma was always true 2013-04-28 09:51:15 -07:00
John Clements
703390150a fix for parsing x() as identifier pattern 2013-04-28 09:51:15 -07:00
John Clements
5119597dc6 hard to read the implied double negative 2013-04-28 09:51:15 -07:00
John Clements
3c10a9412e remove unused functions, fix tiny lexing bug
before this change, the parser would parse 14.a() as a method call, but
would parse 14.ø() as the floating-point number 14. followed by a function
call. This is because it was checking is_alpha, rather than ident_start,
and was therefore wrong with respect to unicode.
2013-04-28 09:51:15 -07:00
John Clements
5411cbf656 remove unused flag to parse_local fn 2013-04-28 09:51:14 -07:00
John Clements
63397b8519 remove unused RESTRICT_NO_CALL_EXPRS restriction 2013-04-28 09:51:14 -07:00
John Clements
2733a1f14b undo abstraction over whether to parse attrs in a block
In principle, it seems like a nice idea to abstract over the two
functions that parse blocks (one with inner attrs allowed, one not).
However, the existing one wound up making things more complex than
just having two separate functions, especially after the obsolete
syntax is (will be) removed.
2013-04-28 09:51:14 -07:00
John Clements
ab03c1e422 refactoring to split foreign_items from items 2013-04-28 09:51:14 -07:00
John Clements
fa5ba17c89 parser comments
parser comments
2013-04-28 09:51:14 -07:00
John Clements
1b4ced8bcb get rid of prec.rs
prec.rs no longer had much to do with precedence; the token->binop
function fits better in token.rs, and the one-liner defining the
precedence of 'as' can go next to the other precedence stuff in
ast_util.rs
2013-04-28 09:51:14 -07:00
John Clements
9f8d30a128 reindent in parser 2013-04-28 09:49:21 -07:00
John Clements
a818648aa9 remove unnecessary function 2013-04-28 09:49:20 -07:00
John Clements
71c0bd5c5d simplify, based on invariant that items_allowed != foreign_items_allowed 2013-04-28 09:49:20 -07:00
John Clements
ae4e09f71a adding parse_path 2013-04-28 09:49:20 -07:00
John Clements
28b285764c comments, helper function for tests, more informative error message 2013-04-28 09:49:20 -07:00
John Clements
50a7f5483b refactor parse_fn_decl 2013-04-28 09:49:20 -07:00
John Clements
2b7f1a4f24 parser comments only 2013-04-28 09:49:20 -07:00
John Clements
c73a9c9cd0 refactoring mod.rs 2013-04-28 09:49:20 -07:00
John Clements
a2493ad048 change stage1,stage2,stage2 into not(stage0)
With luck, this will allow rust to compile itself without --cfg flags again...
2013-04-28 09:49:20 -07:00
bors
cdd342bd34 auto merge of #6097 : Blei/rust/fix-rand, r=pnkfelix
`self` has type `&@Rand`, so `*self` will be of type `@Rand` which causes
this same impl to be called again.

Fixes #6061
2013-04-28 04:48:35 -07:00
Philipp Brüschweiler
8627fc9726 rand: Fix infinite recursion
`self` has type `&@Rand`, so `*self` will be of type `@Rand` which causes
this same impl to be called again.
2013-04-28 13:31:49 +02:00
bors
5f7947aa52 auto merge of #6075 : thestinger/rust/no-no_core, r=brson
core injection works fine now
2013-04-27 19:18:33 -07:00
gifnksm
92f0dc6b4b libstd: inlining almost every methods in bigint module. 2013-04-28 10:59:58 +09:00
gifnksm
01b3490a55 libstd: impl Integer for BigUint/BigInt.
Also remove abs() method from the non-trait impl for BigInt/BigUint.
That method is provided in the Signed trait.
2013-04-28 10:59:58 +09:00
Daniel Micay
f792baba42 only use #[no_core] in libcore 2013-04-27 21:34:24 -04:00
bors
dd5b1de181 auto merge of #6082 : catamorphism/rust/mkdir_recursive, r=brson
r? @brson mkdir_recursive creates a directory as well as any of its
parent directories that don't exist already. Seems like a useful
thing to have in core.

(Or r? anyone who gets to it first.)
2013-04-27 17:24:33 -07:00
bors
88dd53a754 auto merge of #6081 : brson/rust/out-of-stack, r=thestinger
People hit the recursion depth limit too often, it's not possible
to unwind reliably from out-of-stack.

Issues #3555, #3695
2013-04-27 16:24:34 -07:00
bors
9f118865a2 auto merge of #6072 : cmr/rust/better_import_error, r=graydon 2013-04-27 14:24:36 -07:00
bors
aa38867e4e auto merge of #6071 : bjz/rust/numeric-traits, r=graydon
As part of the numeric trait reform (see issue #4819), I have added the following traits to `core::num` and implemented them for Rust's primitive numeric types:

~~~rust
pub trait Bitwise: Not<Self>
                 + BitAnd<Self,Self>
                 + BitOr<Self,Self>
                 + BitXor<Self,Self>
                 + Shl<Self,Self>
                 + Shr<Self,Self> {}

pub trait BitCount {
    fn population_count(&self) -> Self;
    fn leading_zeros(&self) -> Self;
    fn trailing_zeros(&self) -> Self;
}

pub trait Bounded {
    fn min_value() -> Self;
    fn max_value() -> Self;
}

pub trait Primitive: Num
                   + NumCast
                   + Bounded
                   + Neg<Self>
                   + Add<Self,Self>
                   + Sub<Self,Self>
                   + Mul<Self,Self>
                   + Quot<Self,Self>
                   + Rem<Self,Self> {
    fn bits() -> uint;
    fn bytes() -> uint;
}

pub trait Int: Integer
             + Primitive
             + Bitwise
             + BitCount {}

pub trait Float: Real
               + Signed
               + Primitive {
    fn NaN() -> Self;
    fn infinity() -> Self;
    fn neg_infinity() -> Self;
    fn neg_zero() -> Self;

    fn is_NaN(&self) -> bool;
    fn is_infinite(&self) -> bool;
    fn is_finite(&self) -> bool;

    fn mantissa_digits() -> uint;
    fn digits() -> uint;
    fn epsilon() -> Self;
    fn min_exp() -> int;
    fn max_exp() -> int;
    fn min_10_exp() -> int;
    fn max_10_exp() -> int;

    fn mul_add(&self, a: Self, b: Self) -> Self;
    fn next_after(&self, other: Self) -> Self;
}
~~~
Note: I'm not sure my implementation for `BitCount::trailing_zeros` and `BitCount::leading_zeros` is correct for uints. I also need some assistance creating appropriate unit tests for them.

More work needs to be done in implementing specialized primitive floating-point and integer methods, but I'm beginning to reach the limits of my knowledge. Please leave your suggestions/critiques/ideas on #4819 if you have them – I'd very much appreciate hearing them.

I have also added an `Orderable` trait:

~~~rust
pub trait Orderable: Ord {
    fn min(&self, other: &Self) -> Self;
    fn max(&self, other: &Self) -> Self;
    fn clamp(&self, mn: &Self, mx: &Self) -> Self;
}
~~~

This is a temporary trait until we have default methods. We don't want to encumber all implementors of Ord by requiring them to implement these functions, but at the same time we want to be able to take advantage of the speed of the specific numeric functions (like the `fmin` and `fmax` intrinsics).
2013-04-27 13:09:35 -07:00
bors
5de74f3e75 auto merge of #6070 : thestinger/rust/tutorial, r=pcwalton 2013-04-27 12:09:35 -07:00
bors
9ea32a380d auto merge of #6066 : djui/rust/patch-1, r=graydon 2013-04-27 10:24:35 -07:00
bors
47dbcdc455 auto merge of #6064 : thestinger/rust/char, r=catamorphism 2013-04-27 09:27:36 -07:00
bors
46806b7ae0 auto merge of #6059 : Kimundi/rust/nice-fail, r=pcwalton
r? @brson

Unwinding through macros now happens as a call to the trait function `FailWithCause::fail_with()`, which consumes self, allowing to use a more generic failure object in the future.
2013-04-26 22:45:36 -07:00
bors
8804b13bd2 auto merge of #6058 : huonw/rust/rt-isaac-update, r=graydon
The "unsigned 4 byte" `ub4`s are actually 8 bytes on 64-bit platforms
which mean that some bits > 2**32 were retained in calculations, these
would then "reappear" after a right shift and so the stream of random numbers
would differ on 32 bit vs 64 bit platforms.

http://burtleburtle.net/bob/c/randport.c
2013-04-26 21:57:35 -07:00
Brendan Zabarauskas
9cdf402c80 Propagate NaNs for Orderable methods impled on floating-point primitives 2013-04-27 13:13:28 +10:00
Brendan Zabarauskas
c9d099d60d Fix copy-paste mistakes 2013-04-27 12:42:34 +10:00
bors
7c1696b529 auto merge of #6057 : cmr/rust/map_zip, r=graydon
I think the name is more clear, and fits with filter_map etc.
2013-04-26 17:42:36 -07:00
Brendan Zabarauskas
35f33c17f7 Remove unnecessary fallbacks
The `target_word_size` attribute is always available at compile time, so there is no need for a fallback.
2013-04-27 10:34:29 +10:00
Brendan Zabarauskas
32df8ed877 Rename nextafter to next_after to match method name in Float 2013-04-27 10:16:09 +10:00
bors
b67a7b9004 auto merge of #6077 : brson/rust/valgrind, r=brson 2013-04-26 16:54:35 -07:00
Brendan Zabarauskas
4cc9d0ba7e Add additional constants to primitive floating point numbers
These follow the values defined in the C99 standard
2013-04-27 09:07:40 +10:00
Tim Chevalier
848641fcb5 core: Move mkdir_recursive from rustpkg into core::os
mkdir_recursive creates a directory as well as any of its
parent directories that don't exist already. Seems like a useful
thing to have in core.
2013-04-26 15:51:22 -07:00
Brian Anderson
149047e55d rt: Set the stack depth limit to 1GB. Abort on error.
People hit the recursion depth limit too often, it's not possible
to unwind reliably from out-of-stack.

Issues #3555, #3695
2013-04-26 15:39:54 -07:00
Brian Anderson
2c99e3dc3e Suppress all 'cond' errors in valgrind. #5856 2013-04-26 13:41:33 -07:00
Daniel Micay
195911fca4 tutorial-ffi: add example of a custom destructor 2013-04-26 14:07:57 -04:00
Daniel Micay
721e1143a5 tutorial: rework the section on destructors
This removes the comparison to manual memory management examples,
because it requires too much existing knowledge. Implementing custom
destructors can be covered in the FFI tutorial, where `unsafe` is
already well explained.
2013-04-26 14:07:47 -04:00
Brendan Zabarauskas
b7cf89f6e8 Add mul_add and next_after methods to Float 2013-04-27 01:02:30 +10:00
Brendan Zabarauskas
6cc7107aa6 Add Orderable trait
This is a temporary trait until we have default methods. We don't want to encumber all implementors of Ord by requiring them to implement these functions, but at the same time we want to be able to take advantage of the speed of the specific numeric functions (like the `fmin` and `fmax` intrinsics).
2013-04-27 01:01:53 +10:00