Commit Graph

54942 Commits

Author SHA1 Message Date
Guillaume Gomez
9ba1792aac Rollup merge of #34880 - xitep:master, r=steveklabnik
Make .enumerate() example self-explanatory

Should resolve #34624
2016-07-21 11:27:00 +02:00
Guillaume Gomez
705d92d42d Rollup merge of #34855 - GuillaumeGomez:vec_deque_doc, r=steveklabnik
Add examples for VecDeque

Part of #29348.

r? @steveklabnik
2016-07-21 11:26:59 +02:00
Guillaume Gomez
a168e30bb1 Rollup merge of #34854 - GuillaumeGomez:linked_list_doc, r=steveklabnik
Add examples for LinkedList

Part of #29348.

r? @steveklabnik
2016-07-21 11:26:58 +02:00
Guillaume Gomez
bcbe27cbf9 Rollup merge of #34828 - seanmonstar:into-opton, r=alexcrichton
core: impl From<T> for Option<T>

First, the semantics of this `impl` seem spot on. If I have a value `T`, and I wish to make a `Option<T>`, then `Option::from(val)` should always give `Some(val)`.

Second, this allows improvement for several APIs that currently take `Option<T>` as arguments. Consider:

```rust
fn set_read_timeout(&mut self, timeout: Option<u32>) {
    // ...
}

x.set_read_timeout(Some(30));
x.set_read_timeout(Some(10));
x.set_read_timeout(None);
```

With this `impl`:

```rust
fn set_read_timeout<T: Into<Option<u32>>>(&mut self, timeout: T) {
    let timeout = timeout.into();
    // ...
}

x.set_read_timeout(30);
x.set_read_timeout(10);
x.set_read_timeout(Some(10)); // backwards compatible
x.set_read_timeout(None);
```

The change to those methods aren't included, but could be modified later.

r? @sfackler
2016-07-21 11:26:57 +02:00
bors
e7c822cee2 Auto merge of #34873 - alexcrichton:down-with-compiler-rt-for-good, r=brson
mk: Stop using cmake for compiler-rt

The compiler-rt build system has been a never ending cause of pain for Rust
unfortunately:

* The build system is very difficult to invoke and configure to only build
  compiler-rt, especially across platforms.
* The standard build system doesn't actually do what we want, not working for
  some of our platforms and requiring a significant number of patches on our end
  which are difficult to apply when updating compiler-rt.
* Compiling compiler-rt requires LLVM to be compiled, which... is a big
  dependency! This also means that over time compiler-rt is not guaranteed to
  build against older versions of LLVM (or newer versions), and we often want to
  work with multiple versions of LLVM simultaneously.

The makefiles and rustbuild already know how to compile C code, the code here is
far from the *only* C code we're compiling. This patch jettisons all logic to
work with compiler-rt's build system and just goes straight to the source. We
just list all files manually (copied from compiler-rt's
lib/builtins/CMakeLists.txt) and compile them into an archive.

It's likely that this means we'll fail to pick up new files when we upgrade
compiler-rt, but that seems like a much less significant cost to pay than what
we're currently paying.

cc #34400, first steps towards that
2016-07-20 19:02:00 -07:00
Sean McArthur
fbfee42a2f core: impl From<T> for Option<T> 2016-07-20 15:54:54 -07:00
Alex Crichton
ee6011fc71 mk: Stop using cmake for compiler-rt
The compiler-rt build system has been a never ending cause of pain for Rust
unfortunately:

* The build system is very difficult to invoke and configure to only build
  compiler-rt, especially across platforms.
* The standard build system doesn't actually do what we want, not working for
  some of our platforms and requiring a significant number of patches on our end
  which are difficult to apply when updating compiler-rt.
* Compiling compiler-rt requires LLVM to be compiled, which... is a big
  dependency! This also means that over time compiler-rt is not guaranteed to
  build against older versions of LLVM (or newer versions), and we often want to
  work with multiple versions of LLVM simultaneously.

The makefiles and rustbuild already know how to compile C code, the code here is
far from the *only* C code we're compiling. This patch jettisons all logic to
work with compiler-rt's build system and just goes straight to the source. We
just list all files manually (copied from compiler-rt's
lib/builtins/CMakeLists.txt) and compile them into an archive.

