Commit Graph

334 Commits

Author SHA1 Message Date
Nick Cameron
37a94b80f2 Use temp vars for implicit coercion to ^[T] 2014-08-26 12:37:45 +12:00
Nick Cameron
34d607f9c9 Use the slice repr for ~[T] 2014-08-26 12:37:45 +12:00
Austin Bonander
1028120c40 Parameterize indent in PrettyEncoder 2014-08-21 11:04:03 -07:00
bors
655600b01b auto merge of #16621 : tshepang/rust/grammar, r=steveklabnik 2014-08-20 13:55:52 +00:00
Tshepang Lekhonkhobe
1f1620eed7 doc: grammar fixes 2014-08-20 01:31:07 +02:00
Erick Tryzelaar
9b23287974 Don't fail if an object is keyed with a string and we're expecting a number 2014-08-19 13:35:41 -07:00
Erick Tryzelaar
e95552c5e6 serialize: add json bounds checks, support for u64s, and tests 2014-08-19 13:35:41 -07:00
Erick Tryzelaar
3019af6c01 serialize: add json::{Integer,Floating} to parse large integers properly
[breaking-change]
2014-08-19 09:34:10 -07:00
Luqman Aden
d302813888 Reenable ignored test and add run-pass test. 2014-08-11 19:20:10 -07:00
Chuck Ries
0e47f9481e remove outdated comment
These are already coded as traits.
2014-08-10 04:11:33 -07:00
nham
efdb77b8d4 Remove cast to char in libserialize::hex 2014-08-06 12:23:21 -04:00
nham
d45a569995 Use byte literals in libserialize 2014-08-06 01:07:10 -04:00
Andrew Poelstra
5bd8edc112 libserialize: add error() to Decoder
A quick and dirty fix for #15036 until we get serious decoder reform.

Right now it is impossible for a Decodable to signal a decode error,
for example if it has only finitely many allowed values, is a string
which must be encoded a certain way, needs a valid checksum, etc. For
example in the libuuid implementation of Decodable an Option is
unwrapped, meaning that a decode of a malformed UUID will cause the
task to fail.

Since this adds a method to the `Decoder` trait, all users will need
to update their implementations to add it. The strategy used for the
current implementations for JSON and EBML is to add a new entry to
the error enum `ApplicationError(String)` which stores the string
provided to `.error()`.

[breaking-change]
2014-07-31 21:41:19 -07:00
Erick Tryzelaar
e1dcbefe52 remove serialize::ebml, add librbml
Our implementation of ebml has diverged from the standard in order
to better serve the needs of the compiler, so it doesn't make much
sense to call what we have ebml anyore. Furthermore, our implementation
is pretty crufty, and should eventually be rewritten into a format
that better suits the needs of the compiler. This patch factors out
serialize::ebml into librbml, otherwise known as the Really Bad
Markup Language. This is a stopgap library that shouldn't be used
by end users, and will eventually be replaced by something better.

[breaking-change]
2014-07-31 07:30:49 -07:00
Erick Tryzelaar
e27b88d5bd remove seek from std::io::MemWriter, add SeekableMemWriter to librustc
Not all users of MemWriter need to seek, but having MemWriter
seekable adds between 3-29% in overhead in certain circumstances.
This fixes that performance gap by making a non-seekable MemWriter,
and creating a new SeekableMemWriter for those circumstances when
that functionality is actually needed.

```
test io::mem::test::bench_buf_reader                        ... bench:       682 ns/iter (+/- 85)
test io::mem::test::bench_buf_writer                        ... bench:       580 ns/iter (+/- 57)
test io::mem::test::bench_mem_reader                        ... bench:       793 ns/iter (+/- 99)
test io::mem::test::bench_mem_writer_001_0000               ... bench:        48 ns/iter (+/- 27)
test io::mem::test::bench_mem_writer_001_0010               ... bench:        65 ns/iter (+/- 27) = 153 MB/s
test io::mem::test::bench_mem_writer_001_0100               ... bench:       132 ns/iter (+/- 12) = 757 MB/s
test io::mem::test::bench_mem_writer_001_1000               ... bench:       802 ns/iter (+/- 151) = 1246 MB/s
test io::mem::test::bench_mem_writer_100_0000               ... bench:       481 ns/iter (+/- 28)
test io::mem::test::bench_mem_writer_100_0010               ... bench:      1957 ns/iter (+/- 126) = 510 MB/s
test io::mem::test::bench_mem_writer_100_0100               ... bench:      8222 ns/iter (+/- 434) = 1216 MB/s
test io::mem::test::bench_mem_writer_100_1000               ... bench:     82496 ns/iter (+/- 11191) = 1212 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0000      ... bench:        48 ns/iter (+/- 2)
test io::mem::test::bench_seekable_mem_writer_001_0010      ... bench:        64 ns/iter (+/- 2) = 156 MB/s
test io::mem::test::bench_seekable_mem_writer_001_0100      ... bench:       129 ns/iter (+/- 7) = 775 MB/s
test io::mem::test::bench_seekable_mem_writer_001_1000      ... bench:       801 ns/iter (+/- 159) = 1248 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0000      ... bench:       711 ns/iter (+/- 51)
test io::mem::test::bench_seekable_mem_writer_100_0010      ... bench:      2532 ns/iter (+/- 227) = 394 MB/s
test io::mem::test::bench_seekable_mem_writer_100_0100      ... bench:      8962 ns/iter (+/- 947) = 1115 MB/s
test io::mem::test::bench_seekable_mem_writer_100_1000      ... bench:     85086 ns/iter (+/- 11555) = 1175 MB/s
```

[breaking-change]
2014-07-29 16:31:39 -07:00
Erick Tryzelaar
ce2824dafe serialize: fix a warning 2014-07-29 15:50:45 -07:00
Adolfo Ochagavía
9ec19373af Deprecated str::raw::from_utf8_owned
Replaced by `string::raw::from_utf8`

