Commit Graph

30860 Commits

Author SHA1 Message Date
bors
df997e53af auto merge of #15814 : kvark/rust/ast, r=huonw
Makes working with syntax deriving a bit more pleasuring. For instance, once can use local (non-static) strings anywhere inside `TraitDef` now.
2014-07-20 16:01:32 +00:00
bors
8859df7fb5 auto merge of #15803 : omp/rust/master, r=alexcrichton
Fix small typo in guide.
2014-07-20 14:21:32 +00:00
bors
e6b28f9ac3 auto merge of #15797 : brson/rust/taskstab, r=alexcrichton
Summary:

* alloc::rc module stable
* Rc type stable
* Functions relating to weak references experimental
* core::cmp module stable
* PartialEq/Eq/PartialOrd/Ord unstable because trait reform will make them change again
* Equiv experimental because there may be better sol'ns
* lexical_ordering deprecated because it can be done trivially with the Ord trait
* min/max stable
* std::task module stable
* TaskBuilder::stdout/stderr experimental because we aren't certain we want to configure the environment this way
* try_future experimental because Future is experimental
* try unstable because the error type might change
* deschedule/failing unstable

The major thing I did differently than previously-discussed is that I made `try` experimental: there's been discussion that the error type `Box<Any + Send>` is not sufficient.


Per https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-07-16.md.
2014-07-20 12:01:31 +00:00
Steve Klabnik
343a52f6b5 small typo 2014-07-20 04:57:49 -07:00
Jakub Wieczorek
4b9bc2e8f2 Implement new mod import sugar
Implements RFC #168.
2014-07-20 12:40:08 +02:00
bors
4f55b52b1a auto merge of #15785 : treeman/rust/fix-15780, r=alexcrichton
Fix for #15780.
2014-07-20 09:31:29 +00:00
bors
50481f5503 auto merge of #15784 : dotdash/rust/unreach, r=luqmana
`call_visit_glue` is only ever called from trans_intrinsic, and the
block won't be unreachable there. Also, the comment doesn't make sense
anymore. When the code was introduced in 38fee9526a the function was
also responsible for the cleanup glue, which is no longer the case.

While we're at it, also fixed the debug message to output the right
function name.
2014-07-20 07:51:32 +00:00
Piotr Jawniak
20df4ccafe Correctly stringify! types and paths inside macros
Closes #8709
2014-07-20 08:47:14 +02:00
bors
320dbc18d8 auto merge of #15745 : treeman/rust/tutorial-fixup, r=steveklabnik
Simplify example in 5.2 to remove hidden `#[deriving(Show)]`. Traits haven't been introduced yet and now it's easier to just type in the code and expect it to work. Add in some examples for constructing the enum types. Explicitly expose `#![feature(struct_variant)]` in the code to make it more transparent, this bit me when I worked through the tutorial.

Add references in chapter 8 to later chapters describing `Rc`, `Gc` and `Send`. This is a simple fix for #15293.

Simplify vector indexing example in chapter 13 and removed hidden, unnecessary, code. Gave an example usage of the derived `Rand` trait in chapter 17.

Removed references to removed 'extra' crate.
2014-07-20 06:11:32 +00:00
bors
7d0a613d0c auto merge of #15776 : alexcrichton/rust/snapshots, r=huonw 2014-07-20 04:31:33 +00:00
Alex Crichton
707cf47ac8 Register new snapshots 2014-07-19 20:38:00 -07:00
bors
56fafe28ee auto merge of #15767 : pcwalton/rust/lifetime-elision, r=nick29581
This implements RFC 39. Omitted lifetimes in return values will now be
inferred to more useful defaults, and an error is reported if a lifetime
in a return type is omitted and one of the two lifetime elision rules
does not specify what it should be.

This primarily breaks two uncommon code patterns. The first is this:

    unsafe fn get_foo_out_of_thin_air() -> &Foo {
        ...
    }

This should be changed to:

    unsafe fn get_foo_out_of_thin_air() -> &'static Foo {
        ...
    }

The second pattern that needs to be changed is this:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed {
        Owned(format!("hello world"))
    }

Change code like this to:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed<'static> {
        Owned(format!("hello world"))
    }

Closes #15552.

[breaking-change]

r? @nick29581
2014-07-20 02:46:34 +00:00
bors
5e0a597a1a auto merge of #15764 : alexcrichton/rust/issue-15761, r=kballard
This branch of try_send() just forgot to wake up any receiver waiting for data.