It's likely that this means we'll fail to pick up new files when we upgrade
compiler-rt, but that seems like a much less significant cost to pay than what
we're currently paying.

cc #34400, first steps towards that
2016-07-20 13:22:20 -07:00
bors
936bfea94b Auto merge of #34113 - srinivasreddy:deriving_rustfmt, r=brson
run rustfmt on libsyntax_ext/deriving folder
2016-07-20 11:24:12 -07:00
bors
9d5965a5e8 Auto merge of #34694 - mathphreak:master, r=alexcrichton
Add IpAddr common methods

Per https://github.com/rust-lang/rfcs/pull/1668#issuecomment-230867962 no RFC is needed here.

The generated documentation for these methods is being weird. It shows a deprecation message referencing #27709 for each of them even though two of the referenced methods were stabilized as part of that issue. I don't know how best to address that.
2016-07-20 07:10:09 -07:00
bors
a63e3fac8f Auto merge of #33526 - steveklabnik:gh21889, r=alexcrichton
Add some warnings to std::env::current_exe

/cc #21889 @rust-lang/libs @semarie

I started writing this up. I'm not sure if we want to go into other things and in what depth; we don't currently have a lot of security-specific documentation to model after.

Thoughts?
2016-07-20 00:48:21 -07:00
bors
48c245411b Auto merge of #34885 - GuillaumeGomez:btree_map_debug, r=alexcrichton
Add debug for btree_map::{Entry, VacantEntry, OccupiedEntry}
2016-07-19 12:50:15 -07:00
Srinivas Reddy Thatiparthy
9652fcbb6e
Run rustfmt on libsyntax_ext/deriving folder 2016-07-19 23:07:57 +05:30
Steve Klabnik
c4730daf45 re-work example 2016-07-19 12:32:56 -04:00
bors
27e766d7bc Auto merge of #34898 - sanxiyn:rollup, r=sanxiyn
Rollup of 5 pull requests

- Successful merges: #34807, #34853, #34875, #34884, #34889
- Failed merges:
2016-07-19 05:12:51 -07:00
Guillaume Gomez
dae311ea3b Add debug for btree_map::{Entry, VacantEntry, OccupiedEntry} 2016-07-19 11:50:25 +02:00
bors
92400cf8dc Auto merge of #33974 - habnabit:eintr-retry-for-read-iterators, r=alexcrichton
Retry on EINTR in Bytes and Chars.

>Since Bytes and Chars called directly into Read::read, they didn't use any of the retrying wrappers. This allows both iterator types to retry.
2016-07-19 01:20:50 -07:00
Alex Crichton
b45c15ecca mk: Remove -Wall -Werror everywhere
We're not writing C code, so there's not really much of a reason for us to get
warnings and errors from code we haven't written!
2016-07-19 00:04:47 -07:00
bors
8052f73d7b Auto merge of #34879 - petrochenkov:fnptr, r=alexcrichton
Implement traits for variadic function pointers

Closes https://github.com/rust-lang/rust/issues/34874
cc https://github.com/rust-lang/rust/pull/28268

r? @alexcrichton
2016-07-18 18:09:25 -07:00
bors
bbfcb471db Auto merge of #34357 - tbu-:pr_exact_size_is_empty, r=brson
Add `is_empty` function to `ExactSizeIterator`

All other types implementing a `len` functions have `is_empty` already.
2016-07-18 14:26:22 -07:00
bors
9c88898076 Auto merge of #34899 - michaelwoerister:always_internalize_symbols, r=eddyb
Run base::internalize_symbols() even for single-codegen-unit crates.

The initial linkage-assignment (especially for closures) is a conservative one that makes some symbols more visible than they need to be. While this is not a correctness problem, it does force the LLVM inliner to be more conservative too, which results in poor performance. Once translation is based solely on MIR, it will be easier to also make the initial linkage assignment a better fitting one. Until then `internalize_symbols()` does a good job of preventing most performance regressions.

This should solve the regressions reported in https://github.com/rust-lang/rust/issues/34891 and maybe also those in https://github.com/rust-lang/rust/issues/34831.

