Commit Graph

1108 Commits

Author SHA1 Message Date
Daniel Rosenwasser 604667fa82 Added support for a `\0` escape sequence.
This commit adds support for `\0` escapes in character and string literals.

Since `\0` is equivalent to `\x00`, this is a direct translation to the latter
escape sequence. Future builds will be able to compile using `\0` directly.

Also updated the grammar specification and added a test for NUL characters.
2013-09-17 23:52:29 -04:00
Daniel Micay e12c3bfbf9 document what unsafety means
Closes #9144
2013-09-17 19:13:14 -04:00
bors 29cdf58861 auto merge of #9244 : thestinger/rust/drop, r=catamorphism
This doesn't close any bugs as the goal is to convert the parameter to by-value, but this is a step towards being able to make guarantees about `&T` pointers (where T is Freeze) to LLVM.
2013-09-17 07:15:42 -07:00
bors 7ea85333ff auto merge of #9239 : steveklabnik/rust/rustpkg_tutorial, r=catamorphism
First shot at a new tutorial for rustpkg. /cc @catamorphism

Right now, I'm linking to my sample package on GitHub, I'm not sure that everyone would be comfortable with me having that there. Maybe under the mozilla org? I think having one to install and hold up as a default makes sense.
2013-09-17 04:45:45 -07:00
Daniel Micay 4e161a4d40 switch Drop to `&mut self` 2013-09-16 22:19:23 -04:00
Steve Klabnik cf2253ba3f Updating rustpkg tutorial from feedback. 2013-09-16 18:49:47 -07:00
Steve Klabnik a0b9cc6a8b New rustpkg tutorial. 2013-09-16 16:30:49 -07:00
bors bc89ade401 auto merge of #9223 : sfackler/rust/tasks-fix, r=catamorphism
This module was removed a while ago, but the tasks tutorial wasn't
updated, and the old docs page for pipes was never deleted so the link
confusingly still worked!
2013-09-16 13:30:42 -07:00
Steven Fackler 555589ef7f Remove references to std::pipes from task tutorial
This module was removed a while ago, but the tasks tutorial wasn't
updated, and the old docs page for pipes was never deleted so the link
confusingly still worked!
2013-09-15 23:37:38 -07:00
blake2-ppc 8522341274 Remove {uint,int,u64,i64,...}::from_str,from_str_radix
Remove these in favor of the two traits themselves and the wrapper
function std::from_str::from_str.

Add the function std::num::from_str_radix in the corresponding role for
the FromStrRadix trait.
2013-09-15 14:29:16 +02:00
bors 2aa578efd9 auto merge of #9115 : erickt/rust/master, r=erickt
This is a series of patches to modernize option and result. The highlights are:

* rename `.unwrap_or_default(value)` and etc to `.unwrap_or(value)`
* add `.unwrap_or_default()` that uses the `Default` trait
* add `Default` implementations for vecs, HashMap, Option
* add  `Option.and(T) -> Option<T>`, `Option.and_then(&fn() -> Option<T>) -> Option<T>`, `Option.or(T) -> Option<T>`, and `Option.or_else(&fn() -> Option<T>) -> Option<T>`
* add `option::ToOption`, `option::IntoOption`, `option::AsOption`, `result::ToResult`, `result::IntoResult`, `result::AsResult`, `either::ToEither`, and `either::IntoEither`, `either::AsEither`
* renamed `Option::chain*` and `Result::chain*` to `and_then` and `or_else` to avoid the eventual collision with `Iterator.chain`.
* Added a bunch of impls of `Default`
* Added a `#[deriving(Default)]` syntax extension
* Removed impls of `Zero` for `Option<T>` and vecs.
2013-09-14 00:01:04 -07:00
Tim Chevalier 24fdb1d102 rustc/rustpkg: Use a target-specific subdirectory in build/ and lib/
As per rustpkg.md, rustpkg now builds in a target-specific
subdirectory of build/, and installs libraries into a target-specific
subdirectory of lib.

