Commit Graph

62856 Commits

Author SHA1 Message Date
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
Niko Matsakis
eeb6447bbf add an ObligationCauseCode we'll use later (ReturnNoExpression) 2017-03-30 07:55:29 -04:00
Niko Matsakis
27f4b57602 add a TypeVariableOrigin we'll use later (DerivingFn) 2017-03-30 07:55:29 -04:00
Niko Matsakis
555b6d69b2 add some debug logs to type_variable.rs 2017-03-30 07:55:29 -04:00
Niko Matsakis
4c6c26eba1 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.
2017-03-30 07:55:29 -04:00
Niko Matsakis
066d44bc0d refactor the targeted_by_break field
In master, this field was an arbitrary node-id (in fact, an id for
something that doesn't even exist in the HIR -- the `catch` node).
Breaks targeting this block used that id. In the newer system, this
field is a boolean, and any breaks targeted this block will use the
id of the block.
2017-03-30 07:55:29 -04:00
Niko Matsakis
6a47fa1d3d remove unneeded & that now fails to coerce
cc https://github.com/rust-lang/rust/issues/40924
2017-03-30 07:55:29 -04:00
Niko Matsakis
6c02272926 update comment 2017-03-30 07:55:29 -04:00
Niko Matsakis
276bba9039 refactor if so that the "then type" is an expression 2017-03-30 07:55:29 -04:00
Thomas Jespersen
b376386228 Replace hardcoded forward slash with path::MAIN_SEPARATOR
Fixes #40149
2017-03-30 13:51:16 +02:00
raph
1be84cee75 Update process.rs 2017-03-30 09:55:44 +02:00
bors
fe151194e9 Auto merge of #40597 - jseyfried:improve_span_expn_info, r=jseyfried
macros: improve `Span`'s expansion information

This PR improves `Span`'s expansion information. More specifically:
 - It refactors AST node span construction to preserve expansion information.
   - Today, we only use the underlying tokens' `BytePos`s, throwing away the `ExpnId`s.
   - This improves the accuracy of AST nodes' expansion information, fixing #30506.
 - It refactors `span.expn_id: ExpnId` to `span.ctxt: SyntaxContext` and removes `ExpnId`.
   - This gives all tokens as much hygiene information as `Ident`s.
   - This is groundwork for procedural macros 2.0 `TokenStream` API.
   - This is also groundwork for declarative macros 2.0, which will need this hygiene information for some non-`Ident` tokens.
 - It simplifies processing of spans' expansion information throughout the compiler.
 - It fixes #40649.
 - It fixes #39450 and fixes part of #23480.

r? @nrc
2017-03-30 06:48:52 +00:00
Jeffrey Seyfried
8fde04b4a2 Improve Path spans. 2017-03-30 05:44:56 +00:00
bors
6afa0d42ff Auto merge of #40917 - aidanhs:aphs-no-appveyor-cache, r=aturon
Disable appveyor cache

Reverts just appveyor part of https://github.com/rust-lang/rust/pull/40780. r? @aturon
2017-03-30 02:11:55 +00:00
Guillaume Gomez
08a741eabf Add support for image, rules and footnotes 2017-03-29 19:48:06 -06:00
Aidan Hobson Sayers
fe0fbbff5c Disable appveyor cache 2017-03-30 01:33:45 +01:00
Nick Cameron
e3acebff66 save-analysis: track associated types 2017-03-30 12:14:04 +13:00
Camille TJHOA
b36cff5c4f Improve os::linux documentation (#29367) 2017-03-29 23:44:39 +02:00
bors
c82f1325cf Auto merge of #40911 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests

- Successful merges: #40780, #40814, #40816, #40832, #40901, #40907
- Failed merges:
2017-03-29 21:08:17 +00:00
Corey Farwell
fb6ced426e Rollup merge of #40907 - donniebishop:utf8_unchecked_docs, r=steveklabnik
Linked str in from_utf_unchecked

References #29375. Linked `str` in from_utf_unchecked's documentation to the docs for primitive `str`
2017-03-29 16:53:33 -04:00
Corey Farwell
be76eb43ff Rollup merge of #40901 - MaloJaffre:fix-double-redirect, r=steveklabnik
Avoid linking to a moved page in rust.html
2017-03-29 16:53:32 -04:00
Corey Farwell
233e0f3e52 Rollup merge of #40832 - pftbest:fix_msp430, r=stjepang
libcore: fix compilation on 16bit target (MSP430).

Since PR #40601 has been merged, libcore no longer compiles on MSP430.
The reason is this code in `break_patterns`:
```rust
 let mut random = len;
 random ^= random << 13;
 random ^= random >> 17;
 random ^= random << 5;
 random &= modulus - 1;
```
It assumes that `len` is at least a 32 bit integer.
As a workaround replace `break_patterns` with an empty function for 16bit targets.

cc @stjepang
cc @alexcrichton
2017-03-29 16:53:32 -04:00
Corey Farwell
7f1083e741 Rollup merge of #40816 - estebank:issue-38321, r=nikomatsakis
Clarify suggetion for field used as method

Instead of

```rust
error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope
   --> src/wire/ipv4.rs:409:34
    |
409 |         packet.set_src_addr(self.src_addr());
    |                                  ^^^^^^^^
    |
note: did you mean to write `self.src_addr`?
   --> src/wire/ipv4.rs:409:34
    |
409 |         packet.set_src_addr(self.src_addr());
    |                                  ^^^^^^^^
```

present

```rust
error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope
   --> src/wire/ipv4.rs:409:34
    |
409 |         packet.set_src_addr(self.src_addr());
    |                                  ^^^^^^^^ field, not a method
    |
    = help: did you mean to write `self.src_addr` instead of `self.src_addr(...)`?
```

Fix #38321.
2017-03-29 16:53:31 -04:00
Corey Farwell
ea9c8b992c Rollup merge of #40814 - abonander:issue_39436, r=jseyfried
Rustdoc: memoize `pub use`-reexported macros so they don't appear twice in docs

Closes #39436

Preserves existing behavior for `#[macro_reexport]`. `pub use`'d macros are shown as reexports unless inlined, and also correctly obey `#[doc(hidden)]`.

r? @jseyfried

cc @SergioBenitez
2017-03-29 16:53:30 -04:00
Corey Farwell
a9dc8ac7ac Rollup merge of #40780 - aidanhs:aphs-cache-git-modules, r=alexcrichton
Attempt to cache git modules

Partial resolution of #40772, appveyor remains to be done once travis looks like it's working ok.

The approach in this PR is based on the `--reference` flag to `git-clone`/`git-submodule --update` and is a compromise based on the current limitations of the tools we're using.

The ideal would be:
1. have a cached pristine copy of rust-lang/rust master in `$HOME/rustsrc` with all submodules initialised
2. clone the PR branch with `git clone --recurse-submodules --reference $HOME/rustsrc git@github.com:rust-lang/rust.git`

This would (in the nonexistent ideal world) use the pristine copy as an object cache for the top level repo and all submodules, transferring over the network only the changes on the branch. Unfortunately, a) there is no way to manually control the initial clone with travis and b) even if there was, cloned submodules don't use the submodules of the reference as an object cache. So the steps we end up with are:

