Commit Graph

62842 Commits

Author SHA1 Message Date
Stjepan Glavina
0e2d3d41bb Test sort algorithms using a random cmp function 2017-03-31 17:00:24 +02:00
bors
a9329d3aa3 Auto merge of #40737 - nagisa:safe-slicing-strs, r=BurntSushi
Checked slicing for strings

cc https://github.com/rust-lang/rust/issues/39932
2017-03-31 11:13:20 +00:00
Bryan Tan
5a6ebdfcda Add links to std::sync::mpsc docs #29377 2017-03-30 23:28:15 -07:00
bors
474f7a91ee Auto merge of #40620 - laumann:slash-in-diagnostics-path, r=BurntSushi
Replace hardcoded forward slash with path::MAIN_SEPARATOR

Fixes #40149
2017-03-31 03:22:39 +00:00
Guillaume Gomez
36b15f0409 Fix multiple footnotes and improve testing 2017-03-30 17:29:54 -06:00
Donnie Bishop
3b396217b5 Remove parentheses in method references 2017-03-30 18:33:23 -04:00
Donnie Bishop
c4b11d19b8 Revert SplitWhitespace's description
Original headline of SplitWhitespace's description is more descriptive as to what it contains and iterates over.
2017-03-30 16:46:16 -04:00
Donnie Bishop
a4a7166fd5 Modify SplitWhitespace's description 2017-03-30 16:36:06 -04:00
Donnie Bishop
5d14ccbc96 Modify EncodeUtf16's description 2017-03-30 16:35:19 -04:00
Donnie Bishop
17b4884d3c Modify Chars' description 2017-03-30 15:51:49 -04:00
Donnie Bishop
41e0498586 Modify CharIndices' description 2017-03-30 15:46:41 -04:00
Sam Whited
b03edb4a02 Improve the docs for the write and writeln macros
This change reduces duplication by linking the documentation for
`writeln!` to `write!`. It also restructures the `write!` documentation
to read in a more logical manner.

Updates #29329, #29381
2017-03-30 14:40:10 -05:00
Donnie Bishop
0f5cf54246 Modify Bytes' description 2017-03-30 15:40:05 -04:00
Donnie Bishop
9d4b486b84 Modify Lines' description 2017-03-30 15:36:50 -04:00
bors
5c94997b6b Auto merge of #40524 - alexcrichton:update-bootstrap, r=alexcrichton
rustbuild: Update bootstrap compiler

Now that we've also updated cargo's release process this commit also changes the
download location of Cargo from Cargos archives back to the static.r-l.o
archives. This should ensure that the Cargo download is the exact Cargo paired
with the rustc that we release.
2017-03-30 17:10:11 +00:00
Ulrik Sverdrup
6fda0fe891 cmp: Implement all PartialOrd methods for Reverse
When making a forwarding wrapper we must in general forward all methods,
so that we use the type's own `lt` for example instead of the default.

Example important case: f32's partial_cmp does several operations but
its lt is a primitive.
2017-03-30 17:29:19 +02:00
GAJaloyan
ea28196214 removing trailing whitespaces 2017-03-30 17:02:51 +02:00
GAJaloyan
f82705403f adding debug in consume_body function
When in debug_assertions=true mode, the function consume_body lacks some debug output, which makes it harder to follow the control flow. This commit adds this needed debug.
2017-03-30 16:31:16 +02:00
Stjepan Glavina
2946c41c05 More consistent wording 2017-03-30 16:23:46 +02:00
bors
7ae95e5489 Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
change the strategy for diverging types

The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes #39808.
Fixes #39984.
2017-03-30 14:20:20 +00:00
Stjepan Glavina
3fa28cc11e Add a note about overflow for fetch_add/fetch_sub 2017-03-30 16:10:55 +02:00
Luxko
8804a4a6d9 Add missing link in unstable-book
add link to specialization's tracking issue
2017-03-30 20:36:07 +08:00
Niko Matsakis
2414222b17 remove comments that were tripping up pretty printer 2017-03-30 08:18:03 -04:00
Niko Matsakis
744f666445 fix error message for issue-10176.rs 2017-03-30 08:18:03 -04:00
Niko Matsakis
fb99d87c46 update UI test
We no longer give suggestions; this is presumably related to the changes
I made in coercion. However, those suggestions appear to be wrong
anyhow!
2017-03-30 08:18:02 -04:00
Niko Matsakis
e97fc5247a kill the graphviz-flowgraph tests
They are so annoying to update, and haven't caught any bugs afaik.
2017-03-30 08:18:02 -04:00
Niko Matsakis
1b5768df4e document diverges more correctly 2017-03-30 08:18:02 -04:00
Niko Matsakis
8450add8be fix X as ! behavior 2017-03-30 08:18:02 -04:00
Niko Matsakis
7eeddb4093 add test illustrating current "coerce to !" behavior 2017-03-30 08:18:02 -04:00
Niko Matsakis
8c6156e1d1 have coercion supply back the target type
The `try_coerce` method coerces from a source to a target
type, possibly inserting adjustments. It should guarantee
that the post-adjustment type is a subtype of the target type
(or else that some side-constraint has been registered which will lead
to an error). However, it used to return the (possibly adjusted) source
as the type of the expression rather than the target. This led to
less good downstream errors.