As a side-effect, this will also solve most of the problematic cases described in https://github.com/rust-lang/rust/issues/34793. Not reliably so, however. For that, we still need a solution like the one implement in https://github.com/rust-lang/rust/pull/34830.

cc @rust-lang/compiler
2016-07-18 11:29:25 -07:00
Tobias Bucher
7b2a03f08e Fix doctest of ExactSizeIterator::is_empty 2016-07-18 18:35:08 +02:00
Michael Woerister
22f77a9171 Run base::internalize_symbols() even for single-codegen-unit crates.
The initial linkage-assignment (especially for closures) is a conservative one that makes some symbols more visible than they need to be. While this is not a correctness problem, it does force the LLVM inliner to be more conservative too, which results in poor performance. Once translation is based solely on MIR, it will be easier to also make the initial linkage assignment a better fitting one. Until then `internalize_symbols()` does a good job of preventing most performance regressions.
2016-07-18 10:21:40 -04:00
Seo Sanghyeon
88b37b6d9c Rollup merge of #34889 - infinity0:master, r=sanxiyn
Test fixes for ARM64

When these changes are applied, rustc 1.10.0 tests pass successfully on [asachi.debian.org](https://db.debian.org/machines.cgi?host=asachi).
2016-07-18 22:44:57 +09:00
Seo Sanghyeon
1132a4ddfc Rollup merge of #34884 - shepmaster:from_raw_parts_doc, r=@nagisa
Improve {String,Vec}::from_raw_parts documentation
2016-07-18 22:44:56 +09:00
Seo Sanghyeon
b7138494ef Rollup merge of #34875 - frewsxcv:std-slice-struct, r=GuillaumeGomez
Indicate where `std::slice` structs originate from.

None
2016-07-18 22:44:56 +09:00
Seo Sanghyeon
15715c8377 Rollup merge of #34853 - frewsxcv:vec-truncate, r=GuillaumeGomez
Partial rewrite/expansion of `Vec::truncate` documentation.

None
2016-07-18 22:44:56 +09:00
Seo Sanghyeon
41fef433a0 Rollup merge of #34807 - sanxiyn:dump-mir, r=nagisa
Remove extra newlines in MIR dump
2016-07-18 22:44:56 +09:00
bors
06ca016b6e Auto merge of #34886 - jseyfried:improve_stmt_matchers, r=eddyb
macros: fix bug in `stmt` matchers

Today, `stmt` matchers stop too early when parsing expression statements that begin with non-braced macro invocations. For example,
```rust
fn main() {
    macro_rules! m { ($s:stmt;) => { $s } }
    id!(vec![].push(0););
    //^ Before this PR, the `stmt` matcher only consumes "vec![]", so this is an error.
    //| After this PR, the `stmt` matcher consumes "vec![].push(0)", so this compiles.
}
```
This change is backwards compatible due to the follow set for `stmt`.

r? @eddyb
2016-07-18 01:40:23 -07:00
bors
6cc49e51de Auto merge of #34860 - jseyfried:encapsulate_hygiene, r=nrc
Clean up and encapsulate `syntax::ext::mtwt`, rename `mtwt` to `hygiene`

r? @nrc
2016-07-17 22:12:59 -07:00
Jake Goulding
661187a95e Remove extraneous words 2016-07-17 18:19:20 -04:00
Jake Goulding
f6be6aa92a Document from_raw_parts involves ownership transfer 2016-07-17 18:18:49 -04:00
bors
f441bca499 Auto merge of #34876 - frewsxcv:vec-as-mut-slice, r=alexcrichton
Remove unnecessary indexing and deref in `Vec::as_mut_slice`.

None
2016-07-17 12:04:51 -07:00
Ximin Luo
8aaf0f894b doc/book: fix tests for non-x86 architectures, such as aarch64
`rustdoc --test` gets confused when "main" exists for some architectures but not others.
2016-07-17 21:00:24 +02:00
Ximin Luo
4e5e36fb79 test: disable more stdcall tests for ARM arches. temp workaround for #24958 2016-07-17 20:57:54 +02:00
Jeffrey Seyfried
275d321ab0 Remove some unit tests and that are redundant with run-pass/hygiene.rs
and that would be painful to rewrite.
2016-07-17 17:12:35 +00:00
Jeffrey Seyfried
44575f708a Rename mtwt to hygiene 2016-07-17 17:12:35 +00:00
Jeffrey Seyfried
76ed445622 Clean up and encapsulate syntax::ext::mtwt 2016-07-17 17:12:32 +00:00
Jeffrey Seyfried
bd1ad762b7 Add regression test 2016-07-17 16:08:09 +00:00
bors
34f35ed29c Auto merge of #34871 - petrochenkov:inherent, r=jseyfried
Do not resolve inherent static methods from other crates prematurely

Under some specific circumstances paths like `Type::method` can be resolved early in rustc_resolve instead of type checker. `Type` must be defined in another crate, it should be an enum or a trait object (i.e. a type that acts as a "module" in resolve), and `method` should be an inherent static method.
As a result, such paths don't go through `resolve_ufcs`, may be resolved incorrectly and break some invariants in type checker. This patch removes special treatment of such methods.

The removed code was introduced in 2bd46e767c to fix a problem that no longer exists.

r? @jseyfried
2016-07-17 09:07:50 -07:00
Jeffrey Seyfried
27a18b127f macros: Fix bug in statement matchers 2016-07-17 15:46:41 +00:00
Corey Farwell
b2f5b5a812 Indicate where std::slice structs originate from. 2016-07-17 09:16:47 -04:00
Novotnik, Petr
3b5d71e0cf Make .enumerate() example self-explanatory 2016-07-17 12:06:10 +02:00
bors
6aba7be9a6 Auto merge of #34829 - cgswords:tstream, r=nrc
Added tokenstream parser procedure

A tiny PR that simply adds a procedure for parsing `TokenStream`s to the parser in `src/libsyntax`. This is to ease using `TokenStream`s with the current (old) procedural macro system.
2016-07-17 03:05:08 -07:00
Vadim Petrochenkov
9c5039a128 Implement traits for variadic function pointers 2016-07-17 10:21:07 +03:00
bors
7ed6068d3e Auto merge of #34789 - jonathandturner:simplify_liberror, r=alexcrichton
Simplify librustc_errors

This is part 2 of the error crate refactor, starting with #34403.

In this refactor, I focused on slimming down the error crate to fewer moving parts.  As such, I've removed quite a few parts and replaced the with simpler, straight-line code.  Specifically, this PR:

* Removes BasicEmitter
* Remove emit from emitter, leaving emit_struct
* Renames emit_struct to emit
* Removes CoreEmitter and focuses on a single Emitter
* Implements the latest changes to error format RFC (#1644)
* Removes (now-unused) code in emitter.rs and snippet.rs
* Moves more tests to the UI tester, removing some duplicate tests in the process

There is probably more that could be done with some additional refactoring, but this felt like it was getting to a good state.

r? @alexcrichton   cc: @Manishearth (as there may be breaking changes in stuff I removed/changed)
2016-07-17 00:06:29 -07:00
bors
34d7f7e607 Auto merge of #34606 - mathstuf:llvm-with-ninja, r=alexcrichton
llvm, rt: build using the Ninja generator if available

The Ninja generator generally builds much faster than make. It may also
be used on Windows to have a vast speed improvement over the Visual
Studio generators.

Currently hidden behind an `--enable-ninja` flag because it does not
obey the top-level `-j` or `-l` flags given to `make`.
2016-07-16 21:09:15 -07:00
Corey Farwell
f80165dfa2 Remove unnecessary indexing and deref in Vec::as_mut_slice. 2016-07-16 22:09:55 -04:00
Guillaume Gomez
0c9a6f65d0 Add examples for LinkedList 2016-07-17 03:19:27 +02:00
bors
103e5c9b37 Auto merge of #34852 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests

- Successful merges: #33362, #34768, #34837, #34838, #34847, #34848, #34849
- Failed merges: #33951, #34850
2016-07-16 17:40:28 -07:00
Vadim Petrochenkov
f66da5e794 Do not resolve inherent static methods from other crates prematurely 2016-07-17 00:19:26 +03:00