Commit Graph

30157 Commits

Author SHA1 Message Date
Alexandre Gagnon d6c988a669 Vim syntax file types and traits cleanup 2014-07-01 00:52:51 -04:00
bors 5cef1243a2 auto merge of #15242 : pcwalton/rust/self-in-trait-methods, r=alexcrichton
I can't believe this worked! I believe that the way the ABI and
immediates work mean that this Just Works.

Closes #10672.

r? @alexcrichton
2014-07-01 02:51:33 +00:00
Patrick Walton 68ead460f9 librustc: Permit by-value-self methods to be invoked on objects
referenced by boxes.

This is done by creating a shim function that handles the cleanup of the
box properly.

Closes #10672.
2014-06-30 18:43:31 -07:00
bors 90ab2f8b61 auto merge of #15271 : jasonthompson/rust/docs/str, r=huonw
I'm working on adding examples to the API documentation. Should future pull requests include examples for more than one function? Or is this about the right size for a pull request?
2014-07-01 01:01:36 +00:00
bors db29e1b960 auto merge of #15247 : smenardpw/rust/patch-1, r=alexcrichton
./hello_world is not recognized on Windows.
We can type either hello_world or hello_world.exe to run the executable. I chose "hello_world.exe", which seems more conventional on Windows.
2014-06-30 23:06:35 +00:00
bors 8bc286f998 auto merge of #15238 : aochagavia/rust/json, r=alexcrichton
### Breaking changes:

* **Removed unnecessary `box` from enum variant (`Object(Box<Object>)` becomes `Object(Object)`)**
* **Deprecated `Encoder::str_encode`**

### Other changes:

* 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
* Added `encode` and `decode` shortcut functions
* Implemented `FromStr` for `Json`
* Implemented `ToJson` for tuples of arity up to 12
* Fixed some details in the documentation

### Questions

* ~~The `encode` shortcut function does the same as the `Encoder::str_encode` function. It seems wrong to me that two functions do exactly the same. Should we deprecate `Encoder::str_encode`?~~
* ~~Do we really want the ToJson trait for tuples? At the moment we have it for (), (A, B), (A, B, C). I would like to remove them.~~
* ~~We are using `String` as key in the `TreeMap` representing a `Json` object. It would be better to use `&str`, but this would require to annotate lots of lifetimes. Is there any easy solution for this?~~
* There is a lot of duplicated code (`PrettyEncoder` copies about 50 lines from `Encoder`). In an OO language this could be solved very elegantly by using inheritance and overriding. What can we do here to reduce the amount of boilerplate?

[breaking-change]
2014-06-30 21:16:32 +00:00
Adolfo Ochagavía c3cf3b3fb1 Implement ToJson for all tuples 2014-06-30 21:35:50 +02:00
Adolfo Ochagavía 035914edcf Fix issues in librustdoc 2014-06-30 21:35:49 +02:00
Adolfo Ochagavía fb96cbba41 Fix issue with tests 2014-06-30 21:35:49 +02:00
Adolfo Ochagavía 903759e611 Fix issues in libtest 2014-06-30 21:35:48 +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
bors a345c54334 auto merge of #14613 : schmee/rust/utf16-iterator, r=huonw
Closes #14358.

~~The tests are not yet moved to `utf16_iter`, so this probably won't compile. I'm submitting this PR anyway so it can be reviewed and since it was mentioned in #14611.~~ EDIT: Tests now use `utf16_iter`.

This deprecates `.to_utf16`. `x.to_utf16()` should be replaced by either `x.utf16_iter().collect::<Vec<u16>>()` (the type annotation may be optional), or just `x.utf16_iter()` directly, if it can be used in an iterator context.

[breaking-change]

cc @huonw
2014-06-30 19:26:35 +00:00
John Schmidt 3d84b4be3d Add `utf16_units`
This deprecates `.to_utf16`. `x.to_utf16()` should be replaced by either
`x.utf16_units().collect::<Vec<u16>>()` (the type annotation may be optional), or
just `x.utf16_units()` directly, if it can be used in an iterator context.

Closes #14358

[breaking-change]
2014-06-30 18:50:32 +02:00
bors 94343da1bd auto merge of #15275 : sfackler/rust/distcheck, r=alexcrichton
libcoretest wasn't being included which broke the verification of the
tarball.
2014-06-30 16:36:33 +00:00
Jason Thompson 0bfcfcffa7 add example for from_byte() documenation 2014-06-30 12:30:05 -04:00
Steven Fackler 21dba11fec Fix distcheck
libcoretest wasn't being included which broke the verification of the
tarball.
2014-06-30 09:13:09 -07:00
bors 04da31e64c auto merge of #15267 : ruud-v-a/rust/patch-1, r=huonw
[This commit](25fe2cadb1 (diff-04c6e90faac2675aa89e2176d2eec7d8R57)) forgot to remove one line.
2014-06-30 14:06:31 +00:00
bors 566b57f3de auto merge of #15259 : steveklabnik/rust/patch-3, r=alexcrichton
It wasn't clear if we needed to install Hello World or Cargo.
2014-06-30 12:16:30 +00:00
bors 287dcb77b3 auto merge of #15262 : zecozephyr/rust/15620, r=luqmana
Fixes #15260
2014-06-30 10:26:28 +00:00
Ruud van Asseldonk 9df25449f2 fix typo in readme 2014-06-30 11:17:25 +02:00
bors 2735c7bb10 auto merge of #15237 : zzmp/rust/feat/markdown-in-crate-documentation, r=huonw
This makes the `in-header`, `markdown-before-content`, and `markdown-after-content` options available to `rustdoc` when generating documentation for any crate.

Before, these options were only available when creating documentation *from* markdown. Now, they are available when generating documentation from source.