To work around this, the code around blocks -- and particular tail
expressions in blocks -- had some special case manipulation. However,
since that code is now using the more general `CoerceMany` construct (to
account for breaks), it can no longer take advantage of that. This lead
to some regressions in compile-fail tests were errors were reported at
"less good" locations than before.

This change modifies coercions to return the target type when successful
rather the source type. This extends the behavior from blocks to all
coercions. Typically this has limited effect but on a few tests yielded
better errors results (and avoided regressions, of course).

This change also restores the hint about removing semicolons which went
missing (by giving 'force-unit' coercions a chance to add notes etc).
2017-03-30 08:18:01 -04:00
Niko Matsakis
d08a6da1f0 remove Clone from FnCtxt 2017-03-30 07:56:58 -04:00
Niko Matsakis
127a7d643d rename only_has_type_or_fresh_var to coercion_target_type 2017-03-30 07:56:58 -04:00
Niko Matsakis
d448329849 fix handling of blocks with CoerceMany 2017-03-30 07:56:58 -04:00
Niko Matsakis
f83706454f coercion now depends on whether the expression diverges
Before I was checking this in `demand_coerce` but that's not really the
right place. The right place is to move that into the coercion routine
itself.
2017-03-30 07:55:29 -04:00
Niko Matsakis
bad79484fb avoid allocating a vector when the coercion sites are known upfront 2017-03-30 07:55:29 -04:00
Niko Matsakis
609bfe82fd cherry-pick over the tests I wrote for the reachability code
For the most part, the current code performs similarly, although it
differs in some particulars. I'll be nice to have these tests for
judging future changes, as well.
2017-03-30 07:55:29 -04:00
Niko Matsakis
a60e27e25b pacify the mercilous tidy 2017-03-30 07:55:29 -04:00
Niko Matsakis
f11b7d33bb add regression test for #39808
Fixes #39808
2017-03-30 07:55:29 -04:00
Niko Matsakis
2f526cc897 we now get an extra unreachable code warning in this test 2017-03-30 07:55:29 -04:00
Niko Matsakis
5cd99aa167 more detailed tests around diverging type variables 2017-03-30 07:55:29 -04:00
Niko Matsakis
52e524a357 make try_find_coercion_lub private; we always use CoerceMany 2017-03-30 07:55:29 -04:00
Niko Matsakis
cecccd9bef whitespace changes, debug message 2017-03-30 07:55:29 -04:00
Niko Matsakis
140165f22e rewrite ExprArray processing to use CoerceMany 2017-03-30 07:55:29 -04:00
Niko Matsakis
16a71cce51 rework how we handle the type of loops
First, we keep a `CoerceMany` now to find the LUB of all the break
expressions. Second, this `CoerceMany` is actually an
`Option<CoerceMany>`, and we store `None` for loops where "break with an
expression" is disallowed. This avoids silly duplicate errors about a
type mismatch, since the loops pass already reports an error that the
break cannot have an expression. Finally, since we now detect an invalid
break target during HIR lowering, refactor `find_loop` to be infallible.

Adjust tests as needed:

- some spans from breaks are slightly different
- break up a single loop into multiple since `CoerceMany` silences
  redundant and derived errors
- add a ui test that we only give on error for loop-break-value
2017-03-30 07:55:29 -04:00
Niko Matsakis
1ae620bbeb do not eagerly convert ! to a diverging variable
Instead, wait until coercion time.  This has some small effects on a few
tests (one less temporary, generally better errors when trying to call
methods or otherwise "force" the type).
2017-03-30 07:55:29 -04:00
Niko Matsakis
4967f1ae57 document the diverges flag etc 2017-03-30 07:55:29 -04:00
Niko Matsakis
a6e6be5f88 port return expressions to use CoerceMany
This slightly affects the error messages in one particular compile-fail
test.
2017-03-30 07:55:29 -04:00
Niko Matsakis
b725272b26 port if-then-else to use CoerceMany 2017-03-30 07:55:29 -04:00
Niko Matsakis
56847af916 port the match code to use CoerceMany
`match { }` now (correctly?) indicates divergence, which results in more
unreachable warnings. We also avoid fallback to `!` if there is just one
arm (see new test: `match-unresolved-one-arm.rs`).
2017-03-30 07:55:29 -04:00
Niko Matsakis
dad3140407 introduce (but do not yet use) a CoerceMany API
The existing pattern for coercions is fairly complex. `CoerceMany`
enapsulates it better into a helper.
2017-03-30 07:55:29 -04:00