]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoauto merge of #15806 : treeman/rust/std-doc, r=alexcrichton
bors [Sun, 20 Jul 2014 17:46:32 +0000 (17:46 +0000)]
auto merge of #15806 : treeman/rust/std-doc, r=alexcrichton

Used `HashMap` and `HashSet` as the base of most examples. Could change it up with different containers, but I don't think it's a big deal.

9 years agoauto merge of #15814 : kvark/rust/ast, r=huonw
bors [Sun, 20 Jul 2014 16:01:32 +0000 (16:01 +0000)]
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.

9 years agoauto merge of #15803 : omp/rust/master, r=alexcrichton
bors [Sun, 20 Jul 2014 14:21:32 +0000 (14:21 +0000)]
auto merge of #15803 : omp/rust/master, r=alexcrichton

Fix small typo in guide.

9 years agoauto merge of #15797 : brson/rust/taskstab, r=alexcrichton
bors [Sun, 20 Jul 2014 12:01:31 +0000 (12:01 +0000)]
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.

9 years agosmall typo
Steve Klabnik [Sun, 20 Jul 2014 11:57:49 +0000 (04:57 -0700)]
small typo

9 years agoauto merge of #15785 : treeman/rust/fix-15780, r=alexcrichton
bors [Sun, 20 Jul 2014 09:31:29 +0000 (09:31 +0000)]
auto merge of #15785 : treeman/rust/fix-15780, r=alexcrichton

Fix for #15780.

9 years agoauto merge of #15784 : dotdash/rust/unreach, r=luqmana
bors [Sun, 20 Jul 2014 07:51:32 +0000 (07:51 +0000)]
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.

9 years agoauto merge of #15745 : treeman/rust/tutorial-fixup, r=steveklabnik
bors [Sun, 20 Jul 2014 06:11:32 +0000 (06:11 +0000)]
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.

9 years agoauto merge of #15776 : alexcrichton/rust/snapshots, r=huonw
bors [Sun, 20 Jul 2014 04:31:33 +0000 (04:31 +0000)]
auto merge of #15776 : alexcrichton/rust/snapshots, r=huonw

9 years agoRegister new snapshots
Alex Crichton [Wed, 16 Jul 2014 17:28:42 +0000 (10:28 -0700)]
Register new snapshots

9 years agoauto merge of #15767 : pcwalton/rust/lifetime-elision, r=nick29581
bors [Sun, 20 Jul 2014 02:46:34 +0000 (02:46 +0000)]
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

9 years agoauto merge of #15764 : alexcrichton/rust/issue-15761, r=kballard
bors [Sun, 20 Jul 2014 01:06:36 +0000 (01:06 +0000)]
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

9 years agoauto merge of #15746 : steveklabnik/rust/docs_random, r=alexcrichton
bors [Sat, 19 Jul 2014 23:26:37 +0000 (23:26 +0000)]
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.

9 years agoauto merge of #15650 : jakub-/rust/patterns-statics, r=pcwalton
bors [Sat, 19 Jul 2014 21:46:37 +0000 (21:46 +0000)]
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.

9 years agoFixed lifetimes on syntax deriving structs, implemented Clone
Dzmitry Malyshau [Sat, 19 Jul 2014 21:33:17 +0000 (17:33 -0400)]
Fixed lifetimes on syntax deriving structs, implemented Clone

9 years agolibrustc: Implement lifetime elision.
Patrick Walton [Fri, 18 Jul 2014 04:44:59 +0000 (21:44 -0700)]
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]

9 years agoauto merge of #15782 : steveklabnik/rust/string_guide_link, r=cmr
bors [Sat, 19 Jul 2014 18:36:37 +0000 (18:36 +0000)]
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

9 years agoauto merge of #15772 : treeman/rust/hashset-doc, r=alexcrichton
bors [Sat, 19 Jul 2014 16:01:43 +0000 (16:01 +0000)]
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.

9 years agoauto merge of #15638 : blake2-ppc/rust/ptr-arithmetic-chars, r=huonw
bors [Sat, 19 Jul 2014 14:06:39 +0000 (14:06 +0000)]
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.