This also updates the `rustdoc -h` output to reflect these changes. It does not update the `man rustdoc` page, nor does it update the documentation in [the `rustdoc` manual](http://doc.rust-lang.org/rustdoc.html).
2014-06-30 07:31:29 +00:00
zzmp 63afc08262 Allow external html in rustdoc for crates.
Updated documentation to reflect md->html.
Modularized external file loading.
2014-06-30 00:03:34 -07:00
smenardpw f6f1cf13d0 Little typo fix
- ./hello_world which is not recognized on Windows fixed.
- .exe extension added.
- Little rewriting.
2014-06-30 07:43:15 +02:00
Jonathan Bailey 6821a18122 librustc: Don't ICE on binding same field multiple times in struct
pattern.
2014-06-29 22:38:53 -07:00
bors e1683f50c0 auto merge of #15030 : sfackler/rust/partial-cmp, r=huonw
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`.

# Note
This isn't ready to merge yet since libcore tests are broken as you end up with 2 versions of `Option`. The rest should be reviewable though.

RFC: 0028-partial-cmp
2014-06-30 05:36:25 +00: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
bors e25eb6b223 auto merge of #15256 : erickt/rust/optimizations, r=alexcrichton
The bug #11084 causes `option::collect` and `result::collect` about twice as slower as it should because llvm is having some trouble optimizing away the scan closure. This gets rid of it so now those functions perform equivalent to a hand written version.

This also adds an impl of `Default` for `Rc` along the way.
2014-06-30 03:46:25 +00:00
bors 9ae48286a9 auto merge of #15254 : alex/rust/patch-1, r=alexcrichton
This makes the docs ever-so-slightly easier to read.
2014-06-30 01:56:26 +00:00
Steve Klabnik 572234ceac it -> Cargo
It wasn't clear if we needed to install Hello World or Cargo.
2014-06-29 21:51:41 -04:00
bors bb5695b95c auto merge of #15245 : sfackler/rust/coretest, r=alexcrichton
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
2014-06-29 23:36:43 +00:00
Steven Fackler 1ed646eaf7 Extract tests from libcore to a separate crate
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
2014-06-29 15:57:21 -07:00
bors a490871a6c auto merge of #15252 : alexcrichton/rust/issue-15231, r=pcwalton
When cloning a stream, the data is already guaranteed to be in a consistent
state, so there's no need to perform a zeroing. This prevents segfaults as seen
in #15231

Closes #15231
2014-06-29 21:41:45 +00:00
bors ff94f867d2 auto merge of #15234 : pcwalton/rust/integer-fallback-and-casts, r=alexcrichton
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]

r? @alexcrichton
2014-06-29 19:46:46 +00:00
Erick Tryzelaar ab1bd3adf6 core: optimize {option,result}::collect
The bug #11084 causes these collect functions to run about
twice as slow as they should because llvm is having trouble
optimizing away the closure for some reason. This patch works
around that performance bug by using a simple adapter iterator
explicitly for capturing if the outer iterator returns an
error.
2014-06-29 12:32:24 -07:00
Erick Tryzelaar 1ea9991921 alloc: impl Default for Rc 2014-06-29 12:32:24 -07:00
Erick Tryzelaar 2317840c14 collections: minor cleanup 2014-06-29 12:29:36 -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
Alex Gaynor c420f448b3 Wrap two code examples in backticks
This makes the docs ever-so-slightly easier to read.
2014-06-29 11:11:03 -07:00
bors cc5663ad55 auto merge of #15246 : Sawyer47/rust/rand-doc-fix, r=alexcrichton
Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
2014-06-29 17:51:39 +00:00
Alex Crichton ca7fb82e0b rustuv: Don't zero-out data on clones
When cloning a stream, the data is already guaranteed to be in a consistent
state, so there's no need to perform a zeroing. This prevents segfaults as seen
in #15231

Closes #15231
2014-06-29 09:38:07 -07:00
bors bd9563aa38 auto merge of #15249 : aochagavia/rust/rand, r=huonw 2014-06-29 13:11:36 +00:00
bors b569c77148 auto merge of #14904 : huonw/rust/cstr-remove-withref, r=alexcrichton 2014-06-29 11:21:39 +00:00
Huon Wilson 569f13a521 c_str: move `.unwrap` & document it more clearly.
This should be called rarely, but it was placed first in the list of
methods, making it very tempting to call.
2014-06-29 21:15:26 +10:00
Huon Wilson d4d4bc4fe9 c_str: replace .with_ref with .as_ptr throughout the codebase. 2014-06-29 21:15:26 +10:00
Huon Wilson 2c9aada10c c_str: add `.as_ptr` & `.as_mut_ptr` to replace `.with_[mut_]ref`.
These forms return the pointer directly, rather than the added
indirection, indentation, and inefficiencies of the closures in
`.with_ref` and `.with_mut_ref`. The two closure functions are
deprecated.

Replace

    foo(c_str.with_ref(|p| p))

    c_str.with_ref(|p| {
        foo(p);
        bar(p);
    })

with

    foo(c_str.as_ptr())

    let p = c_str.as_ptr();
    foo(p);
    bar(p);

This change does mean that one has to be careful to avoid writing `let p
= x.to_c_str().as_ptr();` since the `CString` will be freed at the end
of the statement. Previously, `with_ref` was used (and `as_ptr` avoided)
for this reason, but Rust has strongly moved away from closures to more
RAII-style code, and most uses of `.with_ref` where in the form
`.with_ref(|p| p)` anyway, that is, they were exactly `.as_ptr`.

[breaking-change]
2014-06-29 21:15:26 +10:00
Piotr Jawniak ba46c8bf66 rand: Small fix in parameter name
Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
2014-06-29 12:09:22 +02:00