]> git.lizzy.rs Git - rust.git/log
rust.git
7 years agoAdd non-panicking abs() functions to all signed integer types.
Jethro Beekman [Tue, 26 Jul 2016 23:31:39 +0000 (16:31 -0700)]
Add non-panicking abs() functions to all signed integer types.

Currently, calling abs() on one of the signed integer types might panic (in
debug mode at least) because the absolute value of the largest negative value
can not be represented in that signed type. Unlike all other integer
operations, there is currently not a non-panicking version on this function.
This seems to just be an oversight in the design, therefore just adding it now.

7 years agoAuto merge of #34951 - tomgarcia:covariant-vec, r=brson
bors [Thu, 28 Jul 2016 12:24:31 +0000 (05:24 -0700)]
Auto merge of #34951 - tomgarcia:covariant-vec, r=brson

Make vec::Drain and binary_heap::Drain covariant

I removed all mutable pointers/references, and added covariance tests similar to the ones in #32635. It builds and passes the tests, but I noticed that there weren't any tests of Drain's behaviour (at least not in libcollectionstest), so I'm not sure if my changes accidently broke Drain's behaviour. Should I add some tests for that (and if so, what should the tests include)?

7 years agoAuto merge of #34908 - jseyfried:improve_tt_matchers, r=nrc
bors [Thu, 28 Jul 2016 07:01:54 +0000 (00:01 -0700)]
Auto merge of #34908 - jseyfried:improve_tt_matchers, r=nrc

macros: Improve `tt` matchers

Fixes #5846, fixes #22819.
r? @nrc

7 years agoAdd regression test
Jeffrey Seyfried [Sun, 17 Jul 2016 18:28:48 +0000 (18:28 +0000)]
Add regression test

7 years agoAuto merge of #34946 - alexcrichton:fix-cfg, r=brson
bors [Thu, 28 Jul 2016 01:58:04 +0000 (18:58 -0700)]
Auto merge of #34946 - alexcrichton:fix-cfg, r=brson

std: Fix usage of SOCK_CLOEXEC

This code path was intended to only get executed on Linux, but unfortunately the
`cfg!` was malformed so it actually never got executed.

7 years agoAuto merge of #34907 - arielb1:found-parse-error, r=nikomatsakis
bors [Wed, 27 Jul 2016 21:28:06 +0000 (14:28 -0700)]
Auto merge of #34907 - arielb1:found-parse-error, r=nikomatsakis

Centralize and clean type error reporting

Refactors the code that handles type errors to be cleaner and fixes various edge cases.

This made the already-bad "type mismatch resolving" error message somewhat uglier. I want to fix that in another commit before this PR is merged.

Fixes #31173

r? @jonathandturner, cc @nikomatsakis

7 years agoAuto merge of #34856 - jseyfried:refactor_reset_tls, r=nrc
bors [Wed, 27 Jul 2016 17:16:36 +0000 (10:16 -0700)]
Auto merge of #34856 - jseyfried:refactor_reset_tls, r=nrc

Avoid reseting the thread local interner at the beginning of `phase_1_parse_input`

The thread local interner is used before `phase_1_parse_input` to create `InternedString`s, which currently wrap `Rc<String>`s. Once `InternedString` is refactored to be an interned string id (like `Name`), resetting will invalidate everything that was interned before `phase_1_parse_input`.

The resets were only useful for the `rusti` project, which can now use `driver::reset_thread_local_state`.

r? @nrc

7 years agoAuto merge of #33363 - japaric:target, r=japaric
bors [Wed, 27 Jul 2016 12:50:27 +0000 (05:50 -0700)]
Auto merge of #33363 - japaric:target, r=japaric

fix built-in target detection

previously the logic was accepting wrong triples (like
`x86_64_unknown-linux-musl`) as valid ones (like `x86_64-unknown-linux-musl`) if
they contained an underscore instead of a dash.

fixes #33329

---

r? @brson

I wanted to use a compile-fail test at first. But, you can't pass an extra `--target` flag to `rustc` for those because they already call `rustc --target $HOST` so you get a `error: Option 'target' given more than once.`. The run-make test used here works fine though.

7 years agoAuto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichton
bors [Wed, 27 Jul 2016 09:26:37 +0000 (02:26 -0700)]
Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichton

DoubleEndedIterator for Args

This PR implements the DoubleEndedIterator trait for the `std::env::Args[Os]` structure, as well
as the internal implementations.

It is primarily motivated by me, as I happened to implement a simple `reversor` program many times
now, which so far had to use code like this:

```Rust
for arg in std::env::args().skip(1).collect::<Vec<_>>().iter().rev() {}
```

... even though I would have loved to do this instead:

```Rust
for arg in std::env::args().skip(1).rev() {}
```

The latter is more natural, and I did not find a reason for not implementing it.
After all, on every system, the number of arguments passed to the program are known
at runtime.