9 years agoSimplify str CharOffsets iterator
root [Sat, 19 Jul 2014 13:39:02 +0000 (15:39 +0200)]
Simplify str CharOffsets iterator

Only one uint is needed to keep track of the offset from the original
full string.

9 years agoauto merge of #15765 : luqmana/rust/iec, r=pcwalton
bors [Sat, 19 Jul 2014 12:26:39 +0000 (12:26 +0000)]
auto merge of #15765 : luqmana/rust/iec, r=pcwalton

Fixes #15400.

9 years agoDocument some trait methods.
Jonas Hietala [Sat, 19 Jul 2014 10:10:09 +0000 (12:10 +0200)]
Document some trait methods.

9 years agoauto merge of #15754 : jakub-/rust/diagnostics, r=alexcrichton
bors [Sat, 19 Jul 2014 08:51:34 +0000 (08:51 +0000)]
auto merge of #15754 : jakub-/rust/diagnostics, r=alexcrichton

9 years agoauto merge of #15752 : nham/rust/dlist_docs, r=alexcrichton
bors [Sat, 19 Jul 2014 07:11:33 +0000 (07:11 +0000)]
auto merge of #15752 : nham/rust/dlist_docs, r=alexcrichton

Someone rightfully complained in IRC that DList was lacking examples. Here are some.

9 years agoFix typo.
David Vazgenovich Shakaryan [Sat, 19 Jul 2014 06:11:25 +0000 (23:11 -0700)]
Fix typo.

9 years agoauto merge of #15686 : alexcrichton/rust/same-crate-name, r=kballard
bors [Sat, 19 Jul 2014 03:11:34 +0000 (03:11 +0000)]
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.

9 years agostd: Stabilize task module.
Brian Anderson [Fri, 18 Jul 2014 23:02:39 +0000 (16:02 -0700)]
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().

9 years agoalloc: Stabilize rc module.
Brian Anderson [Fri, 18 Jul 2014 23:02:14 +0000 (16:02 -0700)]
alloc: Stabilize rc module.

Weak pointers experimental. Most everything else stable.

9 years agostd: Stabilize default
Brian Anderson [Fri, 18 Jul 2014 23:01:55 +0000 (16:01 -0700)]
std: Stabilize default

All stable.

9 years agoImprove documentation for rand::random
Steve Klabnik [Thu, 17 Jul 2014 15:59:45 +0000 (11:59 -0400)]
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.

9 years agorustc: Mix extra-filename in temp outputs
Alex Crichton [Tue, 15 Jul 2014 16:13:58 +0000 (09:13 -0700)]
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.

9 years agoAdd support for patterns referencing non-trivial statics
Jakub Wieczorek [Sun, 13 Jul 2014 13:12:47 +0000 (15:12 +0200)]
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.

9 years agocore: Stabliize core::cmp
Brian Anderson [Fri, 18 Jul 2014 22:59:54 +0000 (15:59 -0700)]
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.

9 years agoWrite multibyte case for str Chars iterator in-line
root [Fri, 18 Jul 2014 22:02:30 +0000 (00:02 +0200)]
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.

9 years agoClarify str Chars iterator implementation
root [Thu, 17 Jul 2014 22:59:49 +0000 (00:59 +0200)]
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.

9 years agoauto merge of #15743 : Ryman/rust/mandelbrot_fix, r=alexcrichton
bors [Fri, 18 Jul 2014 21:46:32 +0000 (21:46 +0000)]
auto merge of #15743 : Ryman/rust/mandelbrot_fix, r=alexcrichton

Matches the official sample output (N=200) again.

cc #15408

9 years agoRemove the unneeded final parameter from call_visit_glue
Björn Steinbrink [Fri, 18 Jul 2014 19:56:36 +0000 (21:56 +0200)]
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.

9 years agoIgnore one test.
Luqman Aden [Fri, 18 Jul 2014 00:17:27 +0000 (17:17 -0700)]
Ignore one test.