[breaking-change]
2014-07-24 07:25:43 -07:00
Brian Anderson
5599b69b6d Convert some push_back users to push 2014-07-23 13:20:16 -07:00
bors
8d43e4474a auto merge of #15867 : cmr/rust/rewrite-lexer4, r=alexcrichton 2014-07-22 07:16:17 +00:00
Corey Richardson
188d889aaf ignore-lexer-test to broken files and remove some tray hyphens
I blame @ChrisMorgan for the hyphens.
2014-07-21 10:59:58 -07:00
Simon Sapin
56218f5dfc Implement FromBase64 for &[u8].
The algorithm was already based on bytes internally.

Also use byte literals instead of casting u8 to char for matching.
2014-07-19 16:46:14 +01:00
Luqman Aden
61ded48fbc Ignore one test. 2014-07-18 11:58:45 -07:00
bors
c0e6c4e650 auto merge of #15675 : errordeveloper/rust/json_docs, r=steveklabnik
- add one simple example of using `ToJson` trait
- make example code more readable
2014-07-17 13:56:19 +00:00
Nick Cameron
aa760a849e deprecate Vec::get 2014-07-17 12:08:31 +12:00
Ilya Dmitrichenko
7beb5507ff Improve docs on JSON.
- add one simple example of using `ToJson` trait
- make example code more readable
2014-07-16 19:30:54 +01:00
Adolfo Ochagavía
211f1caa29 Deprecate str::from_utf8_owned
Use `String::from_utf8` instead

[breaking-change]
2014-07-15 19:55:17 +02:00
Brian Anderson
fa2d220567 Update doc URLs for version bump 2014-07-11 11:21:57 -07:00
Alex Crichton
0c71e0c596 Register new snapshots
Closes #15544
2014-07-09 10:57:58 -07:00
Richo Healey
12c334a77b std: Rename the ToStr trait to ToString, and to_str to to_string.
[breaking-change]
2014-07-08 13:01:43 -07:00
bors
179b2b48ba auto merge of #15411 : mitchmindtree/rust/master, r=alexcrichton
I ran `make check` and everything went smoothly. I also tested `#[deriving(Decodable, Encodable)]` on a struct containing both Cell<T> and RefCell<T> and everything now seems to work fine.
2014-07-07 04:46:31 +00:00
mitchmindtree
0e84d6fc1a Implemented Decodable/Encodable for Cell and RefCell. Fixes #15395
Updated PR with fixme and test

Updated PR with fixme and test
2014-07-07 13:02:09 +10:00
Alex Crichton
e44c2b9bbc Add #[crate_name] attributes as necessary 2014-07-05 12:45:42 -07:00
bors
9f2a43c1b5 auto merge of #15419 : erickt/rust/json, r=pcwalton
This speeds up json serialization by removing most of the allocations.
2014-07-05 01:31:52 +00:00
Erick Tryzelaar
67c8a8d5dd serialize: speed up json pretty printing by batch writing spaces 2014-07-04 16:56:23 -07:00
Erick Tryzelaar
717de500ee serialize: escaping json strings should write in batches.
This significantly speeds up encoding json strings.
2014-07-04 16:36:49 -07:00
Erick Tryzelaar
83f9f07ec4 serialize: Remove allocations from escaping strs and indenting spaces 2014-07-04 11:08:38 -07:00
Patrick Walton
29ec2506ab librustc: Remove the &LIFETIME EXPR production from the language.
This was parsed by the parser but completely ignored; not even stored in
the AST!

This breaks code that looks like:

    static X: &'static [u8] = &'static [1, 2, 3];

Change this code to the shorter:

    static X: &'static [u8] = &[1, 2, 3];

Closes #15312.

[breaking-change]
2014-07-04 00:56:57 -07:00
Alex Crichton
ff1dd44b40 Merge remote-tracking branch 'origin/master' into 0.11.0-release
Conflicts:
	src/libstd/lib.rs
2014-07-02 11:08:21 -07:00
Adolfo Ochagavía
c3cf3b3fb1 Implement ToJson for all tuples 2014-06-30 21:35:50 +02:00
Adolfo Ochagavía
2f16d9ef00 Fix JSON documentation
Fixed some errors, removed some code examples and added usage of the
`encode` and `decode` functions.
2014-06-30 21:35:47 +02:00
Adolfo Ochagavía
954c3234a0 Implement FromStr for Json 2014-06-30 21:35:47 +02:00
Adolfo Ochagavía
6ae5e92cc2 Add encode and decode shortcut functions
Now you can just use `json::encode` and `json::decode`, which is very
practical

**Deprecated `Encoder::str_encode` in favor of `json::encode`**

[breaking-change]
2014-06-30 21:35:46 +02:00
Adolfo Ochagavía
1e55dce0e4 Removed unnecessary Box 2014-06-30 21:35:46 +02:00
Adolfo Ochagavía
4c65a86571 JSON cleanup
* Tried to make the code more idiomatic
* Renamed the `wr` field of the `Encoder` and `PrettyEncoder` structs to `writer`
* Replaced some `from_utf8` by `from_utf8_owned` to avoid unnecessary allocations
* Removed unnecessary `unsafe` code
2014-06-30 21:35:45 +02:00
Steven Fackler
55cae0a094 Implement RFC#28: Add PartialOrd::partial_cmp
I ended up altering the semantics of Json's PartialOrd implementation.
It used to be the case that Null < Null, but I can't think of any reason
for an ordering other than the default one so I just switched it over to
using the derived implementation.

This also fixes broken `PartialOrd` implementations for `Vec` and
`TreeMap`.

RFC: 0028-partial-cmp
2014-06-29 21:42:09 -07:00
Patrick Walton
a5bb0a3a45 librustc: Remove the fallback to int for integers and f64 for
floating point numbers for real.

This will break code that looks like:

    let mut x = 0;
    while ... {
        x += 1;
    }
    println!("{}", x);

Change that code to:

    let mut x = 0i;
    while ... {
        x += 1;
    }
    println!("{}", x);

Closes #15201.