Closes #15761
2014-07-20 01:06:36 +00:00
bors
d8652de942 auto merge of #15746 : steveklabnik/rust/docs_random, r=alexcrichton
This is now linked to in the guide, so I want to make sure it's good. This
adds a bit more explanation, and brings usage in line with current good style.
2014-07-19 23:26:37 +00:00
bors
8672a235dd auto merge of #15650 : jakub-/rust/patterns-statics, r=pcwalton
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
2014-07-19 21:46:37 +00:00
Dzmitry Malyshau
a2467b945c Fixed lifetimes on syntax deriving structs, implemented Clone 2014-07-19 17:33:17 -04:00
Patrick Walton
6f99a27886 librustc: Implement lifetime elision.
This implements RFC 39. Omitted lifetimes in return values will now be
inferred to more useful defaults, and an error is reported if a lifetime
in a return type is omitted and one of the two lifetime elision rules
does not specify what it should be.

This primarily breaks two uncommon code patterns. The first is this:

    unsafe fn get_foo_out_of_thin_air() -> &Foo {
        ...
    }

This should be changed to:

    unsafe fn get_foo_out_of_thin_air() -> &'static Foo {
        ...
    }

The second pattern that needs to be changed is this:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed {
        Owned(format!("hello world"))
    }

Change code like this to:

    enum MaybeBorrowed<'a> {
        Borrowed(&'a str),
        Owned(String),
    }

    fn foo() -> MaybeBorrowed<'static> {
        Owned(format!("hello world"))
    }

Closes #15552.

[breaking-change]
2014-07-19 13:10:58 -07:00
bors
ab610226aa auto merge of #15782 : steveklabnik/rust/string_guide_link, r=cmr
Three small changes:

1. Re-organize headers in the Strings guide so they show up correctly.
2. build the strings guide with the other docs
3. include the strings guide in the list of guides
2014-07-19 18:36:37 +00:00
bors
793b1424ac auto merge of #15772 : treeman/rust/hashset-doc, r=alexcrichton
Example how to use the set with a custom type. Fill in examples for the missing methods. Also group implemented traits below `HashSet` method impl.
2014-07-19 16:01:43 +00: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
bors
ca38434829 auto merge of #15638 : blake2-ppc/rust/ptr-arithmetic-chars, r=huonw
Reimplement the string slice's `Iterator<char>` by wrapping the already efficient
slice iterator.

The iterator uses our guarantee that the string contains valid UTF-8, but its only unsafe
code is transmuting the decoded `u32` into `char`.

Benchmarks suggest that the runtime of `Chars` benchmarks are reduced by up to 30%,
runtime of `Chars` reversed reduced by up to 60%.

```
BEFORE
test str::bench::char_indicesator                          ... bench:       124 ns/iter (+/- 1)
test str::bench::char_indicesator_rev                      ... bench:       188 ns/iter (+/- 9)
test str::bench::char_iterator                             ... bench:       122 ns/iter (+/- 2)
test str::bench::char_iterator_ascii                       ... bench:       302 ns/iter (+/- 41)
test str::bench::char_iterator_for                         ... bench:       123 ns/iter (+/- 4)
test str::bench::char_iterator_rev                         ... bench:       189 ns/iter (+/- 14)
test str::bench::char_iterator_rev_for                     ... bench:       177 ns/iter (+/- 4)

AFTER
test str::bench::char_indicesator                          ... bench:        85 ns/iter (+/- 3)
test str::bench::char_indicesator_rev                      ... bench:        82 ns/iter (+/- 2)
test str::bench::char_iterator                             ... bench:       100 ns/iter (+/- 3)
test str::bench::char_iterator_ascii                       ... bench:       317 ns/iter (+/- 3)
test str::bench::char_iterator_for                         ... bench:        86 ns/iter (+/- 2)
test str::bench::char_iterator_rev                         ... bench:        80 ns/iter (+/- 6)
test str::bench::char_iterator_rev_for                     ... bench:        68 ns/iter (+/- 0)
```

Note: Branch name is no longer indicative of the implementation.
2014-07-19 14:06:39 +00:00
root
c5e0736c24 Simplify str CharOffsets iterator
Only one uint is needed to keep track of the offset from the original
full string.
2014-07-19 15:39:02 +02:00
bors
e0a6e2b414 auto merge of #15765 : luqmana/rust/iec, r=pcwalton
Fixes #15400.
2014-07-19 12:26:39 +00:00
Jonas Hietala
41729b83bc Document some trait methods. 2014-07-19 12:26:18 +02:00
bors
f05a2c97b8 auto merge of #15754 : jakub-/rust/diagnostics, r=alexcrichton 2014-07-19 08:51:34 +00:00
bors
fb4c3f0af2 auto merge of #15752 : nham/rust/dlist_docs, r=alexcrichton
Someone rightfully complained in IRC that DList was lacking examples. Here are some.
2014-07-19 07:11:33 +00:00
David Vazgenovich Shakaryan
69127f2f4e Fix typo. 2014-07-18 23:11:25 -07:00
bors
44a71dee37 auto merge of #15686 : alexcrichton/rust/same-crate-name, r=kballard
The first is to require that `#[crate_name]` and `--crate-name` always match (if both are specified). The second is to fix parallel compilation in cargo by mixing in `-C extra-filename` into the temporary outputs of the compiler.
2014-07-19 03:11:34 +00:00
Brian Anderson
0b946f0a90 std: Stabilize task module.
Most stable. deschedule/failing experimental because of concerns about
naming and desirability.