9 years agolibrustc: Set enum discriminant only after field translation.
Luqman Aden [Thu, 10 Jul 2014 22:09:21 +0000 (15:09 -0700)]
librustc: Set enum discriminant only after field translation.

9 years agolibrustc: Only emit constructor functions as necessary.
Luqman Aden [Thu, 10 Jul 2014 17:59:52 +0000 (10:59 -0700)]
librustc: Only emit constructor functions as necessary.

9 years agolibrustc: Emit tuple struct constructor at callsite instead of via a call to a function.
Luqman Aden [Thu, 10 Jul 2014 07:20:28 +0000 (00:20 -0700)]
librustc: Emit tuple struct constructor at callsite instead of via a call to a function.

9 years agolibrustc: Emit enum variant constructor at callsite instead of via a call to a function.
Luqman Aden [Thu, 10 Jul 2014 06:42:08 +0000 (23:42 -0700)]
librustc: Emit enum variant constructor at callsite instead of via a call to a function.

9 years agoSpecial case for 0 arguments given in format!
Jonas Hietala [Fri, 18 Jul 2014 18:39:38 +0000 (20:39 +0200)]
Special case for 0 arguments given in format!

9 years agoauto merge of #15742 : pnkfelix/rust/fsk-fix-15019, r=pcwalton
bors [Fri, 18 Jul 2014 18:26:34 +0000 (18:26 +0000)]
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.

9 years agoAssign more diagnostic codes
Jakub Wieczorek [Thu, 17 Jul 2014 17:56:37 +0000 (19:56 +0200)]
Assign more diagnostic codes

9 years agoCorrect plural of arguments in format_args!
Jonas Hietala [Fri, 18 Jul 2014 16:34:49 +0000 (18:34 +0200)]
Correct plural of arguments in format_args!

9 years agoauto merge of #14539 : pcwalton/rust/unboxed-closures, r=pnkfelix
bors [Fri, 18 Jul 2014 16:46:33 +0000 (16:46 +0000)]
auto merge of #14539 : pcwalton/rust/unboxed-closures, r=pnkfelix

@nikomatsakis r?

9 years agoRemove outdated unreachable check from `call_visit_glue`
Björn Steinbrink [Sun, 6 Jul 2014 10:02:40 +0000 (12:02 +0200)]
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.

9 years agolibrustc: Implement unboxed closures with mutable receivers
Patrick Walton [Thu, 29 May 2014 05:26:56 +0000 (22:26 -0700)]
librustc: Implement unboxed closures with mutable receivers

9 years agorustc: #[crate_name] and --crate-name must match
Alex Crichton [Tue, 15 Jul 2014 16:13:40 +0000 (09:13 -0700)]
rustc: #[crate_name] and --crate-name must match

Part of the original discussions around the `--crate-name` flag brought up that
mass confusion can arise when the flag specifies a different name than is
contained in the crate.

The current primary use case of the `--crate-name` flag is through cargo and
not requiring a `#[crate_name]` attribute, but if the `#[crate_name]` attribute
is specified it will likely go awry when the two names deviate from one another.
This commit requires that if both are provided they both match to prevent this
confusion.

9 years agoInclude Strings guide with the others.
Steve Klabnik [Fri, 18 Jul 2014 14:48:24 +0000 (10:48 -0400)]
Include Strings guide with the others.

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

9 years agoRemove examples from trait implementations. Unhide imports.
Jonas Hietala [Fri, 18 Jul 2014 14:34:07 +0000 (16:34 +0200)]
Remove examples from trait implementations. Unhide imports.

9 years agoauto merge of #15737 : huonw/rust/lint-level-here, r=pnkfelix
bors [Fri, 18 Jul 2014 13:31:22 +0000 (13:31 +0000)]
auto merge of #15737 : huonw/rust/lint-level-here, r=pnkfelix

This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).

9 years agoFill in documentation for HashSet.
Jonas Hietala [Thu, 17 Jul 2014 18:40:39 +0000 (20:40 +0200)]
Fill in documentation for HashSet.

Example how to use the set with a custom type. Fill in examples for the missing methods.

