Commit Graph

40862 Commits

Author SHA1 Message Date
Andrew Paseltiner
644a75ecd1 Fix borrow docs 2015-04-09 12:51:19 -04:00
bors
e326aa197b Auto merge of #24176 - kballard:bufreader-seek-impl, r=aturon 2015-04-09 12:07:24 +00:00
bors
e57410cd92 Auto merge of #24171 - rillian:rustup, r=brson
The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

```
export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib
```
Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.
2015-04-09 07:49:26 +00:00
bors
0e5e669272 Auto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alexcrichton
We only implemented Clone on `extern "Rust" fn`s (for up to 8
parameters). This didn't cover `extern "C"` or `unsafe` (or
`unsafe extern "C"`) `fn`s, but there's no reason why they shouldn't be
cloneable as well.

The new impls are marked unstable because the existing impl for `extern
"Rust" fn`s is.

Fixes #24161.
2015-04-09 04:56:23 +00:00
Kevin Ballard
16052053ac Implement io::Seek for io::BufWriter<W> where W: io::Seek
Seeking the `BufWriter` writes out its internal buffer before seeking.
2015-04-08 21:25:59 -07:00
Kevin Ballard
0a380a9318 Implement io::Seek for io::BufReader<R> where R: io::Seek
Seeking the `BufReader` discards the internal buffer (and adjusts the
offset appropriately when seeking with `SeekFrom::Current(_)`).
2015-04-08 21:25:58 -07:00
bors
287a544a30 Auto merge of #24158 - sanxiyn:cast, r=nrc
Fix #13993.
Fix #17167.
2015-04-09 01:00:37 +00:00
bors
6436e348e9 Auto merge of #24144 - richo:ptr-formatter, r=alexcrichton
~~I believe this should fix the issue. Opening a PR to ensure noone duplicates effort, I'm running check now.~~

Closes #24091
2015-04-08 22:08:31 +00:00
bors
ff804778c8 Auto merge of #24029 - nagisa:print-locking, r=alexcrichton
write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

I’m not sure whether we want to do this change, though, because it has the same deadlock hazard which we tried to avoid by not locking inside write_fmt itself (see [this comment](80def6c244/src/libstd/io/stdio.rs (L267))).

Spotted on [reddit].

cc @alexcrichton 

[reddit]: http://www.reddit.com/r/rust/comments/31comh/println_with_multiple_threads/
2015-04-08 19:03:09 +00:00
Simonas Kazlauskas
45aa6c8d1b Implement reentrant mutexes and make stdio use them
write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides
write_fmt to lock the stdio handle for the whole duration of the call.
2015-04-08 19:42:16 +03:00
bors
30e7e6e8b0 Auto merge of #24195 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24143, #24149, #24167, #24178
- Failed merges:
2015-04-08 15:59:10 +00:00
Steve Klabnik
12e9d7ced0 Rollup merge of #24178 - steveklabnik:new_toc, r=nikomatsakis
Basically, the overall structure is this:

* Getting Started - getting an environment up and running
* Learn Rust - project-based learning the basics
* Effective Rust - higher level concepts that lead to writing good rust
* Syntax and Semantics - chunks of exactly what it sounds like
* Nightly Rust - unstable stuff, a staging area for documenting features
* Glossary - self-explanatory

There's a number of weaknesses with the current TOC, but I'll just focus on the strengths of the new one:

We start off with getting our environment set up. That's "getting started".

Then, we basically present you with two choices: do you want to start small, with bits of syntax? Or do you want to dive in with projects?

I'm guessing more people will choose the second, so that's the next part: "Learn Rust." I don't have any chapters here, but this would have an updated guessing game, a tutorial on building a little `wc` clone, and something else I haven't decided yet. Lots of options. But the idea is to just dive in and get your hands dirty. I'll heavily link to the 'syntax and semantics' sections that are relevant.

Then, a section I'm calling 'Effective Rust'. it feels greedy to steal that title, so I'm hoping to give it another name. These are higher-level things than syntax that Rust programmers should know: error handling is a great example. Most of these are sort of 'how do I use the standard library together' kinds of things. This also contains informations about systems programming that those new to it might not know: the stack vs the heap, for example.