[breaking-change]
2014-06-29 11:47:58 -07:00
bors
fe8bc17801 auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwalton
This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
2014-06-28 20:11:34 +00:00
Alex Crichton
0dfc90ab15 Rename all raw pointers as necessary 2014-06-28 11:53:58 -07:00
Alex Crichton
aa1163b92d Update to 0.11.0 2014-06-27 12:50:16 -07:00
mrec
e1a9899a3a json: Fix handling of NaN/Infinity
The JSON spec requires that these special values be serialized as null; the current serialization breaks any conformant JSON parser. So encoding needs to output "null",  to_json on floating-point types can return Null as well as Number, and reading null when specifically expecting a number should be interpreted as NaN. There's no way to round-trip Infinity.
2014-06-26 02:26:41 +01:00
Niko Matsakis
9e3d0b002a librustc: Remove the fallback to int from typechecking.
This breaks a fair amount of code. The typical patterns are:

* `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`;

* `println!("{}", 3)`: change to `println!("{}", 3i)`;

* `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`.

RFC #30. Closes #6023.

[breaking-change]
2014-06-24 17:18:48 -07:00
Erick Tryzelaar
76371d1ff1 serialize: Simplify the json docs 2014-06-21 17:42:22 -04:00
bors
f05cd6e04e auto merge of #15014 : brson/rust/all-crates-experimental, r=cmr
This creates a stability baseline for all crates that we distribute that are not `std`. In general, all library code must start as experimental and progress in stages to become stable.
2014-06-19 03:31:18 +00:00
Simon Sapin
108b8b6dc7 Deprecate the bytes!() macro.
Replace its usage with byte string literals, except in `bytes!()` tests.
Also add a new snapshot, to be able to use the new b"foo" syntax.

The src/etc/2014-06-rewrite-bytes-macros.py script automatically
rewrites `bytes!()` invocations into byte string literals.
Pass it filenames as arguments to generate a diff that you can inspect,
or `--apply` followed by filenames to apply the changes in place.
Diffs can be piped into `tip` or `pygmentize -l diff` for coloring.
2014-06-18 17:02:22 -07:00
Brendan Zabarauskas
cb8ca2dafd Shorten endian conversion method names
The consensus on #14917 was that the proposed names were too long.
2014-06-18 17:01:34 -07:00
Brendan Zabarauskas
ff9f92ce52 Merge the Bitwise and ByteOrder traits into the Int trait
This reduces the complexity of the trait hierarchy.
2014-06-18 17:01:34 -07:00
Brendan Zabarauskas
b84d17d4d7 Use ByteOrder methods instead of free-standing functions 2014-06-18 17:01:34 -07:00
Brian Anderson
77657baf2c Mark all crates except std as experimental 2014-06-17 22:13:36 -07:00
Nick Cameron
8e7213f65b Remove TraitStore from ty_trait
Use ty_rptr/ty_uniq(ty_trait) rather than TraitStore to represent trait types.
Also addresses (but doesn't close) #12470.
Part of the work towards DST (#12938).

[breaking-change] lifetime parameters in `&mut trait` are now invariant. They used to be contravariant.
2014-06-18 10:30:33 +12:00
theptrk
e1971dd35a Update "use" to "uses" ln186 2014-06-16 18:16:32 -07:00
bors
8a5c5b6081 auto merge of #14932 : Sawyer47/rust/json-smallfix, r=huonw 2014-06-16 13:16:44 +00:00
Alex Crichton
89b0e6e12b Register new snapshots 2014-06-15 23:30:24 -07:00
Piotr Jawniak
b71fa9bd72 Small improvement for json PrettyEncoder 2014-06-15 09:31:14 +02:00
Alex Crichton
ade807c6dc rustc: Obsolete the @ syntax entirely
This removes all remnants of `@` pointers from rustc. Additionally, this removes
the `GC` structure from the prelude as it seems odd exporting an experimental
type in the prelude by default.

Closes #14193
[breaking-change]
2014-06-14 10:45:37 -07:00
Alex Crichton
f20b1293fc Register new snapshots 2014-06-14 10:28:09 -07:00
bors
0422934e24 auto merge of #14831 : alexcrichton/rust/format-intl, r=brson
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-13 14:42:03 +00:00
Alex Crichton
cac7a2053a std: Remove i18n/l10n from format!
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-11 16:04:24 -07:00
Alex Crichton
3316b1eb7c rustc: Remove ~[T] from the language
The following features have been removed

* box [a, b, c]
* ~[a, b, c]
* box [a, ..N]
* ~[a, ..N]
* ~[T] (as a type)
* deprecated_owned_vector lint

All users of ~[T] should move to using Vec<T> instead.
2014-06-11 15:02:17 -07:00
Alex Crichton
531ed3d599 rustc: Update how Gc<T> is recognized
This commit uses the same trick as ~/Box to map Gc<T> to @T internally inside
the compiler. This moves a number of implementations of traits to the `gc`
module in the standard library.

This removes functions such as `Gc::new`, `Gc::borrow`, and `Gc::ptr_eq` in
favor of the more modern equivalents, `box(GC)`, `Deref`, and pointer equality.

The Gc pointer itself should be much more useful now, and subsequent commits
will move the compiler away from @T towards Gc<T>

[breaking-change]
2014-06-11 09:11:40 -07:00
Keegan McAllister
ffb2f12ed8 Use phase(plugin) in bootstrap crates
Do this to avoid warnings on post-stage0 builds.
2014-06-09 14:29:30 -07:00
Joseph Crail
45e56eccbe Fix spelling errors in comments. 2014-06-08 13:39:42 -04:00
Alex Crichton
e5bbbca33e rustdoc: Submit examples to play.rust-lang.org
This grows a new option inside of rustdoc to add the ability to submit examples
to an external website. If the `--markdown-playground-url` command line option
or crate doc attribute `html_playground_url` is present, then examples will have
a button on hover to submit the code to the playground specified.

This commit enables submission of example code to play.rust-lang.org. The code
submitted is that which is tested by rustdoc, not necessarily the exact code
shown in the example.

Closes #14654
2014-06-06 20:00:16 -07:00
Alex Crichton
760b93adc0 Fallout from the libcollections movement 2014-06-05 13:55:11 -07:00
Jorge Aparicio
a413d005a7 Implement ToJson for &[T], and add tests. Closes #14619 2014-06-03 10:52:54 -05:00
Alex Crichton
bba701c59d std: Drop Total from Total{Eq,Ord}
This completes the last stage of the renaming of the comparison hierarchy of
traits. This change renames TotalEq to Eq and TotalOrd to Ord.

In the future the new Eq/Ord will be filled out with their appropriate methods,
but for now this change is purely a renaming change.

[breaking-change]
2014-06-01 10:31:27 -07:00
Alex Crichton
748bc3ca49 std: Rename {Eq,Ord} to Partial{Eq,Ord}
This is part of the ongoing renaming of the equality traits. See #12517 for more
details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord}
or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}.