9 years agoauto merge of #15733 : sanxiyn/rust/use-from-type, r=alexcrichton
bors [Fri, 18 Jul 2014 11:51:20 +0000 (11:51 +0000)]
auto merge of #15733 : sanxiyn/rust/use-from-type, r=alexcrichton

Importing from types was disallowed in #6462. Flag was set for paths whether it is a module or a type. Type flag was set when impl was seen. The problem is, for cross-crate situations, when reexport is involved, it is possible that impl is seen too late because metadata is loaded lazily.

Fix #15664.

9 years agoRemoved the `_frozen` methods from dataflow API.
Felix S. Klock II [Thu, 17 Jul 2014 13:36:38 +0000 (15:36 +0200)]
Removed the `_frozen` methods from dataflow API.

Calls to methods like `each_bit_on_entry_frozen` and
`each_gen_bit_frozen` now go to the `each_bit_on_entry` and
`each_gen_bit` methods.

9 years agoRemoved `index_to_bitset` from the dataflow context.
Felix S. Klock II [Thu, 17 Jul 2014 12:28:03 +0000 (14:28 +0200)]
Removed `index_to_bitset` from the dataflow context.

Part of addressing 15019.

9 years agoauto merge of #15732 : bgamari/rust/to-tokens, r=alexcrichton
bors [Fri, 18 Jul 2014 09:31:22 +0000 (09:31 +0000)]
auto merge of #15732 : bgamari/rust/to-tokens, r=alexcrichton

Here I add a `ToTokens` impl for `Attribute_` and `Option<T>`, as well as generalize the impl for `Vec<T>`

9 years agoauto merge of #15727 : fhahn/rust/remove-some-unwraps, r=alexcrichton
bors [Fri, 18 Jul 2014 07:51:22 +0000 (07:51 +0000)]
auto merge of #15727 : fhahn/rust/remove-some-unwraps, r=alexcrichton

When looking through the `btree` code, I stumbled over a couple of `unwraps` that could be avoided.

9 years agoauto merge of #15726 : aturon/rust/macro-stability, r=alexcrichton
bors [Fri, 18 Jul 2014 06:11:24 +0000 (06:11 +0000)]
auto merge of #15726 : aturon/rust/macro-stability, r=alexcrichton

This small patch causes the stability lint to bail out when traversing
any AST produced via a macro expansion. Ultimately, we would like to
lint the contents of the macro at the place where the macro is defined,
but regardless we should not be linting it at the use site.

Closes #15703

9 years agoauto merge of #15725 : aochagavia/rust/vec, r=alexcrichton
bors [Fri, 18 Jul 2014 03:46:23 +0000 (03:46 +0000)]
auto merge of #15725 : aochagavia/rust/vec, r=alexcrichton

* Deprecated `to_owned` in favor of `to_vec`
* Deprecated `into_owned` in favor of `into_vec`

[breaking-change]

9 years agoAdd examples for DList methods rotate_forward, rotate_backward, append, prepend and...
nham [Thu, 17 Jul 2014 20:46:27 +0000 (16:46 -0400)]
Add examples for DList methods rotate_forward, rotate_backward, append, prepend and insert_when

9 years agoauto merge of #15593 : steveklabnik/rust/string_guide, r=kballard
bors [Fri, 18 Jul 2014 01:46:24 +0000 (01:46 +0000)]
auto merge of #15593 : steveklabnik/rust/string_guide, r=kballard

I decided to change it up a little today and hack out the beginning of the String guide. Strings are different enough in Rust that I think they deserve a specific guide, especially for those who are used to managed languages.

I decided to start with Strings because they get asked about a lot in IRC, and also based on discussions like this one on reddit: http://www.reddit.com/r/rust/comments/2ac390/generic_string_literals/

I blatantly stole bits from our other documentation on Strings. It's a little sparse at current, but I wanted to start somewhere.

I am not exactly sure what should go in "Best Practices," and would like the feedback from the team on this. Specifically due to comments like this one: http://www.reddit.com/r/rust/comments/2ac390/generic_string_literals/citmxb5