Then, "Syntax and Semantics." This has one section for each bit of Rust. Small, focused, but explains _everything_. These are positioned to be almost entirely in-order, but heavily cross-link, so you can go out of order if you want to, but you can also use it as a reference.

Next, "Nightly Rust," where documenting unstable things goes. If we want to get good feedback on new features, they'll need to be documented, but we don't want to taint the main docs, so that's what this is for.

Finally, the glossary. Straightforward enough.

--------------------------------

This is going to be a terrible PR to review, so I just did the TOC re-organization, with basically no editing. So it'll be a bit jumbled at first. But next steps are to go through and edit / revise / tweak / add stuff to get it in tip-top shape for 1.0!
2015-04-08 11:34:12 -04:00
Steve Klabnik
91798a89e5 Rollup merge of #24167 - hauleth:remove-incorrect-example-from-mpsc, r=steveklabnik
As beta is now released and is "suggested" version of `rustc` then there should be no code (in documentation) that will not compile with it. This one does not.

So according to [this great talk](http://delete-your-code.herokuapp.com/), I am doing what should be done.
2015-04-08 11:34:12 -04:00
Steve Klabnik
4cef7f296f Rollup merge of #24149 - bombless:update-faq, r=steveklabnik
I think "let is used to introduce variables" is incorrent.
You can use
```rust
match (42, true) {
    (x, y) => { /* ... */ }
}
```
to replace
```rust
let x = 42;
let y = true;
```
so it's nothing special for `let`.
2015-04-08 11:34:12 -04:00
Steve Klabnik
ac3cc6c427 Rollup merge of #24143 - michaelsproul:extended-errors, r=pnkfelix
I've taken another look at extended errors - fixing up the printing and adding a few more for match expressions.

With regards to printing, the previous behaviour was to just print the error message string directly, despite it containing indentation which caused it to overflow the standard terminal width of 80 columns (try `rustc --explain E0004`). The first approach I considered was to strip the leading whitespace from each line and lay out the text dynamically, inserting spaces in between. This approach became quite messy when taking multi-paragraph errors into account (and seemed overkill). The approach I settled on removes the indentation in the string itself and begins each message with a newline that is stripped before printing.

I feel like complete extended errors would be nice to have for 1.0.0 and I'm happy to spearhead an effort to get them written. Brian got me onto writing them at an SF meetup and I think it shouldn't be too hard to get the remaining 80 or so written with the help of people who don't really work on compiler innards.
2015-04-08 11:34:11 -04:00
bors
9266d599f4 Auto merge of #24021 - pnkfelix:fn-params-outlive-body, r=nikomatsakis
Encode more precise scoping rules for function params

Function params outlive everything in the body (incl temporaries).  Thus if we assign them their own `CodeExtent`, the region inference can properly show that it is sound to have temporaries with destructors that reference the parameters (because such temporaries will be dropped before the parameters are dropped).

Fix #23338
2015-04-08 12:57:58 +00:00
Felix S. Klock II
86c5faf42b Address review nit by making map_id take an FnMut. 2015-04-08 13:55:01 +02:00
bors
926f38e588 Auto merge of #23998 - nrc:impl-self, r=nikomatsakis
Closes #23909

r? @nikomatsakis (or anyone else, really)
2015-04-08 09:58:05 +00:00
bors
3a66c7f626 Auto merge of #24120 - aturon:range-perf, r=alexcrichton
A recent change to the implementation of range iterators meant that,
even when stepping by 1, the iterators *always* involved checked
arithmetic.

This commit reverts to the earlier behavior (while retaining the
refactoring into traits).

Fixes #24095
Closes #24119
cc #24014 

r? @alexcrichton
2015-04-08 07:02:06 +00:00
Seo Sanghyeon
e2ff1881b2 Address review comments 2015-04-08 15:02:12 +09:00
Richo Healey
a329a61b9b alloc: impl fmt::Pointer for Rc, Arc and Box
Closes #24091
2015-04-07 22:50:36 -07:00
bors
ce97c197c2 Auto merge of #24078 - whipsch:extra-token-msg, r=huonw
Addresses issue #22425.  See `src/test/compile-fail/macro-incomplete-parse.rs` for a relevant test:

    macro-incomplete-parse.rs:15:9: 15:10 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:15         , //~ ERROR macro expansion ignores token `,`
                                         ^
    macro-incomplete-parse.rs:27:1: 27:17 note: caused by the macro expansion here; the usage of `ignored_item` is likely invalid in this context
    macro-incomplete-parse.rs:27 ignored_item!();
                                 ^~~~~~~~~~~~~~~~
    macro-incomplete-parse.rs:20:14: 20:15 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:20     () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
                                              ^
    macro-incomplete-parse.rs:30:5: 30:21 note: caused by the macro expansion here; the usage of `ignored_expr` is likely invalid in this context
    macro-incomplete-parse.rs:30     ignored_expr!();
                                     ^~~~~~~~~~~~~~~~
    macro-incomplete-parse.rs:24:14: 24:15 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:24     () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
                                              ^
    macro-incomplete-parse.rs:32:9: 32:23 note: caused by the macro expansion here; the usage of `ignored_pat` is likely invalid in this context
    macro-incomplete-parse.rs:32         ignored_pat!() => (),
                                         ^~~~~~~~~~~~~~

This does not address the case of improper expansion inside of an impl { } as seen in issue #21607.


I'm not sure if the note text is ideal, but it can be refined if needed.
2015-04-08 04:10:12 +00:00
York Xiang
c9454b1a02 Update "let is used to introduce variables" paragraph 2015-04-08 10:29:11 +08:00
Steve Klabnik
0027253f18 Import real content. 2015-04-07 22:16:02 -04:00
bors
dd6c4a8f15 Auto merge of #23293 - tbu-:pr_additive_multiplicative, r=alexcrichton
Previously it could not be implemented for types outside `libcore/iter.rs` due
to coherence issues.
2015-04-08 00:42:10 +00:00
Steve Klabnik
f354c8a580 New TOC 2015-04-07 19:44:49 -04:00
Aaron Turon
dddcbcfeac Fix range performance regression
A recent change to the implementation of range iterators meant that,
even when stepping by 1, the iterators *always* involved checked
arithmetic.

This commit reverts to the earlier behavior (while retaining the
refactoring into traits).

Fixes #24095
cc #24014
2015-04-07 16:20:55 -07:00
Tobias Bucher
97f24a8596 Make sum and product inherent methods on Iterator
In addition to being nicer, this also allows you to use `sum` and `product` for
iterators yielding custom types aside from the standard integers.

Due to removing the `AdditiveIterator` and `MultiplicativeIterator` trait, this
is a breaking change.

[breaking-change]
2015-04-08 00:26:35 +02:00
Ralph Giles
9a51c63a2f rustup: let RUSTUP_PREFIX env override default prefix.
The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib

Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.
2015-04-07 14:05:02 -07:00
bors
d9146bf8ba Auto merge of #24169 - Manishearth:rollup, r=Manishearth
- Successful merges: #24132, #24139, #24147, #24148, #24150, #24166
- Failed merges:
2015-04-07 19:49:59 +00:00
Manish Goregaokar
4e067f5273 Rollup merge of #24166 - lgvz:email, r=steveklabnik 2015-04-08 01:19:38 +05:30
Manish Goregaokar
c4bd1c2bb2 Rollup merge of #24150 - wg:master, r=alexcrichton
This fix allows the gdb debuginfo tests to pass on FreeBSD when using the newer 7.8 package.
2015-04-08 01:19:38 +05:30
Manish Goregaokar
fe2cff74f4 Rollup merge of #24148 - xfq:patch-2, r=steveklabnik
People use programming language *implementations* like Ruby MRI, CPython, and SpiderMonkey for executing programs.
2015-04-08 01:19:38 +05:30
Manish Goregaokar
2b34643638 Rollup merge of #24147 - lstat:needstest-22560, r=alexcrichton
Closes #22560
2015-04-08 01:19:38 +05:30
Manish Goregaokar
6295406d9f Rollup merge of #24139 - xfq:patch-1, r=steveklabnik
Use HTTPS where possible to avoid plaintext HTTP connections.
2015-04-08 01:19:37 +05:30
Manish Goregaokar
7b2e11844a Rollup merge of #24132 - kwantam:master, r=alexcrichton
@mahkoh points out in #15628 that unicode.py does not use
normative data for Grapheme classes. This pr fixes that issue,
and does some minor cleanup of the unicode.py script.

In addition, GC_RegionalIndicator is renamed GC_Regional_Indicator
in order to stay in line with the Unicode class name definitions.
I have updated refs in u_str.rs, and verified that there are no
refs elsewhere in the codebase. However, in principle someone
using the unicode tables for their own purposes might see breakage
from this.
2015-04-08 01:19:37 +05:30
Łukasz Niemier
4695bf0705 Remove another invalid example 2015-04-07 21:46:14 +02:00
Kevin Ballard
df95719391 Add Clone impls for extern "C" and unsafe fns
We only implemented Clone on `extern "Rust" fn`s (for up to 8
parameters). This didn't cover `extern "C"` or `unsafe` (or `unsafe
extern "C"`) `fn`s, but there's no reason why they shouldn't be
cloneable as well.

The new impls are marked unstable because the existing impl for `extern
"Rust" fn`s is.

Fixes #24161.
2015-04-07 12:39:25 -07:00
Łukasz Niemier
4cf59304c1 Remove incorrect example from docs 2015-04-07 20:35:54 +02:00
Tero Hänninen
f728e39572 Change my email 2015-04-07 21:21:46 +03:00
Michael Sproul
039a553998 Add more extended error messages for match exprs. 2015-04-07 11:16:32 -07:00
bors
1fd89b625b Auto merge of #24156 - Manishearth:rollup, r=Manishearth 2015-04-07 16:44:11 +00:00
Manish Goregaokar
ae64d8e415 doc ignore (fixup #24059) 2015-04-07 22:10:55 +05:30
Seo Sanghyeon
d18b405faf Check casts from fat pointer 2015-04-08 00:45:57 +09:00
Seo Sanghyeon
f4c2228be0 Check casts from float 2015-04-07 22:49:43 +09:00
Manish Goregaokar
b3bcbb1a22 Rollup merge of #24113 - mbrubeck:doc-edit, r=steveklabnik
* Fix broken \"module-level documentation\" link on the [`trait Any` docs](http://doc.rust-lang.org/std/any/trait.Any.html) and related broken markup on the [`std::any` docs](http://doc.rust-lang.org/std/any/index.html).

* Remove an outdated or incorrect notice in the `BufRead::lines` docs. There is no such `read_string` function, and `lines` never returns an error.

r? @steveklabnik
2015-04-07 18:13:24 +05:30
Manish Goregaokar
322e4a18e3 Rollup merge of #24112 - joshtriplett:patch-1, r=steveklabnik
traits.md said:

If we add a `use` line right above `main` and make the right things public,
everything is fine:

However, the use line was actually placed at the top of the file instead.  Move
the use line to right above main.  That also makes the example more evocative
of cases where the module is defined in a separate file.
2015-04-07 18:13:12 +05:30
Manish Goregaokar
6efb8352e8 Rollup merge of #24110 - tbu-:pr_doc_fix_add, r=alexcrichton 2015-04-07 18:13:04 +05:30
Manish Goregaokar
50cb31f0e7 Rollup merge of #24088 - GuillaumeGomez:patch-1, r=alexcrichton
Fixes #24060.
2015-04-07 18:12:55 +05:30
Manish Goregaokar
6f852f5620 Rollup merge of #24059 - nikomatsakis:issue-22914-phantomdata-docs, r=huon
This probably needs a bit more work, but I wanted to try and capture some common use cases and be a bit more helpful.

r? @huonw
cc @steveklabnik
2015-04-07 18:12:47 +05:30