Closes #8672
2013-09-13 10:43:22 -07:00
Erick Tryzelaar 7c08abb0ce Document the Zero trait 2013-09-12 18:54:13 -07:00
bors 49eb7bd271 auto merge of #9039 : singingboyo/rust/update-for-expr-docs, r=thestinger
The old documentation for for loops/expressions has been quite wrong since the change to iterators.  This updates the docs to make them relevant to how for loops work now, if not very in-depth.  There may be a need for updates giving more depth on how they work, such as detailing what method calls they make, but I don't know enough about the implementation to include that.
2013-09-11 07:46:04 -07:00
Daniel Micay 6919cf5fe1 rename `std::iterator` to `std::iter`
The trait will keep the `Iterator` naming, but a more concise module
name makes using the free functions less verbose. The module will define
iterables in addition to iterators, as it deals with iteration in
general.
2013-09-09 03:21:46 -04:00
Brandon Sanderson 8f31377514 Update for_expr docs. 2013-09-07 01:38:35 -07:00
novalis c891fa326d Fix #6031. Allow symbolic log levels, not just numbers. 2013-09-06 23:30:17 -04:00
Huon Wilson 506f69aed7 Implement support for indicating the stability of items.
There are 6 new compiler recognised attributes: deprecated, experimental,
unstable, stable, frozen, locked (these levels are taken directly from
Node's "stability index"[1]). These indicate the stability of the
item to which they are attached; e.g. `#[deprecated] fn foo() { .. }`
says that `foo` is deprecated.

This comes with 3 lints for the first 3 levels (with matching names) that
will detect the use of items marked with them (the `unstable` lint
includes items with no stability attribute). The attributes can be given
a short text note that will be displayed by the lint. An example:

    #[warn(unstable)]; // `allow` by default

    #[deprecated="use `bar`"]
    fn foo() { }

    #[stable]
    fn bar() { }

    fn baz() { }

    fn main() {
        foo(); // "warning: use of deprecated item: use `bar`"

        bar(); // all fine

        baz(); // "warning: use of unmarked item"
    }

The lints currently only check the "edges" of the AST: i.e. functions,
methods[2], structs and enum variants. Any stability attributes on modules,
enums, traits and impls are not checked.

[1]: http://nodejs.org/api/documentation.html
[2]: the method check is currently incorrect and doesn't work.
2013-09-04 00:12:27 +10:00
bors 7c5398b612 auto merge of #8276 : kballard/rust/iterator-protocol, r=cmr
r? @thestinger
2013-09-01 07:00:44 -07:00
Carlos c7a269fedc doc/rust.md: Missing in keyword on keyword list. 2013-08-30 13:21:14 +02:00
Kevin Ballard fb0b388804 Make the iterator protocol more explicit
Document the fact that the iterator protocol only defines behavior up
until the first None is returned. After this point, iterators are free
to behave how they wish.

Add a new iterator adaptor Fuse<T> that modifies iterators to return
None forever if they returned None once.
2013-08-29 22:49:26 -07:00
Brian Anderson d923f75d79 doc: Remove statement about scheduling randomness
The new scheduler is not currently that random.
2013-08-28 11:23:32 -07:00
Patrick Walton aac9d6eee9 librustc: Fix merge fallout 2013-08-27 19:09:27 -07:00
bors 4fa09e08ed auto merge of #8777 : Kimundi/rust/doc_stuff, r=cmr 2013-08-27 06:45:50 -07:00
Marvin Löbel 8f17ac9099 Rewrote module tutorial 2013-08-27 04:15:11 +02:00
blake2-ppc 026304cf15 doc: Link condition and error-handling tutorial from main tutorial 2013-08-26 18:10:40 +02:00
Ben Blum c678b22276 Talk about trait bounds in the tutorial. 2013-08-23 19:20:34 -04:00
bors 943f9aaa4a auto merge of #8692 : kballard/rust/ffi-tutorial-c_str, r=huonw
The FFI tutorial still incorrectly stated that strings were terminated
with
2013-08-23 06:31:19 -07:00
bors ea32d019c4 auto merge of #8682 : adridu59/rust/master, r=cmr 2013-08-23 02:46:24 -07:00
Brandon Sanderson 35ec01a3f7 Clarify use_decl module resolution docs. 2013-08-22 19:32:22 -07:00
Kevin Ballard fe1beac45e Update FFI tutorial to reference `c_str::to_c_str`
The FFI tutorial still incorrectly stated that strings were terminated
with \0 and suggested using `str::as_c_str`.
2013-08-22 17:03:06 -07:00
Adrien Tétar 892e8b8ec1 doc: add range iterators in the for loop section 2013-08-22 15:30:04 +02:00
Niko Matsakis 82a9abbf62 Change type of extern fns from `*u8` to `extern "ABI" fn`
cc #3678
2013-08-21 10:50:37 -04:00
bors c87d798fb0 auto merge of #8585 : jankobler/rust/extract-grammar-01, r=catamorphism
This fixes some errors which extract_grammar.py reports, when called with

python2.7 src/etc/extract_grammar.py <doc/rust.md
2013-08-21 02:22:25 -07:00
Daniel Micay 5f3a637b7c enable tests for the container tutorial 2013-08-20 22:05:46 -04:00
Daniel Micay 7727920ba2 iterator: add a method for reversing a container
this works on any container with a mutable double-ended iterator
2013-08-20 22:05:03 -04:00
Daniel Micay 46fc549fa9 rm obsolete integer to_str{,_radix} free functions 2013-08-20 22:05:03 -04:00
Graydon Hoare ef5d537010 doc: add condition tutorial 2013-08-19 16:48:48 -07:00
Niko Matsakis 0479d946c8 Add externfn macro and correctly label fixed_stack_segments 2013-08-19 07:13:15 -04:00
Jan Kobler c5c4a63aeb insert space
in the rust grammar

to avoid error messages like this:

  Exception: non-alpha apparent keyword: pub"

when using extract_grammar.py:

python2.7 src/etc/extract_grammar.py <doc/rust.md

Signed-off-by: Jan Kobler <eng1@koblersystems.de>
2013-08-18 08:00:23 +02:00
Huon Wilson abe94f9b4d doc: correct spelling in documentation. 2013-08-16 15:41:28 +10:00
Daniel Micay 6a21f22767 update the iterator tutorial 2013-08-15 21:12:34 -04:00
bors 790e6bb397 auto merge of #8490 : huonw/rust/fromiterator-extendable, r=catamorphism
If they are on the trait then it is extremely annoying to use them as
generic parameters to a function, e.g. with the iterator param on the trait
itself, if one was to pass an Extendable<int> to a function that filled it
either from a Range or a Map<VecIterator>, one needs to write something
like:

    fn foo<E: Extendable<int, Range<int>> +
              Extendable<int, Map<&'self int, int, VecIterator<int>>>
          (e: &mut E, ...) { ... }

since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>`
means that `foo` takes 2 type parameters, and the caller has to specify them
(which doesn't work anyway, as they'll mismatch with the iterators used in
`foo` itself).

This patch changes it to:

    fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15 02:56:08 -07:00
bors 3dde8e0f29 auto merge of #8480 : cmr/rust/tutorial, r=metajack 2013-08-14 18:29:09 -07:00
bors e7b572952c auto merge of #8469 : gifnksm/rust/tutorial-ja, r=graydon
This PR adds an Japanese translated version of `doc/tutorial.md`.
Other tutorials have not yet translated.
2013-08-14 13:05:22 -07:00
Huon Wilson 53487a0246 std: Move the iterator param on FromIterator and Extendable to the method.
If they are on the trait then it is extremely annoying to use them as
generic parameters to a function, e.g. with the iterator param on the trait
itself, if one was to pass an Extendable<int> to a function that filled it
either from a Range or a Map<VecIterator>, one needs to write something
like:

    fn foo<E: Extendable<int, Range<int>> +
              Extendable<int, Map<&'self int, int, VecIterator<int>>>
          (e: &mut E, ...) { ... }

since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>`
means that `foo` takes 2 type parameters, and the caller has to specify them
(which doesn't work anyway, as they'll mismatch with the iterators used in
`foo` itself).

This patch changes it to:

    fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15 01:10:45 +10:00
Corey Richardson 93fab48b52 Remove unnecessary return 2013-08-12 20:52:37 -04:00
gifnksm 8e1440c7d4 tutorial: Add Japanese translation 2013-08-13 00:26:49 +09:00
bors 59434a1b8c auto merge of #8429 : catamorphism/rust/rustpkg-docs, r=catamorphism 2013-08-12 08:17:14 -07:00
gifnksm e4cfb1d0f5 doc: Generate .po files for Japanse translations 2013-08-12 22:39:31 +09:00