9 years agosync: Ensure try_send() wakes up receivers
Alex Crichton [Fri, 18 Jul 2014 00:23:38 +0000 (17:23 -0700)]
sync: Ensure try_send() wakes up receivers

This branch of try_send() just forgot to wake up any receiver waiting for data.

Closes #15761

9 years agoGuide: strings
Steve Klabnik [Thu, 17 Jul 2014 23:24:12 +0000 (19:24 -0400)]
Guide: strings

9 years agoauto merge of #15719 : michaelwoerister/rust/global_var_null_span_fix, r=alexcrichton
bors [Fri, 18 Jul 2014 00:01:22 +0000 (00:01 +0000)]
auto merge of #15719 : michaelwoerister/rust/global_var_null_span_fix, r=alexcrichton

This should fix issue #15541. It would be good to have an test case for this would also be nice but I haven't had the time to write one. The change is very small though and it doesn't break anything in the existing test suite, so I guess we can add it without test for now.

9 years agoAdd more tests for str Chars iterator
root [Thu, 17 Jul 2014 22:59:09 +0000 (00:59 +0200)]
Add more tests for str Chars iterator

Test iterating (decoding) every codepoint.

9 years agoauto merge of #15515 : pcwalton/rust/cross-borrowing, r=alexcrichton
bors [Thu, 17 Jul 2014 22:16:23 +0000 (22:16 +0000)]
auto merge of #15515 : pcwalton/rust/cross-borrowing, r=alexcrichton

except where trait objects are involved.

Part of issue #15349, though I'm leaving it open for trait objects.
Cross borrowing for trait objects remains because it is needed until we
have DST.

This will break code like:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(a);

Change this code to:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(&*a);

[breaking-change]

r? @alexcrichton

9 years agolibrustc: Remove cross-borrowing of `Box<T>` to `&T` from the language,
Patrick Walton [Mon, 7 Jul 2014 23:35:15 +0000 (16:35 -0700)]
librustc: Remove cross-borrowing of `Box<T>` to `&T` from the language,
except where trait objects are involved.

Part of issue #15349, though I'm leaving it open for trait objects.
Cross borrowing for trait objects remains because it is needed until we
have DST.

This will break code like:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(a);

Change this code to:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(&*a);

[breaking-change]

9 years agoauto merge of #15718 : treeman/rust/integer-doc, r=alexcrichton
bors [Thu, 17 Jul 2014 20:36:19 +0000 (20:36 +0000)]
auto merge of #15718 : treeman/rust/integer-doc, r=alexcrichton

Simple usage examples for Integer methods. Also group `div_rem` and `div_mod_floor` together at the bottom of the trait, to reflect the documentation rendering.

9 years agoauto merge of #15716 : treeman/rust/bigint-doc, r=alexcrichton
bors [Thu, 17 Jul 2014 18:56:22 +0000 (18:56 +0000)]
auto merge of #15716 : treeman/rust/bigint-doc, r=alexcrichton

Also use `///` for documentation instead of `/**`. End comments with `.`.

9 years agocore::str: Implement Chars iterator using slice::Items
root [Thu, 17 Jul 2014 17:34:07 +0000 (19:34 +0200)]
core::str: Implement Chars iterator using slice::Items

Re-use the vector iterator to implement the chars 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.

9 years agostr: Add better tests for string slice's Chars iterator
root [Thu, 17 Jul 2014 16:03:34 +0000 (18:03 +0200)]
str: Add better tests for string slice's Chars iterator

Test using for ch s.chars() { black_box(ch) } to have a test that should
force the iterator to run its full decoding computations.

9 years agoauto merge of #15706 : phi-gamma/rust/master, r=huonw
bors [Thu, 17 Jul 2014 17:16:23 +0000 (17:16 +0000)]
auto merge of #15706 : phi-gamma/rust/master, r=huonw

I kept changes to each file in a separate commit. Please let me know if you prefer them
squashed!