1. have a cached pristine copy of rust-lang/rust master in `$HOME/rustsrc` with all submodules initialised
2. have a cloned PR branch
3. extract the path of each submodule, and explicitly `git submodule update --init --reference $HOME/rustsrc/$module $module` (i.e. point directly to the location of the pristine submodule repo) for each one

I've also taken some care to make this forward compatible, both for adding and removing submodules.

r? @alexcrichton
2017-03-29 16:53:29 -04:00
Simonas Kazlauskas
1e3bc5ac4f Allow using Vec::<T>::place_back for T: !Clone
The place_back was likely put into block with `T: Clone` bound by mistake.
2017-03-29 23:01:34 +03:00
Donnie Bishop
19b98f3027 Linked str in from_utf_unchecked 2017-03-29 13:21:31 -04:00
Alex Crichton
c033942925 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-29 08:55:15 -07:00
bors
e1cec5d4bf Auto merge of #40899 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests

- Successful merges: #40720, #40786, #40841, #40866, #40897
- Failed merges:
2017-03-29 15:38:11 +00:00
raph
5a7e9ad64a Removing trailing spaces 2017-03-29 16:30:39 +02:00
raph
3ac27c3e54 adding /// 2017-03-29 16:19:23 +02:00
raph
022bae8a4a Add example to std::process::abort 2017-03-29 15:59:22 +02:00
Malo Jaffré
4ef554206c Avoid linking to a moved page in rust.html 2017-03-29 15:38:47 +02:00
Corey Farwell
8df6cd365c Rollup merge of #40897 - irfanhudda:fix-typo-char, r=BurntSushi
Fix typo in libcore/char.rs
2017-03-29 08:57:08 -04:00
Corey Farwell
baab5d81bd Rollup merge of #40866 - projektir:once_docs, r=estebank
Adding linking for Once docs #29377

Linking everything around `Once`, `ONCE_INIT`, and `OnceState`.
2017-03-29 08:57:07 -04:00
Corey Farwell
a63b1dfa34 Rollup merge of #40841 - arielb1:immutable-blame, r=pnkfelix
borrowck: consolidate `mut` suggestions

This converts all of borrowck's `mut` suggestions to a new
`mc::ImmutabilityBlame` API instead of the current mix of various hacks.

Fixes #35937.
Fixes #40823.
Fixes #40859.

cc @estebank
r? @pnkfelix
2017-03-29 08:57:06 -04:00
Corey Farwell
96dd9a9d27 Rollup merge of #40786 - frewsxcv:unstable-book-remaining-features, r=steveklabnik
Add all unstable features to Unstable Book.

Add all unstable features to the Unstable Book, also remove a few that
either no longer exist or were promoted to stable.

These changes were extracted out of
https://github.com/rust-lang/rust/pull/40694
2017-03-29 08:57:04 -04:00