To my mind, it follows KISS, and does not try to be smart at all. Also, there are no unit-tests,
primarily as I did not find any existing tests for the `Args` struct either.

The windows implementation is basically a copy-pasted variant of the `next()` method implementation,
and I could imagine sharing most of the code instead. Actually I would be happy if the reviewer would
ask for it.

7 years agoAuto merge of #35053 - steveklabnik:rollup, r=steveklabnik
bors [Wed, 27 Jul 2016 03:52:24 +0000 (20:52 -0700)]
Auto merge of #35053 - steveklabnik:rollup, r=steveklabnik

Rollup of 15 pull requests

- Successful merges: #34461, #34609, #34732, #34850, #34935, #34974, #34990, #34995, #35001, #35009, #35010, #35019, #35028, #35029, #35043
- Failed merges:

7 years agoAuto merge of #35014 - vadimcn:travis-test, r=alexcrichton
bors [Wed, 27 Jul 2016 00:07:08 +0000 (17:07 -0700)]
Auto merge of #35014 - vadimcn:travis-test, r=alexcrichton

Fix Travis tests

r? @vadimcn

7 years agoRollup merge of #35043 - rahiel:patch-1, r=nikomatsakis
Steve Klabnik [Tue, 26 Jul 2016 21:21:14 +0000 (17:21 -0400)]
Rollup merge of #35043 - rahiel:patch-1, r=nikomatsakis

doc/book/trait-objects: remove empty lines at start of examples

I think it looks better without them.

7 years agoRollup merge of #35029 - eulerdisk:fix_missing_comma_in_csv_dumper, r=nrc
Steve Klabnik [Tue, 26 Jul 2016 21:21:14 +0000 (17:21 -0400)]
Rollup merge of #35029 - eulerdisk:fix_missing_comma_in_csv_dumper, r=nrc

Fixed missing comma in the csv dumper.

Added missing comma before `file_line_end`.

r? @nrc

7 years agoRollup merge of #35028 - abhijeetbhagat:patch-6, r=alexcrichton
Steve Klabnik [Tue, 26 Jul 2016 21:21:13 +0000 (17:21 -0400)]
Rollup merge of #35028 - abhijeetbhagat:patch-6, r=alexcrichton