9 years agoauto merge of #15705 : klutzy/rust/cross-ld-library, r=alexcrichton
bors [Thu, 17 Jul 2014 15:36:23 +0000 (15:36 +0000)]
auto merge of #15705 : klutzy/rust/cross-ld-library, r=alexcrichton

9 years agoRename functions in the CloneableVector trait
Adolfo Ochagavía [Wed, 16 Jul 2014 20:37:28 +0000 (22:37 +0200)]
Rename functions in the CloneableVector trait

* Deprecated `to_owned` in favor of `to_vec`
* Deprecated `into_owned` in favor of `into_vec`

[breaking-change]

9 years agoSmall fixes for tutorial.
Jonas Hietala [Thu, 17 Jul 2014 14:21:33 +0000 (16:21 +0200)]
Small fixes for tutorial.

5.2 Simplify example to remove hidden #[deriving(Show)].
    Add example for constructing the enums.

8   Reference later sections describing rc, gc and send.
    Fix for #15293.

13  Simplify BananaMania example to remove hidden code.

17  Gave an example using the derived Rand trait.

Removed references to removed 'extra' crate.

9 years agoauto merge of #15675 : errordeveloper/rust/json_docs, r=steveklabnik
bors [Thu, 17 Jul 2014 13:56:19 +0000 (13:56 +0000)]
auto merge of #15675 : errordeveloper/rust/json_docs, r=steveklabnik

- add one simple example of using `ToJson` trait
- make example code more readable

9 years agosyntax: Add ToTokens impl for Method
Ben Gamari [Thu, 17 Jul 2014 12:54:43 +0000 (08:54 -0400)]
syntax: Add ToTokens impl for Method

9 years agoauto merge of #15698 : Zoxc/rust/code-model, r=alexcrichton
bors [Thu, 17 Jul 2014 12:11:19 +0000 (12:11 +0000)]
auto merge of #15698 : Zoxc/rust/code-model, r=alexcrichton

The default code model is usually unsuitable for kernels,
so we add an option to specify which model we want.

Testing for this would be fragile and very architecture specific and is better left to LLVM.

9 years agolint: add method to get level of a specific lint.
Huon Wilson [Thu, 17 Jul 2014 10:07:43 +0000 (20:07 +1000)]
lint: add method to get level of a specific lint.

This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).

9 years agoauto merge of #15668 : steveklabnik/rust/tree_set_example, r=alexcrichton
bors [Thu, 17 Jul 2014 08:01:21 +0000 (08:01 +0000)]
auto merge of #15668 : steveklabnik/rust/tree_set_example, r=alexcrichton

Someone asked for an example usage of this on IRC, so I tossed together the simplest one. Obviously, this isn't up to snuff, but it's better than nothing.

9 years agoauto merge of #14022 : pcwalton/rust/explicit-self, r=pnkfelix
bors [Thu, 17 Jul 2014 06:21:21 +0000 (06:21 +0000)]
auto merge of #14022 : pcwalton/rust/explicit-self, r=pnkfelix

r? @nikomatsakis

9 years agolibrustc: Allow the new UFCS explicit self in trait definitions, and
Patrick Walton [Tue, 8 Jul 2014 06:19:35 +0000 (23:19 -0700)]
librustc: Allow the new UFCS explicit self in trait definitions, and
remove `~self` from the test suite.

9 years agosyntax: Add quote_method!
Ben Gamari [Thu, 17 Jul 2014 05:02:27 +0000 (01:02 -0400)]
syntax: Add quote_method!

9 years agoDisallow importing from types when reexport is involved
Seo Sanghyeon [Thu, 17 Jul 2014 04:50:54 +0000 (13:50 +0900)]
Disallow importing from types when reexport is involved

9 years agolibsyntax: Remove `Send` from `PtrTy` in `deriving`.
Patrick Walton [Tue, 8 Jul 2014 04:52:28 +0000 (21:52 -0700)]
libsyntax: Remove `Send` from `PtrTy` in `deriving`.

It'll be complex to port to the new explicit-self regime and it seems to
be unused.