cc #12517

[breaking-change]
2014-05-30 15:52:24 -07:00
Kevin Butler
ed5bf6621e lib{serialize, uuid}: Fix snake case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

serialize::ebml::reader::Doc => seriaize::ebml::Doc::new
serialize::ebml::reader::Decoder => Decoder::new
serialize::ebml::writer::Encoder => Encoder::new

[breaking-change]
2014-05-30 17:55:41 +01:00
Alex Crichton
925ff65118 std: Recreate a rand module
This commit shuffles around some of the `rand` code, along with some
reorganization. The new state of the world is as follows:

* The librand crate now only depends on libcore. This interface is experimental.
* The standard library has a new module, `std::rand`. This interface will
  eventually become stable.

Unfortunately, this entailed more of a breaking change than just shuffling some
names around. The following breaking changes were made to the rand library:

* Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
  will return an infinite stream of random values. Previous behavior can be
  regained with `rng.gen_iter().take(n).collect()`

* Rng::gen_ascii_str() was removed. This has been replaced with
  Rng::gen_ascii_chars() which will return an infinite stream of random ascii
  characters. Similarly to gen_iter(), previous behavior can be emulated with
  `rng.gen_ascii_chars().take(n).collect()`

* {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
  relied on being able to use an OSRng for seeding, but this is no longer
  available in librand (where these types are defined). To retain the same
  functionality, these types now implement the `Rand` trait so they can be
  generated with a random seed from another random number generator. This allows
  the stdlib to use an OSRng to create seeded instances of these RNGs.

* Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
  pretty rare in the codebase, and it allows for librand to not depend on
  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
  supported.  If this is undesirable, librand can depend on liballoc and regain
  these implementations.

* The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
  but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
  structure now has a lifetime associated with it.

* The `sample` method on `Rng` has been moved to a top-level function in the
  `rand` module due to its dependence on `Vec`.

cc #13851

[breaking-change]
2014-05-29 16:18:26 -07:00
Alex Crichton
42aed6bde2 std: Remove format_strbuf!()
This was only ever a transitionary macro.
2014-05-28 08:35:41 -07:00
Alex Crichton
b53454e2e4 Move std::{reflect,repr,Poly} to a libdebug crate
This commit moves reflection (as well as the {:?} format modifier) to a new
libdebug crate, all of which is marked experimental.

This is a breaking change because it now requires the debug crate to be
explicitly linked if the :? format qualifier is used. This means that any code
using this feature will have to add `extern crate debug;` to the top of the
crate. Any code relying on reflection will also need to do this.

Closes #12019

[breaking-change]
2014-05-27 21:44:51 -07:00
bors
911cc9c352 auto merge of #14414 : richo/rust/features/nerf_unused_string_fns, r=alexcrichton
This should block on #14323
2014-05-27 17:46:48 -07:00
Richo Healey
1f1b2e42d7 std: Rename strbuf operations to string
[breaking-change]
2014-05-27 12:59:31 -07:00
Erick Tryzelaar
85d9cfb809 serialize: Remove old commented out code 2014-05-27 10:20:02 -07:00
Richo Healey
553074506e core: rename strbuf::StrBuf to string::String
[breaking-change]
2014-05-24 21:48:10 -07:00
Adolfo Ochagavía
9088a56db1 Removed unnecessary macro declaration 2014-05-24 18:11:30 +02:00
bors
a0960a1223 auto merge of #14348 : alexcrichton/rust/doc.rust-lang.org, r=huonw 2014-05-22 16:56:23 -07:00
Patrick Walton
e878721d70 libcore: Remove all uses of ~str from libcore.
[breaking-change]
2014-05-22 14:42:02 -07:00
Patrick Walton
5633d4641f libstd: Remove all uses of ~str from libstd 2014-05-22 14:42:02 -07:00
Patrick Walton
36195eb91f libstd: Remove ~str from all libstd modules except fmt and str. 2014-05-22 14:42:01 -07:00
Alex Crichton
799ddba8da Change static.rust-lang.org to doc.rust-lang.org
The new documentation site has shorter urls, gzip'd content, and index.html
redirecting functionality.
2014-05-21 19:55:39 -07:00
Patrick Walton
28bcef85e4 libserialize: Remove all uses of ~str from libserialize.
Had to make `struct Tm` in `libtime` not serializable for now.
2014-05-16 11:41:27 -07:00
Alex Crichton
1de4b65d2a Updates with core::fmt changes
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used
   instead.
2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro
   is preferred wherever possible.
3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15 23:22:06 -07:00
bors
84406d438c auto merge of #14213 : kballard/rust/str_from_utf8_result, r=cmr
Change `str::from_utf8_owned()` and `StrBuf::from_utf8()` to return `Result`.

This allows the vector to be recovered when it contains invalid UTF-8.
2014-05-15 21:41:29 -07:00
Kevin Ballard
ba7844a7ff Change StrBuf::from_utf8() to return Result
This allows the original vector to be recovered in the event that it is
not UTF-8.

[breaking-change]
2014-05-14 17:35:55 -07:00
Alex Crichton
af00c57379 serialize: Broaden ignores of json tests
It was thought that these failures only happened on windows, turns out they
happen on any 32-bit machine.

cc #14064
2014-05-13 09:28:26 -07:00
Brian Anderson
c1da4f875f Add the patch number to version strings. Closes #13289 2014-05-12 19:52:29 -07:00
Alex Crichton
f94d671bfa core: Remove the cast module
This commit revisits the `cast` module in libcore and libstd, and scrutinizes
all functions inside of it. The result was to remove the `cast` module entirely,
folding all functionality into the `mem` module. Specifically, this is the fate
of each function in the `cast` module.

* transmute - This function was moved to `mem`, but it is now marked as
              #[unstable]. This is due to planned changes to the `transmute`
              function and how it can be invoked (see the #[unstable] comment).
              For more information, see RFC 5 and #12898

* transmute_copy - This function was moved to `mem`, with clarification that is
                   is not an error to invoke it with T/U that are different
                   sizes, but rather that it is strongly discouraged. This
                   function is now #[stable]

* forget - This function was moved to `mem` and marked #[stable]

* bump_box_refcount - This function was removed due to the deprecation of
                      managed boxes as well as its questionable utility.

* transmute_mut - This function was previously deprecated, and removed as part
                  of this commit.

* transmute_mut_unsafe - This function doesn't serve much of a purpose when it
                         can be achieved with an `as` in safe code, so it was
                         removed.

* transmute_lifetime - This function was removed because it is likely a strong
                       indication that code is incorrect in the first place.

* transmute_mut_lifetime - This function was removed for the same reasons as
                           `transmute_lifetime`

* copy_lifetime - This function was moved to `mem`, but it is marked
                  `#[unstable]` now due to the likelihood of being removed in
                  the future if it is found to not be very useful.

* copy_mut_lifetime - This function was also moved to `mem`, but had the same
                      treatment as `copy_lifetime`.

* copy_lifetime_vec - This function was removed because it is not used today,
                      and its existence is not necessary with DST
                      (copy_lifetime will suffice).

In summary, the cast module was stripped down to these functions, and then the
functions were moved to the `mem` module.

    transmute - #[unstable]
    transmute_copy - #[stable]
    forget - #[stable]
    copy_lifetime - #[unstable]
    copy_mut_lifetime - #[unstable]

[breaking-change]
2014-05-11 01:13:02 -07:00
bors
5b4774dafc auto merge of #14065 : alexcrichton/rust/ignore-flaky-windows-test, r=brson
See #14064 for some rationale, but the basic idea is that I suspect that there
is an LLVM codegen bug somewhere, and I'm not entirely sure why it's happening
intermittently rather than deterministically...

cc #14064
2014-05-09 20:31:31 -07:00
Alex Crichton
300109e5eb serialize: Ignore two flaky json tests on windows
See #14064 for some rationale, but the basic idea is that I suspect that there
is an LLVM codegen bug somewhere, and I'm not entirely sure why it's happening
intermittently rather than deterministically...

cc #14064
2014-05-09 09:49:30 -07:00
Kevin Ballard
f582150159 Restore Decodable impl for ~[T]
Bring back the Decodable impl for ~[T], this time using FromVec. It's
still not recommended that anyone use this, but at least it's available
if necessary.
2014-05-08 12:08:01 -07:00
Kevin Ballard
eab6bb2ece Handle fallout in documentation
Tweak the tutorial's section on vectors and strings, to slightly clarify
the difference between fixed-size vectors, vectors, and slices.
2014-05-08 12:06:22 -07:00
Kevin Ballard
cd3f31d9d1 Handle fallout in libserialize
API Changes:

- from_base64() returns Result<Vec<u8>, FromBase64Error>
- from_hex() returns Result<Vec<u8>, FromHexError>
- json::List is a Vec<Json>
- Decodable is no longer implemented on ~[T] (but Encodable still is)
- DecoderHelpers::read_to_vec() returns a Result<Vec<T>, E>
2014-05-08 12:06:22 -07:00
Alex Crichton
91ede1f09a core: Inherit non-allocating slice functionality
This commit adds a new trait, MutableVectorAllocating, which represents
functions on vectors which can allocate.

This is another extension trait to slices which should be removed once a lang
item exists for the ~ allocation.
2014-05-07 08:15:58 -07:00
Patrick Walton
090040bf40 librustc: Remove ~EXPR, ~TYPE, and ~PAT from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]
2014-05-06 23:12:54 -07:00
bors
0c691df8ac auto merge of #13773 : brson/rust/boxxy, r=alexcrichton
`box` is the way you allocate in future-rust.
2014-05-03 10:56:57 -07:00
Brian Anderson
a5be12ce7e Replace most ~exprs with 'box'. #11779 2014-05-02 23:00:58 -07:00
Herman J. Radtke III
923a8f39ca Implement ToJson for Vec<T>
Now that ~[T] is obsolete, we need to allow to_json() to work for
vectors.
2014-05-02 00:02:15 -07:00
bors
adcbf53955 auto merge of #13886 : japaric/rust/fix-an-typos, r=alexcrichton
Found the first one in the rust reference docs. I was going to submit a PR with one fix, but figured I could look for more... This is the result.
2014-05-01 20:11:47 -07:00
Jorge Aparicio
e4bf643b99 Fix a/an typos 2014-05-01 20:02:11 -05:00
bors
9f836d5a53 auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton 2014-05-01 16:06:48 -07:00
Daniel Micay
7852625b86 remove leftover obsolete string literals 2014-05-01 17:42:57 -04:00
Herman J. Radtke III
fa6efedccf Add serialization support for StrBuf
- implement Encodable and Decodable for StrBuf
- implement to_json for StrBuf
2014-04-30 23:49:00 -07:00
Patrick Walton
4baff4e15f librustc: Remove ~"string" and &"string" from the language 2014-04-30 16:49:12 -07:00
bors
9f484e616e auto merge of #13648 : gereeter/rust/removed-rev, r=alexcrichton
In the process, `Splits` got changed to be more like `CharSplits` in `str` to present the DEI interface.

Note that `treemap` still has a `rev_iter` function because it seems like it would be a significant interface change to expose a DEI - the iterator would have to gain an extra pointer, the completion checks would be more complicated, and it isn't easy to check that such an implementation is correct due to the use of unsafety to subvert the aliasing properties of `&mut`.

This fixes #9391.
2014-04-30 15:46:47 -07:00
Jonathan S
03609e5a5e Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is provided (everywhere but treemap)
This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also
deprecates related functions like rsplit, rev_components, and rev_str_components. In every case,
these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this
more concrete, a translation table for all functional changes necessary follows:

* container.rev_iter() -> container.iter().rev()
* container.mut_rev_iter() -> container.mut_iter().rev()
* container.move_rev_iter() -> container.move_iter().rev()
* sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev()
* path.rev_components() -> path.components().rev()
* path.rev_str_components() -> path.str_components().rev()

In terms of the type system, this change also deprecates any specialized reversed iterator types (except
in treemap), opting instead to use Rev directly if any type annotations are needed. However, since
methods directly returning reversed iterators are now discouraged, the need for such annotations should
be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in
the original reversed name and surround it with Rev<>:

* RevComponents<'a> -> Rev<Components<'a>>
* RevStrComponents<'a> -> Rev<StrComponents<'a>>
* RevItems<'a, T> -> Rev<Items<'a, T>>
* etc.

The reasoning behind this change is that it makes the standard API much simpler without reducing readability,
performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries
(all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two
characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice
like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft
goes away.

[breaking-change]
2014-04-28 16:45:36 -05:00
Nicolas Silva
18bed22e5a Fix a code formatting issue in json.rs 2014-04-27 23:09:57 +02:00
Nicolas Silva
cd3b54a3f1 Add a streaming parser to serialize::json. 2014-04-27 23:09:56 +02:00
Richo Healey
d46c737d3b serialize: Remove errant println!'s from decode 2014-04-19 17:59:04 -07:00
Richo Healey
919889a1d6 Replace all ~"" with "".to_owned() 2014-04-18 17:25:34 -07:00
Alex Crichton
675b82657e Update the rest of the compiler with ~[T] changes 2014-04-18 10:57:10 -07:00
Huon Wilson
54ec04f1c1 Use the unsigned integer types for bitwise intrinsics.
Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just
exposing the internal LLVM names pointlessly (LLVM doesn't have "signed
integers" or "unsigned integers", it just has sized integer types
with (un)signed *operations*).

These operations are semantically working with raw bytes, which the
unsigned types model better.
2014-04-15 19:45:00 -07:00
Keegan McAllister
cee9a83629 Decode non-BMP hex escapes in JSON
Fixes #13064.
2014-04-11 15:54:46 -07:00
Liigo Zhuang
408f484b66 libtest: rename BenchHarness to Bencher
Closes #12640
2014-04-11 17:31:13 +08:00
bors
cea8def620 auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it.

Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
2014-04-10 21:01:41 -07:00
Huon Wilson
a65411e4f7 std,serialize: remove some internal uses of ~[].
These are all private uses of ~[], so can easily & non-controversially
be replaced with Vec.
2014-04-10 15:21:58 -07:00
Patrick Walton
d8e45ea7c0 libstd: Implement StrBuf, a new string buffer type like Vec, and
port all code over to use it.
2014-04-10 22:10:10 +10:00
Steven Fackler
49a8081095 De-~[] Mem{Reader,Writer} 2014-04-06 15:40:01 -07:00
Steven Fackler
d0e60b72ee De-~[] Reader and Writer
There's a little more allocation here and there now since
from_utf8_owned can't be used with Vec.
2014-04-06 15:39:56 -07:00
bors
2a2d0dce87 auto merge of #13296 : brson/rust/0.11-pre, r=alexcrichton
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 19:56:45 -07:00
bors
e7fe207229 auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichton
Closes #13285 (rustc: Stop using LLVMGetSectionName)
Closes #13280 (std: override clone_from for Vec.)
Closes #13277 (serialize: add a few missing pubs to base64)
Closes #13275 (Add and remove some ignore-win32 flags)
Closes #13273 (Removed managed boxes from libarena.)
Closes #13270 (Minor copy-editing for the tutorial)
Closes #13267 (fix Option<~ZeroSizeType>)
Closes #13265 (Update emacs mode to support new `#![inner(attribute)]` syntax.)
Closes #13263 (syntax: Remove AbiSet, use one Abi)
2014-04-03 17:17:02 -07:00
Brian Anderson
0875ffcbff Bump version to 0.11-pre
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 16:28:46 -07:00
bors
bb31cb8d2e auto merge of #13286 : alexcrichton/rust/release, r=brson
Merging the 0.10 release into the master branch.
2014-04-03 13:52:03 -07:00
Arcterus
696a005181 serialize: add a few missing pubs to base64 2014-04-03 13:42:48 -07:00
Alex Crichton
9a259f4303 Fix fallout of requiring uint indices 2014-04-02 15:56:31 -07:00
Alex Crichton
ee7016d95f serialize: Switch field privacy as necessary 2014-03-31 15:47:36 -07:00
Alex Crichton
a5681d2590 Bump version to 0.10 2014-03-31 14:40:44 -07:00
Eunchong Yu
2deca5840e Json doesn't need to depend on IoError to implement Encodable #13230 2014-04-01 03:05:32 +09:00
Marvin Löbel
c356e3ba6a Removed deprecated functions map and flat_map for vectors and slices. 2014-03-30 03:47:04 +02:00
bors
df9cf18c10 auto merge of #13188 : FlaPer87/rust/master, r=alexcrichton 2014-03-29 02:56:40 -07:00
Flavio Percoco
a9c6061c9a Register new snapshot 2014-03-29 01:12:32 +01:00
Brian Anderson
451e8c1c61 Convert most code to new inner attribute syntax.
Closes #2569
2014-03-28 17:12:21 -07:00
Sean McArthur
f1739b14a1 serialize: use Result
All of Decoder and Encoder's methods now return a Result.

Encodable.encode() and Decodable.decode() return a Result as well.

fixes #12292
2014-03-27 17:41:55 -07:00
Alex Crichton
bb9172d7b5 Fix fallout of removing default bounds
This is all purely fallout of getting the previous commit to compile.
2014-03-27 10:14:50 -07:00
bors
1599ac9cf2 auto merge of #13095 : alexcrichton/rust/serialize-tuple, r=huonw
This commit moves from {read,emit}_seq for tuples to {read,emit}_tuple, as well
as providing a generalized macro for generating these implementations from one
invocation.

Closes #13086
2014-03-23 15:16:48 -07:00
Alex Crichton
e46e9332d9 serialize: Read/emit tuples with {read,emit}_tuple
This commit moves from {read,emit}_seq for tuples to {read,emit}_tuple, as well
as providing a generalized macro for generating these implementations from one
invocation.

Closes #13086
2014-03-23 10:10:13 -07:00
Flavio Percoco
576e36e674 Register new snapshots 2014-03-23 11:37:31 +01:00
Daniel Micay
3829ac2a52 use TotalEq for HashMap
Closes #5283
2014-03-23 01:59:11 -04:00
Alex Crichton
3fb1ed0e04 rustc: Remove all usage of manual deref()
Favor using '*' instead
2014-03-22 08:48:34 -07:00
Alex Crichton
11ac4df4d2 Register new snapshots 2014-03-20 11:02:26 -07:00
Alex Crichton
da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Daniel Micay
14f656d1a7 rename std::vec_ng -> std::vec
Closes #12771
2014-03-20 04:25:32 -04:00
Daniel Micay
ce620320a2 rename std::vec -> std::slice
Closes #12702
2014-03-20 01:30:27 -04:00
Jeff Olson
2265512033 closes #12967 fix [en|de]coding of HashMap<K,V> where K is a numeric type
serialize: ref #12697 minor adj. to last char check + prettyencode test
2014-03-18 13:49:13 -07:00
Corey Richardson
f9e0baa19a remove duplicate methods in impls 2014-03-18 13:47:42 -07:00
Alex Crichton
cc6ec8df95 log: Introduce liblog, the old std::logging
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level <= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level <= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
2014-03-15 22:26:36 -07:00
Steven Fackler
9106c15ffd Add rustdoc html crate info 2014-03-15 14:26:12 -07:00
Huon Wilson
62792f09f2 lint: add lint for use of a ~[T].
This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-14 11:28:39 +11:00
Eduard Burtescu
cdc18b96d6 Remove Rc's borrow method to avoid conflicts with RefCell's borrow in Rc<RefCell<T>>. 2014-03-13 14:21:45 +02:00
Erick Tryzelaar
d2cfd543f7 serialize: make Paths serializable 2014-03-12 18:58:54 -07:00
zslayton
0bfb61ed9d Closes #12829. Names changed for consistency, find_path optimized, method impls refactored to reduce repitition.
Fixed formatting, reworked find_path to use fewer Options.

Removed stray tab.
2014-03-12 15:01:25 -07:00
Huon Wilson
198caa87cd Update users for the std::rand -> librand move. 2014-03-12 11:31:43 +11:00
zslayton
9e0cfa23e8 Added convenience methods and accompanying tests to the Json class.
Fixed some styling issues with trailing whitespace.

- Removed redundant functions.
- Renamed `get` to `find`
- Renamed `get_path` to `find_path`
- Renamed `find` to `search`
- Changed as_object and as_list to return Object and List
  rather than the underlying implementation types
  of TreeMap<~str,Json> and ~[Json]
- Refactored find_path to use a fold() instead of recursion

Formatting fixes.

Fixed spacing, deleted comment.

Added convenience methods and accompanying tests to the Json class.

Updated tests to expect less pointer indirection.
2014-03-11 12:13:46 -04:00
Alex Crichton
42389b7069 collections: Correct with_capacity_and_hasher
The arguments were accidentally swapped in the wrong order.

Closes #12743
2014-03-06 18:07:52 -08:00
Palmer Cox
6d9bdf975a Rename all variables that have uppercase characters in their names to use only lowercase characters 2014-03-04 21:23:36 -05:00
Marvin Löbel
3158047a45 Cleaned up std::any
- Added `TraitObject` representation to `std::raw`.
- Added doc to `std::raw`.
- Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()`
  methods as they are uneccessary now after the removal of
  headers on owned boxes. This reduces the number of virtual calls needed.
- Made the `..Ext` implementations work directly with the repr of
  a trait object.
- Removed `Any`-related traits from the prelude.

- Added bench for `Any`
2014-03-04 21:10:23 +01:00
Alex Crichton
02882fbd7e std: Change assert_eq!() to use {} instead of {:?}
Formatting via reflection has been a little questionable for some time now, and
it's a little unfortunate that one of the standard macros will silently use
reflection when you weren't expecting it. This adds small bits of code bloat to
libraries, as well as not always being necessary. In light of this information,
this commit switches assert_eq!() to using {} in the error message instead of
{:?}.

In updating existing code, there were a few error cases that I encountered:

* It's impossible to define Show for [T, ..N]. I think DST will alleviate this
  because we can define Show for [T].
* A few types here and there just needed a #[deriving(Show)]
* Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
* `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
  I don't think this is much of a regression though because {:?} on paths looks
  awful (it's a byte array).

Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
significant for smaller binaries.
2014-02-28 23:01:54 -08:00
Erick Tryzelaar
72b5e30f6c collections: allow HashMap to work with generic hashers 2014-02-27 19:02:52 -08:00
bors
994b48cf52 auto merge of #12453 : alexcrichton/rust/move-json, r=brson
This also inverts the dependency between libserialize and libcollections.

cc #8784
2014-02-24 15:57:13 -08:00
bors
b48bc9ec93 auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichton
Commits for details. Highlights:

- `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]`
- a lot of `transmute`s removed outright or replaced with `as` (etc.)
2014-02-24 14:37:01 -08:00
Alex Crichton
6485917d7c Move extra::json to libserialize
This also inverts the dependency between libserialize and libcollections.

cc #8784
2014-02-24 09:51:39 -08:00
Alex Crichton
b78b749810 Remove all ToStr impls, add Show impls
This commit changes the ToStr trait to:

    impl<T: fmt::Show> ToStr for T {
        fn to_str(&self) -> ~str { format!("{}", *self) }
    }

The ToStr trait has been on the chopping block for quite awhile now, and this is
the final nail in its coffin. The trait and the corresponding method are not
being removed as part of this commit, but rather any implementations of the
`ToStr` trait are being forbidden because of the generic impl. The new way to
get the `to_str()` method to work is to implement `fmt::Show`.

Formatting into a `&mut Writer` (as `format!` does) is much more efficient than
`ToStr` when building up large strings. The `ToStr` trait forces many
intermediate allocations to be made while the `fmt::Show` trait allows
incremental buildup in the same heap allocated buffer. Additionally, the
`fmt::Show` trait is much more extensible in terms of interoperation with other
`Writer` instances and in more situations. By design the `ToStr` trait requires
at least one allocation whereas the `fmt::Show` trait does not require any
allocations.

Closes #8242
Closes #9806
2014-02-23 20:51:56 -08:00
Huon Wilson
9e8d5aa29e arena,std,serialize: remove some unnecessary transmutes.
`as`-able transmutes, duplication and manual slice decomposition are
silly.
2014-02-24 01:15:39 +11:00
Alex Crichton
2a14e084cf Move std::{trie, hashmap} to libcollections
These two containers are indeed collections, so their place is in
libcollections, not in libstd. There will always be a hash map as part of the
standard distribution of Rust, but by moving it out of the standard library it
makes libstd that much more portable to more platforms and environments.

This conveniently also removes the stuttering of 'std::hashmap::HashMap',
although 'collections::HashMap' is only one character shorter.
2014-02-23 00:35:11 -08:00
bors
22d3669b9e auto merge of #11863 : erickt/rust/hash, r=acrichto
This PR merges `IterBytes` and `Hash` into a trait that allows for generic non-stream-based hashing. It makes use of @eddyb's default type parameter support in order to have a similar usage to the old `Hash` framework.

Fixes #8038.

Todo:

- [x] Better documentation
- [ ] Benchmark
- [ ] Parameterize `HashMap` on a `Hasher`.
2014-02-22 15:01:58 -08:00
Eduard Bopp
9982de6397 Warn about unnecessary parentheses upon assignment
Closes #12366.

Parentheses around assignment statements such as

    let mut a = (0);
    a = (1);
    a += (2);

are not necessary and therefore an unnecessary_parens warning is raised when
statements like this occur.

The warning mechanism was refactored along the way to allow for code reuse
between the routines for checking expressions and statements.

Code had to be adopted throughout the compiler and standard libraries to comply
with this modification of the lint.
2014-02-22 16:32:48 +01:00
Erick Tryzelaar
d223dd1e57 std: rewrite Hash to make it more generic
This patch merges IterBytes and Hash traits, which clears up the
confusion of using `#[deriving(IterBytes)]` to support hashing.
Instead, it now is much easier to use the new `#[deriving(Hash)]`
for making a type hashable with a stream hash.

Furthermore, it supports custom non-stream-based hashers, such as
if a value's hash was cached in a database.

This does not yet replace the old IterBytes-hash with this new
version.
2014-02-21 21:33:23 -08:00
Patrick Walton
03b791095d libstd: Implement some convenience methods on vectors 2014-02-21 10:54:14 -08:00
Alex Crichton
7bb498bd7a Mass rename if_ok! to try!
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 09:16:52 -08:00
Liigo Zhuang
53b9d1a324 move extra::test to libtest 2014-02-20 16:03:58 +08:00
Alex Crichton
a41b0c2529 extern mod => extern crate
This was previously implemented, and it just needed a snapshot to go through
2014-02-14 22:55:21 -08:00
JeremyLetang
60bc76fb78 remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset) 2014-02-13 12:54:17 -08:00
Liigo Zhuang
8a5b938b3b Move base64 and hex from libextra to libserialize 2014-02-13 12:50:25 -08:00
Brian Anderson
073b655187 std: Move byteswap functions to mem 2014-02-09 00:17:41 -08:00
Jeff Olson
b8852e89ce pull extra::{serialize, ebml} into a separate libserialize crate
- `extra::json` didn't make the cut, because of `extra::json` required
   dep on `extra::TreeMap`. If/when `extra::TreeMap` moves out of `extra`,
   then `extra::json` could move into `serialize`
- `libextra`, `libsyntax` and `librustc` depend on the newly created
  `libserialize`
- The extensions to various `extra` types like `DList`, `RingBuf`, `TreeMap`
  and `TreeSet` for `Encodable`/`Decodable` were moved into the respective
  modules in `extra`
- There is some trickery, evident in `src/libextra/lib.rs` where a stub
  of `extra::serialize` is set up (in `src/libextra/serialize.rs`) for
  use in the stage0 build, where the snapshot rustc is still making
  deriving for `Encodable` and `Decodable` point at extra. Big props to
  @huonw for help working out the re-export solution for this

extra: inline extra::serialize stub

fix stuff clobbered in rebase + don't reexport serialize::serialize

no more globs in libserialize

syntax: fix import of libserialize traits

librustc: fix bad imports in encoder/decoder

add serialize dep to librustdoc

fix failing run-pass tests w/ serialize dep

adjust uuid dep

more rebase de-clobbering for libserialize

fixing tests, pushing libextra dep into cfg(test)

fix doc code in extra::json

adjust index.md links to serialize and uuid library
2014-02-05 10:38:22 -08:00