Remove no_stack_check tests (#34915)

Part of fixes for #34915

7 years agoRollup merge of #35019 - frewsxcv:slice-split, r=GuillaumeGomez
Steve Klabnik [Tue, 26 Jul 2016 21:21:13 +0000 (17:21 -0400)]
Rollup merge of #35019 - frewsxcv:slice-split, r=GuillaumeGomez

Rewrite/expansion of `slice::split` doc examples.

None

7 years agoRollup merge of #35010 - GuillaumeGomez:file_doc, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:13 +0000 (17:21 -0400)]
Rollup merge of #35010 - GuillaumeGomez:file_doc, r=steveklabnik

Improve Open doc

Part of #29356.

r? @steveklabnik

7 years agoRollup merge of #35009 - GuillaumeGomez:dir_entry_doc, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:13 +0000 (17:21 -0400)]
Rollup merge of #35009 - GuillaumeGomez:dir_entry_doc, r=steveklabnik

Dir entry doc

Part of #29356.

r? @steveklabnik

7 years agoRollup merge of #35001 - rdwilliamson:patch-1, r=alexcrichton
Steve Klabnik [Tue, 26 Jul 2016 21:21:13 +0000 (17:21 -0400)]
Rollup merge of #35001 - rdwilliamson:patch-1, r=alexcrichton

Fix HashMap's values_mut example to use println!

Fix HashMap's values_mut example to use println!

7 years agoRollup merge of #34995 - GuillaumeGomez:dir_builder_doc, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:12 +0000 (17:21 -0400)]
Rollup merge of #34995 - GuillaumeGomez:dir_builder_doc, r=steveklabnik

Add DirBuilder doc examples

r? @steveklabnik

Part of #29329 and of #29356.

7 years agoRollup merge of #34990 - abhijeetbhagat:patch-3, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:12 +0000 (17:21 -0400)]
Rollup merge of #34990 - abhijeetbhagat:patch-3, r=steveklabnik

Update underscore usage (#34903)

7 years agoRollup merge of #34974 - abhijeetbhagat:patch-2, r=GuillaumeGomez
Steve Klabnik [Tue, 26 Jul 2016 21:21:12 +0000 (17:21 -0400)]
Rollup merge of #34974 - abhijeetbhagat:patch-2, r=GuillaumeGomez

Update VecDeque documentation to specify direction of index 0 (#34920)

I mentioned the direction for all the methods that work with an index

7 years agoRollup merge of #34935 - GuillaumeGomez:hash_map_doc, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:12 +0000 (17:21 -0400)]
Rollup merge of #34935 - GuillaumeGomez:hash_map_doc, r=steveklabnik

Add HashMap Entry enums examples

Part of #29348.

r? @steveklabnik

7 years agoRollup merge of #34850 - tshepang:patch-3, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:11 +0000 (17:21 -0400)]
Rollup merge of #34850 - tshepang:patch-3, r=steveklabnik

doc: add missing pause

7 years agoRollup merge of #34732 - durka:patch-27, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:11 +0000 (17:21 -0400)]
Rollup merge of #34732 - durka:patch-27, r=steveklabnik

document DoubleEndedIterator::next_back

document DoubleEndedIterator::next_back

fixes #34726

7 years agoRollup merge of #34609 - ubsan:transmute_docs, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:11 +0000 (17:21 -0400)]
Rollup merge of #34609 - ubsan:transmute_docs, r=steveklabnik

Add more docs - mostly warnings - to std::mem::transmute

7 years agoRollup merge of #34461 - ubsan:master, r=steveklabnik
Steve Klabnik [Tue, 26 Jul 2016 21:21:10 +0000 (17:21 -0400)]
Rollup merge of #34461 - ubsan:master, r=steveklabnik

Fix ABI string docs in reference.md

7 years agoAuto merge of #34983 - alexcrichton:windows-flaky, r=brson
bors [Tue, 26 Jul 2016 20:51:34 +0000 (13:51 -0700)]
Auto merge of #34983 - alexcrichton:windows-flaky, r=brson

std: Ignore tests where threads outlive main

Long ago we discovered that threads which outlive main and then exit while the
rest of the program is exiting causes Windows to hang (#20704). That's what was
happening in this test so let's just not run this test any more.

7 years agoDoubleEndedIterator for Args
Sebastian Thiel [Sat, 30 Apr 2016 14:37:44 +0000 (16:37 +0200)]
DoubleEndedIterator for Args

The number of arguments given to a process is always known, which
makes implementing DoubleEndedIterator possible.

That way, the Iterator::rev() method becomes usable, among others.

Signed-off-by: Sebastian Thiel <byronimo@gmail.com>
Tidy for DoubleEndedIterator

I chose to not create a new feature for it, even though
technically, this makes me lie about the original availability
of the implementation.

Verify with @alexchrichton

Setup feature flag for new std::env::Args iterators

Add test for Args reverse iterator

It's somewhat depending on the input of the test program,
but made in such a way that should be somewhat flexible to changes
to the way it is called.

Deduplicate windows ArgsOS code for DEI

DEI = DoubleEndedIterator

Move env::args().rev() test to run-pass

It must be controlling it's arguments for full isolation.

Remove superfluous feature name

Assert all arguments returned by env::args().rev()

Let's be very sure it works as we expect, why take chances.

Fix rval of os_string_from_ptr

A trait cannot be returned, but only the corresponding object.

Deref pointers to actually operate on the argument

Put unsafe to correct location

7 years agodoc/book/trait-objects: remove empty lines at start of examples
Rahiel Kasim [Tue, 26 Jul 2016 09:14:46 +0000 (11:14 +0200)]
doc/book/trait-objects: remove empty lines at start of examples

7 years agoRewrite/expansion of `slice::split` doc examples.
Corey Farwell [Mon, 25 Jul 2016 02:10:36 +0000 (22:10 -0400)]
Rewrite/expansion of `slice::split` doc examples.

7 years agoWeaken test `compile-fail/lifetime-inference-give-expl-lifetime-param`.
Jeffrey Seyfried [Fri, 22 Jul 2016 16:44:09 +0000 (09:44 -0700)]
Weaken test `compile-fail/lifetime-inference-give-expl-lifetime-param`.

7 years agoLooser LSDA parsing
Vadim Chugunov [Mon, 25 Jul 2016 05:09:56 +0000 (22:09 -0700)]
Looser LSDA parsing

7 years agoFixed missing comma in the csv dumper.
Andrea Pretto [Mon, 25 Jul 2016 09:46:59 +0000 (11:46 +0200)]
Fixed missing comma in the csv dumper.

7 years agoRemove no_stack_check tests (#34915)
abhi [Mon, 25 Jul 2016 09:30:32 +0000 (15:00 +0530)]
Remove no_stack_check tests (#34915)

Part of fixes for #34915

7 years agoadd include ../tools.mk to the Makefile
Jorge Aparicio [Fri, 22 Jul 2016 22:11:38 +0000 (17:11 -0500)]
add include ../tools.mk to the Makefile

7 years agoAuto merge of #35006 - Manishearth:rollup, r=Manishearth
bors [Sun, 24 Jul 2016 18:42:06 +0000 (11:42 -0700)]
Auto merge of #35006 - Manishearth:rollup, r=Manishearth

Rollup of 7 pull requests

- Successful merges: #34965, #34972, #34975, #34976, #34977, #34988, #34989
- Failed merges:

7 years agoImprove Open doc
Guillaume Gomez [Sun, 24 Jul 2016 15:00:49 +0000 (17:00 +0200)]
Improve Open doc

7 years agoAdd DirEntry doc examples
Guillaume Gomez [Sun, 24 Jul 2016 14:52:28 +0000 (16:52 +0200)]
Add DirEntry doc examples

7 years agoAdd missing links
Guillaume Gomez [Sun, 24 Jul 2016 14:07:06 +0000 (16:07 +0200)]
Add missing links

7 years agoRollup merge of #34989 - frewsxcv:fix-set-len-doc-example, r=nagisa
Manish Goregaokar [Sun, 24 Jul 2016 09:48:48 +0000 (15:18 +0530)]
Rollup merge of #34989 - frewsxcv:fix-set-len-doc-example, r=nagisa

Fix incorrect 'memory leak' example for `Vec::set_len`.

Example was written in https://github.com/rust-lang/rust/pull/34911

Issue was brought up in this comment:

https://github.com/rust-lang/rust/commit/a005b2cd2ac679da7393e537aa05e2b7d32d36d5#commitcomment-18346958

7 years agoRollup merge of #34988 - frewsxcv:vec-windows, r=GuillaumeGomez
Manish Goregaokar [Sun, 24 Jul 2016 09:48:48 +0000 (15:18 +0530)]
Rollup merge of #34988 - frewsxcv:vec-windows, r=GuillaumeGomez

Doc example improvements for `slice::windows`.

* Modify existing example to not rely on printing to see results
* Add an example demonstrating when slice is shorter than `size`

7 years agoRollup merge of #34977 - wettowelreactor:patch-3, r=steveklabnik
Manish Goregaokar [Sun, 24 Jul 2016 09:48:48 +0000 (15:18 +0530)]
Rollup merge of #34977 - wettowelreactor:patch-3, r=steveklabnik

Fixed to spelling errors in char.rs

Fixed two small spelling mistakes (interator -> iterator) in the documentation for encode_utf8 and encode_utf16

7 years agoRollup merge of #34976 - GuillaumeGomez:build_hasher_doc, r=steveklabnik
Manish Goregaokar [Sun, 24 Jul 2016 09:48:48 +0000 (15:18 +0530)]
Rollup merge of #34976 - GuillaumeGomez:build_hasher_doc, r=steveklabnik

Add BuildHasher example

r? @steveklabnik

7 years agoRollup merge of #34975 - GuillaumeGomez:random_state_doc, r=steveklabnik
Manish Goregaokar [Sun, 24 Jul 2016 09:48:47 +0000 (15:18 +0530)]
Rollup merge of #34975 - GuillaumeGomez:random_state_doc, r=steveklabnik

Add Random state doc

Last part of #29348.

r? @steveklabnik

7 years agoRollup merge of #34972 - oli-obk:cant_cast_str_to_const_ptr, r=eddyb
Manish Goregaokar [Sun, 24 Jul 2016 09:48:47 +0000 (15:18 +0530)]
Rollup merge of #34972 - oli-obk:cant_cast_str_to_const_ptr, r=eddyb

improve const eval error reporting on "" and b"" casts

r? @eddyb

cc @ubsan

7 years agoRollup merge of #34965 - jonathandturner:multispan_cleanup, r=sanxiyn
Manish Goregaokar [Sun, 24 Jul 2016 09:48:47 +0000 (15:18 +0530)]
Rollup merge of #34965 - jonathandturner:multispan_cleanup, r=sanxiyn

Remove unused methods from MultiSpan

Removed a couple of unused methods from MultiSpan.  I thought about batching this with some other changes but wasn't sure when I'd get around to them, so PR for a tiny fix instead.

This can be rollup'd.

7 years agoFix HashMap's values_mut example to use println!
Robert Williamson [Sat, 23 Jul 2016 22:13:25 +0000 (16:13 -0600)]
Fix HashMap's values_mut example to use println!

7 years agomacros: Improve `tt` fragments
Jeffrey Seyfried [Sun, 17 Jul 2016 17:22:25 +0000 (17:22 +0000)]
macros: Improve `tt` fragments

7 years agoAuto merge of #34832 - vadimcn:rusty-personality, r=alexcrichton
bors [Sat, 23 Jul 2016 16:35:34 +0000 (09:35 -0700)]
Auto merge of #34832 - vadimcn:rusty-personality, r=alexcrichton

Implement rust_eh_personality in Rust, remove rust_eh_personality_catch.

Well, not quite: ARM EHABI platforms still use the old scheme -- for now.

r? @alexcrichton

7 years agoDoc example improvements for `slice::windows`.
Corey Farwell [Sat, 23 Jul 2016 00:23:25 +0000 (20:23 -0400)]
Doc example improvements for `slice::windows`.

* Modify existing example to not rely on printing to see results
* Add an example demonstrating when slice is shorter than `size`

7 years agoFix incorrect 'memory leak' example for `Vec::set_len`.
Corey Farwell [Sat, 23 Jul 2016 01:43:59 +0000 (21:43 -0400)]
Fix incorrect 'memory leak' example for `Vec::set_len`.

Example was written in https://github.com/rust-lang/rust/pull/34911

Issue was brought up in this comment:

https://github.com/rust-lang/rust/commit/a005b2cd2ac679da7393e537aa05e2b7d32d36d5#commitcomment-18346958

7 years agoAuto merge of #34925 - jseyfried:nested_macros, r=eddyb
bors [Sat, 23 Jul 2016 11:01:05 +0000 (04:01 -0700)]
Auto merge of #34925 - jseyfried:nested_macros, r=eddyb

Support nested `macro_rules!`

Fixes #6994.
r? @eddyb

7 years agoUpdate underscore usage (#34903)
abhi [Sat, 23 Jul 2016 07:45:09 +0000 (13:15 +0530)]
Update underscore usage (#34903)

7 years agoAdd DirBuilder doc examples
Guillaume Gomez [Fri, 22 Jul 2016 23:57:21 +0000 (01:57 +0200)]
Add DirBuilder doc examples

7 years agostd: Ignore tests where threads outlive main
Alex Crichton [Fri, 22 Jul 2016 23:21:51 +0000 (16:21 -0700)]
std: Ignore tests where threads outlive main

Long ago we discovered that threads which outlive main and then exit while the
rest of the program is exiting causes Windows to hang (#20704). That's what was
happening in this test so let's just not run this test any more.

7 years agoImplement rust_eh_personality in Rust, remove rust_eh_personality_catch.
Vadim Chugunov [Fri, 22 Jul 2016 21:57:54 +0000 (14:57 -0700)]
Implement rust_eh_personality in Rust, remove rust_eh_personality_catch.

Well, not quite: ARM EHABI platforms still use the old scheme -- for now.

7 years agoaddress review comments
Ariel Ben-Yehuda [Fri, 22 Jul 2016 20:52:53 +0000 (23:52 +0300)]
address review comments

I split the RFC1592 commit out

7 years agoAdd E0559 error explanation
ggomez [Thu, 21 Jul 2016 14:47:05 +0000 (16:47 +0200)]
Add E0559 error explanation

7 years agoAdd E0560 error explanation
ggomez [Thu, 21 Jul 2016 14:18:12 +0000 (16:18 +0200)]
Add E0560 error explanation

7 years agoAdd new error codes in librustc_typeck
ggomez [Thu, 21 Jul 2016 14:07:08 +0000 (16:07 +0200)]
Add new error codes in librustc_typeck

7 years agouse diagnostic-mutating style for `note_type_err` too
Ariel Ben-Yehuda [Thu, 21 Jul 2016 17:12:30 +0000 (20:12 +0300)]
use diagnostic-mutating style for `note_type_err` too

that is much cleaner than the `type_err!` style I used earlier.

7 years agorustc_errors: fix a few bugs
Ariel Ben-Yehuda [Thu, 21 Jul 2016 17:12:04 +0000 (20:12 +0300)]
rustc_errors: fix a few bugs

7 years agoAuto merge of #34924 - cgswords:empty_delim, r=nrc
bors [Fri, 22 Jul 2016 18:30:29 +0000 (11:30 -0700)]
Auto merge of #34924 - cgswords:empty_delim, r=nrc

Added empty CloseDelim to tokens for future use.

Description says it all. I added a new DelimToken type, Empty, to indicate a Delimited tokenstream with no actual delimiters (which are variously useful for constructing macro output).

r? @nrc

7 years agoFixed to spelling errors in char.rs
Camille Roussel [Fri, 22 Jul 2016 14:48:19 +0000 (10:48 -0400)]
Fixed to spelling errors in char.rs

Fixed two small spelling mistakes (interator -> iterator) in the documentation for encode_utf8 and encode_utf16

7 years agoAdd BuildHasher example
ggomez [Fri, 22 Jul 2016 14:38:16 +0000 (16:38 +0200)]
Add BuildHasher example

7 years agoAuto merge of #34917 - michaelwoerister:fix-internalize-symbols, r=eddyb
bors [Fri, 22 Jul 2016 14:25:06 +0000 (07:25 -0700)]
Auto merge of #34917 - michaelwoerister:fix-internalize-symbols, r=eddyb

Fix wrong condition in base::internalize_symbols().

Fix a typo that snuck into https://github.com/rust-lang/rust/pull/34899 (and completely broke `internalize_symbols()`).

7 years agoAdd Random state doc
ggomez [Fri, 22 Jul 2016 12:57:52 +0000 (14:57 +0200)]
Add Random state doc

7 years agoAdd HashMap Entry enums examples
ggomez [Wed, 20 Jul 2016 12:44:15 +0000 (14:44 +0200)]
Add HashMap Entry enums examples

7 years agoUpdate VecDeque documentation to specify direction of index 0 (#34920)
abhi [Fri, 22 Jul 2016 12:20:54 +0000 (17:50 +0530)]
Update VecDeque documentation to specify direction of index 0 (#34920)

7 years agotry to recover the non-matching types in projection errors
Ariel Ben-Yehuda [Wed, 20 Jul 2016 23:13:14 +0000 (02:13 +0300)]
try to recover the non-matching types in projection errors

The type equation in projection takes place under a binder and a snapshot, which
we can't easily take types out of. Instead, when encountering a projection error,
try to re-do the projection and find the type error then.

This fails to produce a sane type error when the failure was a "leak_check" failure.
I can't think of a sane way to show *these*, so I just left them use the old crappy
representation, and added a test to make sure we don't break them.

7 years agoremove the now-unused multiline error code
Ariel Ben-Yehuda [Mon, 18 Jul 2016 22:10:19 +0000 (01:10 +0300)]
remove the now-unused multiline error code

7 years agorefactor constant evaluation error reporting
Ariel Ben-Yehuda [Tue, 19 Jul 2016 21:02:56 +0000 (00:02 +0300)]
refactor constant evaluation error reporting

Refactor constant evaluation to use a single error reporting function
that reports a type-error-like message.

Also, unify all error codes with the "constant evaluation error" message
to just E0080, and similarly for a few other duplicate codes. The old
situation was a total mess, and now that we have *something* we can
further iterate on the UX.

7 years agoswitch projection errors to use the new type error messages
Ariel Ben-Yehuda [Mon, 18 Jul 2016 22:02:47 +0000 (01:02 +0300)]
switch projection errors to use the new type error messages

Unfortunately, projection errors do not come with a nice set of
mismatched types. This is because the type equality check occurs
within a higher-ranked context. Therefore, only the type error
is reported. This is ugly but was always the situation.

I will introduce better errors for the lower-ranked case in
another commit.

Fixes the last known occurence of #31173

7 years agoswitch compare_method to new-style trait error reporting
Ariel Ben-Yehuda [Mon, 18 Jul 2016 20:13:34 +0000 (23:13 +0300)]
switch compare_method to new-style trait error reporting

7 years agorefactor type error reporting
Ariel Ben-Yehuda [Sat, 16 Jul 2016 20:18:20 +0000 (23:18 +0300)]
refactor type error reporting

7 years agoremove rustc_typeck::same_type_err
Ariel Ben-Yehuda [Sat, 16 Jul 2016 16:38:17 +0000 (19:38 +0300)]
remove rustc_typeck::same_type_err

7 years agoremove never-called type-error reporting functions
Ariel Ben-Yehuda [Fri, 8 Jul 2016 19:51:29 +0000 (22:51 +0300)]
remove never-called type-error reporting functions

7 years agoAuto merge of #34771 - murarth:string-insert-str, r=alexcrichton
bors [Fri, 22 Jul 2016 08:36:22 +0000 (01:36 -0700)]
Auto merge of #34771 - murarth:string-insert-str, r=alexcrichton

Add method `String::insert_str`

7 years agoimprove const eval error reporting on "" and b"" casts
Oliver Schneider [Fri, 22 Jul 2016 07:34:44 +0000 (09:34 +0200)]
improve const eval error reporting on "" and b"" casts

7 years agoAuto merge of #34724 - mitchmindtree:mpsc_receiver_try_recv, r=alexcrichton
bors [Fri, 22 Jul 2016 05:39:48 +0000 (22:39 -0700)]
Auto merge of #34724 - mitchmindtree:mpsc_receiver_try_recv, r=alexcrichton

Add a method to the mpsc::Receiver for producing a non-blocking iterator

Currently, the `mpsc::Receiver` offers methods for receiving values in both blocking (`recv`) and non-blocking (`try_recv`) flavours. However only blocking iteration over values is supported. This PR adds a non-blocking iterator to complement the `try_recv` method, just as the blocking iterator complements the `recv` method.

Use-case
-------------

I predominantly use rust in my work on real-time systems and in particular real-time audio generation/processing. I use `mpsc::channel`s to communicate between threads in a purely non-blocking manner. I.e. I might send messages from the GUI thread to the audio thread to update the state of the dsp-graph, or from the audio thread to the GUI thread to display the RMS of each node. These are just a couple examples (I'm probably using 30+ channels across my various projects). I almost exclusively use the `mpsc::Receiver::try_recv` method to avoid blocking any of the real-time threads and causing unwanted glitching/stuttering. Now that I mention it, I can't think of a single time that I personally have used the `recv` method (though I can of course see why it would be useful, and perhaps the common case for many people).

As a result of this experience, I can't help but feel there is a large hole in the `Receiver` API.

| blocking | non-blocking |
|------------|--------------------|
| `recv` | `try_recv` |
| `iter` | ðŸ™€   |

For the most part, I've been working around this using `while let Ok(v) = r.try_recv() { ... }`, however as nice as this is, it is clearly no match for the Iterator API.

As an example, in the majority of my channel use cases I only want to check for *n* number of messages before breaking from the loop so that I don't miss the audio IO callback or hog the GUI thread for too long when an unexpectedly large number of messages are sent. Currently, I have to write something like this:

```rust
let mut take = 100;
while let Ok(msg) = rx.try_recv() {
    // Do stuff with msg
    if take == 0 {
        break;
    }
    take -= 1;
}
```

or wrap the `try_recv` call in a `Range<usize>`/`FilterMap` iterator combo.

On the other hand, this PR would allow for the following:

```rust
for msg in rx.try_iter().take(100) {
    // Do stuff with msg
}
```

I imagine this might also be useful to game devs, embedded or anyone doing message passing across real-time threads.

7 years agoReadding lifetime parameters and removing allocation
Thomas Garcia [Fri, 22 Jul 2016 03:55:19 +0000 (20:55 -0700)]
Readding lifetime parameters and removing allocation

7 years agoAuto merge of #34715 - scottcarr:mir-test, r=nikomatsakis
bors [Fri, 22 Jul 2016 02:44:59 +0000 (19:44 -0700)]
Auto merge of #34715 - scottcarr:mir-test, r=nikomatsakis

Add MIR Optimization Tests

I've starting working on the infrastructure for testing MIR optimizations.

The plan now is to have a set of test cases (written in Rust), compile them with -Z dump-mir, and check the MIR before and after each pass.

7 years agoAuto merge of #34544 - 3Hren:issue/xx/reinterpret-format-precision-for-strings, r...
bors [Thu, 21 Jul 2016 23:19:54 +0000 (16:19 -0700)]
Auto merge of #34544 - 3Hren:issue/xx/reinterpret-format-precision-for-strings, r=alexcrichton

feat: reinterpret `precision` field for strings

This commit changes the behavior of formatting string arguments with both width and precision fields set.

Documentation says that the `width` field is the "minimum width" that the format should take up. If the value's string does not fill up this many characters, then the padding specified by fill/alignment will be used to take up the required space.

This is true for all formatted types except string, which is truncated down to `precision` number of chars and then all of `fill`, `align` and `width` fields are completely ignored.

For example: `format!("{:/^10.8}", "1234567890);` emits "12345678". In the contrast Python version works as the expected:
```python
>>> '{:/^10.8}'.format('1234567890')
'/12345678/'
```

This commit gives back the `Python` behavior by changing the `precision` field meaning to the truncation and nothing more. The result string *will* be prepended/appended up to the `width` field with the proper `fill` char.

__However, this is the breaking change, I admit.__ Feel free to close it, but otherwise it should be mentioned in the `std::fmt` documentation somewhere near of `fill/align/width` fields description.

7 years agoFix nits
ubsan [Thu, 21 Jul 2016 19:57:42 +0000 (12:57 -0700)]
Fix nits

7 years agoRemove unused methods from MultiSpan
Jonathan Turner [Thu, 21 Jul 2016 19:38:15 +0000 (12:38 -0700)]
Remove unused methods from MultiSpan

7 years agodoc: add missing pause
Tshepang Lekhonkhobe [Sat, 16 Jul 2016 09:18:53 +0000 (11:18 +0200)]
doc: add missing pause

7 years agoAuto merge of #34939 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 21 Jul 2016 11:05:34 +0000 (04:05 -0700)]
Auto merge of #34939 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 7 pull requests

- Successful merges: #34854, #34855, #34880, #34895, #34911, #34921, #34930
- Failed merges: #33951, #34850

7 years agoFix issue in receiver_try_iter test where response sender would panic instead of...
mitchmindtree [Thu, 21 Jul 2016 09:32:24 +0000 (19:32 +1000)]
Fix issue in receiver_try_iter test where response sender would panic instead of break from the loop

7 years agoRollup merge of #34937 - GuillaumeGomez:hash_map_entry_debug, r=apasel422
Guillaume Gomez [Thu, 21 Jul 2016 09:27:01 +0000 (11:27 +0200)]
Rollup merge of #34937 - GuillaumeGomez:hash_map_entry_debug, r=apasel422

Add debug for hash_map::{Entry, VacantEntry, OccupiedEntry}

r? @alexcrichton

7 years agoRollup merge of #34930 - frewsxcv:vec-as-slice, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:01 +0000 (11:27 +0200)]
Rollup merge of #34930 - frewsxcv:vec-as-slice, r=steveklabnik

Add doc examples for `Vec::{as_slice,as_mut_slice}`.

None

7 years agoRollup merge of #34921 - GuillaumeGomez:css_fix, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:01 +0000 (11:27 +0200)]
Rollup merge of #34921 - GuillaumeGomez:css_fix, r=steveklabnik

[CSS] Fix unwanted top margin for toggle wrapper

Fixes top margin.

Before:

![before](https://cloud.githubusercontent.com/assets/3050060/16950833/72b2b956-4dc2-11e6-9d27-24507871b5a8.png)

After (check "A view into a single entry in map" toggle wrapper more precisely):

![after](https://cloud.githubusercontent.com/assets/3050060/16950839/7835c6fc-4dc2-11e6-901a-ae8c4191baca.png)

r? @steveklabnik

7 years agoRollup merge of #34919 - GuillaumeGomez:btree_map_doc, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:01 +0000 (11:27 +0200)]
Rollup merge of #34919 - GuillaumeGomez:btree_map_doc, r=steveklabnik

Add doc for btree_map types

Part of #29348.

r? @steveklabnik

7 years agoRollup merge of #34911 - frewsxcv:vec-set-len, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:00 +0000 (11:27 +0200)]
Rollup merge of #34911 - frewsxcv:vec-set-len, r=steveklabnik

Rewrite/expand doc examples for `Vec::set_len`.

None

7 years agoRollup merge of #34910 - alexcrichton:hard-float-mips, r=brson
Guillaume Gomez [Thu, 21 Jul 2016 09:27:00 +0000 (11:27 +0200)]
Rollup merge of #34910 - alexcrichton:hard-float-mips, r=brson

rustc: Remove soft-float from MIPS targets

Right now two MIPS targets in the compiler, `mips-unknown-linux-{gnu,musl}` both
generate object files using the soft-float ABI through LLVM by default. This is
also expressed as the `-C soft-float` codegen option and otherwise isn't used
for any other target in the compiler. This option was added quite some time ago
(back in #9617), and nowadays it's more appropriate to be done through a codegen
option.

This is motivated by #34743 which necessitated an upgrade in the CMake
installation on our bots which necessitated an upgrade in the Ubuntu version
which invalidated the MIPS compilers we were using. The new MIPS compilers
(coming from Debian I believe) all have hard float enabled by default and soft
float support not built in. This meant that we couldn't upgrade the bots
until #34841 landed because otherwise we would fail to compile C code as the
`-msoft-float` option wouldn't work.

Unfortunately, though, this means that once we upgrade the bots the C code we're
compiling will be compiled for hard float and the Rust code will be compiled
for soft float, a bad mismatch! This PR remedies the situation such that Rust
will compile with hard float as well.

If this lands it will likely produce broken nightlies for a day or two while we
get around to upgrading the bots because the current C toolchain only produces
soft-float binaries, and now rust will be hard-float. Hopefully, though, the
upgrade can go smoothly!

7 years agoRollup merge of #34895 - mark-buer:patch-1, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:00 +0000 (11:27 +0200)]
Rollup merge of #34895 - mark-buer:patch-1, r=steveklabnik

Remove rustdoc reference to `walk_dir`

7 years agoRollup merge of #34890 - oconnor663:addassign, r=brson
Guillaume Gomez [Thu, 21 Jul 2016 09:27:00 +0000 (11:27 +0200)]
Rollup merge of #34890 - oconnor663:addassign, r=brson

implement AddAssign for String

Currently `String` implements `Add` but not `AddAssign`. This PR fills in that gap.

I played around with having `AddAssign` (and `Add` and `push_str`) take `AsRef<str>` instead of `&str`, but it looks like that breaks arguments that implement `Deref<Target=str>` and not `AsRef<str>`. Comments in [`libcore/convert.rs`](https://github.com/rust-lang/rust/blob/master/src/libcore/convert.rs#L207-L213) make it sound like we could fix this with a blanket impl eventually. Does anyone know what's blocking that?

7 years agoRollup merge of #34880 - xitep:master, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:27:00 +0000 (11:27 +0200)]
Rollup merge of #34880 - xitep:master, r=steveklabnik

Make .enumerate() example self-explanatory

Should resolve #34624

7 years agoRollup merge of #34855 - GuillaumeGomez:vec_deque_doc, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:26:59 +0000 (11:26 +0200)]
Rollup merge of #34855 - GuillaumeGomez:vec_deque_doc, r=steveklabnik

Add examples for VecDeque

Part of #29348.

r? @steveklabnik

7 years agoRollup merge of #34854 - GuillaumeGomez:linked_list_doc, r=steveklabnik
Guillaume Gomez [Thu, 21 Jul 2016 09:26:58 +0000 (11:26 +0200)]
Rollup merge of #34854 - GuillaumeGomez:linked_list_doc, r=steveklabnik

Add examples for LinkedList

Part of #29348.

r? @steveklabnik

7 years agoRollup merge of #34828 - seanmonstar:into-opton, r=alexcrichton
Guillaume Gomez [Thu, 21 Jul 2016 09:26:57 +0000 (11:26 +0200)]
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