9 years agolibrustc: Implement the fully-expanded, UFCS form of explicit self.
Patrick Walton [Tue, 6 May 2014 23:37:32 +0000 (16:37 -0700)]
librustc: Implement the fully-expanded, UFCS form of explicit self.

This makes two changes to region inference: (1) it allows region
inference to relate early-bound regions; and (2) it allows regions to be
related before variance runs. The former is needed because there is no
relation between the two regions before region substitution happens,
while the latter is needed because type collection has to run before
variance. We assume that, before variance is inferred, that lifetimes
are invariant. This is a conservative overapproximation.

This relates to #13885. This does not remove `~self` from the language
yet, however.

[breaking-change]

9 years agosyntax: Generalize ToTokens impl for Vec<T>
Ben Gamari [Thu, 17 Jul 2014 02:24:42 +0000 (22:24 -0400)]
syntax: Generalize ToTokens impl for Vec<T>

It will now `flat_map` over the elements of a `Vec<T>` if
`T: ToTokens`

9 years agosyntax: Add ToTokens for Attribute_
Ben Gamari [Thu, 17 Jul 2014 02:17:16 +0000 (22:17 -0400)]
syntax: Add ToTokens for Attribute_

9 years agosyntax: Add ToTokens for Option<T>
Ben Gamari [Thu, 17 Jul 2014 02:16:55 +0000 (22:16 -0400)]
syntax: Add ToTokens for Option<T>

10 years agoauto merge of #15652 : nick29581/rust/vec_index, r=acrichto
bors [Thu, 17 Jul 2014 01:16:19 +0000 (01:16 +0000)]
auto merge of #15652 : nick29581/rust/vec_index, r=acrichto

10 years agodeprecate Vec::get
Nick Cameron [Mon, 14 Jul 2014 23:37:25 +0000 (11:37 +1200)]
deprecate Vec::get

10 years agoAdd TreeSet example.
Steve Klabnik [Wed, 16 Jul 2014 22:11:40 +0000 (18:11 -0400)]
Add TreeSet example.

10 years agoauto merge of #15696 : Zoxc/rust/redzone, r=alexcrichton
bors [Wed, 16 Jul 2014 21:46:21 +0000 (21:46 +0000)]
auto merge of #15696 : Zoxc/rust/redzone, r=alexcrichton

Disabling the redzone is required in x86-64's kernel mode to avoid interrupts trashing the stack.

I'm not sure if decl_fn is the right place to tag all functions with noredzone. It might have interactions with external functions when linking with bitcode built without -C no-redzone although I see no reason to do that.

I'm not sure how to write a test inspecting the bitcode output for noredzone attributes on all functions either.

10 years agobtree: use pattern matching instead of unwrap
Florian Hahn [Wed, 16 Jul 2014 21:22:14 +0000 (23:22 +0200)]
btree: use pattern matching instead of unwrap

10 years agoImplement Index and IndexMut for Vec
Nick Cameron [Sun, 13 Jul 2014 23:03:23 +0000 (11:03 +1200)]
Implement Index and IndexMut for Vec

10 years agostability lint: ignore code from macro expansion
Aaron Turon [Wed, 16 Jul 2014 20:50:33 +0000 (13:50 -0700)]
stability lint: ignore code from macro expansion

This small patch causes the stability lint to bail out when traversing
any AST produced via a macro expansion. Ultimately, we would like to
lint the contents of the macro at the place where the macro is defined,
but regardless we should not be linting it at the use site.

Closes #15703

10 years agoauto merge of #15667 : treeman/rust/set-doc, r=alexcrichton
bors [Wed, 16 Jul 2014 18:56:18 +0000 (18:56 +0000)]
auto merge of #15667 : treeman/rust/set-doc, r=alexcrichton

Example code for HashSet, similar to the [HashMap example](http://doc.rust-lang.org/std/collections/hashmap/struct.HashMap.html).

10 years agoImprove docs on JSON.
Ilya Dmitrichenko [Mon, 14 Jul 2014 21:41:16 +0000 (22:41 +0100)]
Improve docs on JSON.

- add one simple example of using `ToJson` trait
- make example code more readable