Adds task::name() to replace deprecated task::with_name().
2014-07-18 18:34:38 -07:00
Brian Anderson
cf8bfde9d3 alloc: Stabilize rc module.
Weak pointers experimental. Most everything else stable.
2014-07-18 18:34:38 -07:00
Brian Anderson
71f3d8fc1f std: Stabilize default
All stable.
2014-07-18 18:34:35 -07:00
Steve Klabnik
c8b8444ce1 Improve documentation for rand::random
This is now linked to in the guide, so I want to make sure it's good. This
adds a bit more explanation, and brings usage in line with current good style.
2014-07-18 21:19:51 -04:00
Alex Crichton
82fb85a152 rustc: Mix extra-filename in temp outputs
When invoking the compiler in parallel, the intermediate output of the object
files and bytecode can stomp over one another if two crates with the same name
are being compiled.

The output file is already being disambiguated with `-C extra-filename`, so this
commit alters the naming of the temporary files to also mix in the extra
filename to ensure that file names don't clash.
2014-07-18 18:09:08 -07:00
Jakub Wieczorek
fba1194841 Add support for patterns referencing non-trivial statics
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
2014-07-19 01:09:22 +02:00
Brian Anderson
a57e2a7f4d core: Stabliize core::cmp
Mark Eq, PartialEq, Ord, PartialOrd as unstable: they will change
slightly after trait reform. Equiv as experimental: better solutions
are desired. min/max stable.
2014-07-18 15:59:54 -07:00
root
4592164869 Write multibyte case for str Chars iterator in-line
Thanks to comments from @alexcrichton, write the next/next_back function
bodies without nested functions in a more top-to-bottom flow style.

Also improve comment style and motivate the unsafe blocks with comments.
2014-07-19 00:28:45 +02:00
root
bbb299ad98 Clarify str Chars iterator implementation
Thanks to comments from @huonw, clarify decoding details and use
statics for important constants for UTF-8 decoding. Convert some magic
numbers scattered in the same file to use the statics too.
2014-07-19 00:28:45 +02:00
bors
ef352faea8 auto merge of #15743 : Ryman/rust/mandelbrot_fix, r=alexcrichton
Matches the official sample output (N=200) again.

cc #15408
2014-07-18 21:46:32 +00:00
Björn Steinbrink
d368ffdb26 Remove the unneeded final parameter from call_visit_glue
call_visit_glue() is only ever called with None as its last argument, so
we can remove it as well.
2014-07-18 21:56:36 +02:00
Luqman Aden
61ded48fbc Ignore one test. 2014-07-18 11:58:45 -07:00
Luqman Aden
ad27e2625a librustc: Set enum discriminant only after field translation. 2014-07-18 11:58:45 -07:00
Luqman Aden
27748b09d8 librustc: Only emit constructor functions as necessary. 2014-07-18 11:58:45 -07:00
Luqman Aden
06bf73a646 librustc: Emit tuple struct constructor at callsite instead of via a call to a function. 2014-07-18 11:46:03 -07:00
Luqman Aden
cb404dd4fb librustc: Emit enum variant constructor at callsite instead of via a call to a function. 2014-07-18 11:46:03 -07:00
Jonas Hietala
820a55857a Special case for 0 arguments given in format! 2014-07-18 20:39:38 +02:00
bors
7502b4cd6b auto merge of #15742 : pnkfelix/rust/fsk-fix-15019, r=pcwalton
Removed `index_to_bitset` field and `_frozen` methods.

Drive-by: Added some missing docs on the `each_bit` method.

Drive-by: Put in a regular pattern: when calling `compute_id_range`, ensure `words_per_id > 0` by either asserting it or checking and returning early.  (The prior code did the latter in a few cases where necessary, but debugging is much aided by the asserts.)

Fix #15019.
2014-07-18 18:26:34 +00:00
Jakub Wieczorek
5274e997ab Assign more diagnostic codes 2014-07-18 20:13:19 +02:00
Jonas Hietala
18717fcf68 Correct plural of arguments in format_args! 2014-07-18 19:25:46 +02:00
bors
9c9bdfd1c5 auto merge of #14539 : pcwalton/rust/unboxed-closures, r=pnkfelix
@nikomatsakis r?
2014-07-18 16:46:33 +00:00
Björn Steinbrink
33a4dd824f Remove outdated unreachable check from call_visit_glue
`call_visit_glue` is only ever called from trans_intrinsic, and the
block won't be unreachable there. Also, the comment doesn't make sense
anymore. When the code was introduced in 38fee9526a the function was
also responsible for the cleanup glue, which is no longer the case.

While we're at it, also fixed the debug message to output the right
function name.
2014-07-18 18:16:18 +02:00