Commit Graph

79360 Commits

Author SHA1 Message Date
Takanori Ishibashi
f386cdae19 innacurate -> inaccurate 2018-05-27 09:47:04 +09:00
Simon Martin
023137dc1e Issue #51022: Improve E0131 message when lifetimes are involved. 2018-05-27 00:28:49 +02:00
Mateusz Mikuła
05f15d45c3 Update cargo 2018-05-27 00:00:34 +02:00
bors
5015fa346c Auto merge of #51094 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 3 pull requests

Successful merges:

 - #51049 (Fix behaviour of divergence in while loop conditions)
 - #51057 (make ui tests robust with respect to NLL)
 - #51092 ([master] Release notes for 1.26.1)

Failed merges:
2018-05-26 19:05:39 +00:00
Esteban Küber
7dec8a4e99 Fix test 2018-05-26 12:03:50 -07:00
est31
20ab8841b1 Point to the current box syntax tracking issue
The issue was used for both box syntax as well as placement new.
It got closed due to placement new being unapproved.
So a new one got created for box syntax, yet neither
the unstable book nor feature_gate.rs got updated.
We are doing this now.
2018-05-26 19:27:21 +02:00
Mark Simulacrum
472b04d827
Rollup merge of #51092 - Mark-Simulacrum:release-notes-master, r=Mark-Simulacrum
[master] Release notes for 1.26.1

None
2018-05-26 11:22:55 -06:00
Mark Simulacrum
b1de3519c9
Rollup merge of #51057 - pnkfelix:issue-51025-make-ui-tests-robust-wrt-nll, r=nikomatsakis
make ui tests robust with respect to NLL

This PR revises the `ui` tests that I could quickly identify that:
 1. previously had successful compilations under non-lexical lifetimes (NLL) because they assumed lexical lifetimes, but
 2. such assumption of lexical lifetimes was actually not necessarily part of the spirit of the original issue/bug we want to witness.

In many cases, this is simply a matter of adding a use of a borrow so that it gets extended long enough to observe a conflict.

(In some cases the revision was more subtle, such as adding a destructor, or revising the order of declaration of some variables.)

----

With these test revisions in place, I subsequently updated the expected stderr output under the NLL compiletest mode. So now we should get even more testing of NLL than we were before.

Fix #51025
2018-05-26 11:22:54 -06:00
Mark Simulacrum
90b7bf6e0a
Rollup merge of #51049 - varkor:break-while-condition, r=nikomatsakis
Fix behaviour of divergence in while loop conditions

This fixes `'a: while break 'a {};` being treated as diverging, by tracking break expressions in the same way as in `loop` expressions.

Fixes #50856.

r? @nikomatsakis
2018-05-26 11:22:53 -06:00
Mark Simulacrum
ae80941b11 Copy release notes from stable branch to master 2018-05-26 11:19:21 -06:00
bors
1e504d301c Auto merge of #51072 - petrochenkov:ifield, r=eddyb
Use `Ident`s for fields in HIR

Continuation of https://github.com/rust-lang/rust/pull/49718, part of https://github.com/rust-lang/rust/issues/49300
2018-05-26 16:56:22 +00:00
bors
1594c6c650 Auto merge of #51052 - nikomatsakis:obsolete-arrow, r=petrochenkov
restore emplacement syntax (obsolete)

Fix https://github.com/rust-lang/rust/issues/50832

r? @petrochenkov
2018-05-26 14:30:30 +00:00
Vadim Petrochenkov
1e4269cb83 Add Ident::as_str helper 2018-05-26 15:20:23 +03:00
bors
7a0e6a837f Auto merge of #51082 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests

Successful merges:

 - #50987 (Underline multiple suggested replacements in the same line)
 - #51014 (Add documentation about env! second argument)
 - #51034 (Remove unused lowering field and method)
 - #51047 (Use AllFacts from polonius-engine)
 - #51048 (Add more missing examples for Formatter)
 - #51056 (Mention and use `Once::new` instead of `ONCE_INIT`)
 - #51059 (What does an expression look like, that consists only of special characters?)
 - #51065 (Update nomicon link in transmute docs)
 - #51067 (Add inner links in documentation)
 - #51070 (Fail typecheck if we encounter a bogus break)
 - #51073 (Rename TokenStream::empty to TokenStream::new)

Failed merges:
2018-05-26 12:03:28 +00:00
Vadim Petrochenkov
189c0a1297 Use Idents for fields in HIR 2018-05-26 14:41:58 +03:00
kennytm
84b2e14b9d
Rollup merge of #51073 - dtolnay:empty, r=alexcrichton
Rename TokenStream::empty to TokenStream::new

There is no precedent for the `empty` name -- we do not have `Vec::empty` or `HashMap::empty` etc.

I would propose landing this but reflecting it in a non-breaking release of proc-macro2 that provides both `new` and a deprecated `empty` constructor.

Tracking issue: #38356

r? @alexcrichton
2018-05-26 19:32:33 +08:00
kennytm
5089ebc568
Rollup merge of #51070 - est31:fix_break_const_ice, r=estebank
Fail typecheck if we encounter a bogus break

Lone breaks outside of loops create errors in the
loop check pass but as they are not fatal,
compilation continues.

MIR building code assumes all HIR break statements
to point to valid locations and fires ICEs if this
assumption is violated. In normal compilation,
this causes no issues, as code apparently prevents
MIR from being built if errors are present.

However, before that, typecheck runs and with it
MIR const eval. Here we operate differently
from normal compilation: it doesn't check for any
errors except for type checker ones and then
directly builds the MIR.

This constellation causes an ICE-on-error if
bogus break statements are being put into array
length expressions.

This commit fixes this ICE by letting typecheck
fail if bogus break statements are encountered.
This way, MIR const eval fails cleanly with a
type check error.

Fixes #50576
Fixes #50581
2018-05-26 19:32:32 +08:00
kennytm
239e3d2dd7
Rollup merge of #51067 - mcarton:patch-1, r=steveklabnik
Add inner links in documentation

From [this SO question](https://stackoverflow.com/q/50518757/2733851) it looks like this page isn't really clear.
I personally do think this page is quite clear, the only think I could think of was adding some references.
2018-05-26 19:32:30 +08:00
kennytm
18028eb217
Rollup merge of #51065 - mbrubeck:docs, r=rkruppe
Update nomicon link in transmute docs

The list of "invalid primitive values" has moved to a different URL within the Rustonomicon.
2018-05-26 19:32:29 +08:00
kennytm
5d95492d3a
Rollup merge of #51059 - oberien:patch-1, r=nikomatsakis
What does an expression look like, that consists only of special characters?

I had a lot of fun creating this together with @CryZe
2018-05-26 19:32:25 +08:00
kennytm
e0e598bb76
Rollup merge of #51056 - tbu-:pr_once_new, r=dtolnay
Mention and use `Once::new` instead of `ONCE_INIT`
2018-05-26 19:32:24 +08:00
kennytm
08b417084d
Rollup merge of #51048 - GuillaumeGomez:formatter-examples, r=QuietMisdreavus
Add more missing examples for Formatter

r? @QuietMisdreavus
2018-05-26 19:32:23 +08:00
kennytm
e667e7be60
Rollup merge of #51047 - spastorino:use_polonius_engine_facts, r=nikomatsakis
Use AllFacts from polonius-engine
2018-05-26 19:32:22 +08:00
kennytm
e66ba0fe8b
Rollup merge of #51034 - oli-obk:lowering, r=pnkfelix
Remove unused lowering field and method

r? @nikomatsakis

So while trying to understand lowering better, I found out that there's something related to creating definitions. Analyzing that further, I realized that it is entirely dead code.

The `parent_def` field was only ever used for setting and resetting the field itself. The field was never read anywhere else and thus its value was entirely unused.

Maybe the `unused_field` lint should detect when the only use of a field is the field being read without using the read value other than writing back to the field?

The diff is best viewed without whitespace changes getting in the way: https://github.com/rust-lang/rust/pull/51034/files?w=1
2018-05-26 19:32:21 +08:00
kennytm
ee18e92684
Rollup merge of #51014 - GuillaumeGomez:env_docs, r=QuietMisdreavus
Add documentation about env! second argument

Fixes #48044.

r? @QuietMisdreavus
2018-05-26 19:32:20 +08:00
kennytm
103abdb75c
Rollup merge of #50987 - estebank:underline-multiple-suggestions, r=petrochencov
Underline multiple suggested replacements in the same line

<img width="685" alt="screen shot 2018-05-22 at 21 06 48" src="https://user-images.githubusercontent.com/1606434/40403051-174f3180-5e04-11e8-86b6-261630c5ff80.png">

Follow up to #50943.

Fix #50977.
2018-05-26 19:32:18 +08:00
bors
b4247d45a5 Auto merge of #51041 - alexcrichton:better-unwind, r=nikomatsakis
std: Ensure OOM is classified as `nounwind`

OOM can't unwind today, and historically it's been optimized as if it can't
unwind. This accidentally regressed with recent changes to the OOM handler, so
this commit adds in a codegen test to assert that everything gets optimized away
after the OOM function is approrpiately classified as nounwind

Closes #50925
2018-05-26 09:59:43 +00:00
bors
444a9c3f1a Auto merge of #50364 - LukasKalbertodt:improve-duration-debug-impl, r=KodrAus
Improve `Debug` impl of `time::Duration`

Hi there!

For a long time now, I was getting annoyed by the derived `Debug` impl of `Duration`. Usually, I use `Duration` to either do quick'n'dirty benchmarking or measuring the time of some operation in general. The output of the derived Debug impl is hard to parse for humans: is { secs: 0, nanos: 968360102 } or { secs: 0, nanos 98507324 } longer?

So after running into the annoyance several times (sometimes building my own function to print the Duration properly), I decided to tackle this. Now the output looks like this:

```
Duration::new(1, 0)                 => 1s
Duration::new(1, 1)                 => 1.000000001s
Duration::new(1, 300)               => 1.0000003s
Duration::new(1, 4000)              => 1.000004s
Duration::new(1, 600000)            => 1.0006s
Duration::new(1, 7000000)           => 1.007s
Duration::new(0, 0)                 => 0ns
Duration::new(0, 1)                 => 1ns
Duration::new(0, 300)               => 300ns
Duration::new(0, 4001)              => 4.001µs
Duration::new(0, 600300)            => 600.3µs
Duration::new(0, 7000000)           => 7ms
```

Note that I implemented the formatting manually and didn't use floats. No information is "lost" when printing. So `Duration::new(123_456_789_000, 900_000_001)` prints as `123456789000.900000001s`.

~~This is not yet finished~~, but I wanted to open the PR now already in order to get some feedback (maybe everyone likes the derived impl).

### Still ToDo:

- [x] Respect precision ~~and width~~ parameter of the formatter (see [this comment](https://github.com/rust-lang/rust/pull/50364#issuecomment-386107107))

### Alternatives/Decisions

- Should large durations displayed in minutes, hours, days, ...? For now, I decided not to because the current formatting is close the how a `Duration` is stored. From this new `Debug` output, you can still easily see what the values of `secs` and `nanos` are. A formatting like `3h 27m 12s 9ms` might be more appropriate for a `Display` impl?
- Should this rather be a `Display` impl and should `Debug` be derived? Maybe this formatting is too fancy for `Debug`? In my opinion it's not and, as already mentioned, from the current format one can still very easily determine the values for `secs` and `nanos`.
- Whitespace between the number and the unit?

### Notes for reviewers

- ~~The combined diff sucks. Rather review both commits individually.~~
- ~~In the unit test, I am building my own type implementing `fmt::Write` to test the output. Maybe there is already something like that which I can use?~~
- My `Debug` impl block is marked as `#[stable(...)]`... but that's fine since the derived Debug impl was stable already, right?

---

~~Apart from the main change, I moved all `time` unit tests into the `tests` directory. All other `libcore` tests are there, so I guess it was simply an oversight. Prior to this change, the `time` tests weren't run, so I guess this is kind of a bug fix. If my `Debug` impl is rejected, I can of course just send the fix as PR.~~ (this was already merged in #50466)
2018-05-26 07:33:06 +00:00
Zack M. Davis
6437295b17 in which we check for confusable Unicodepoints in float literal exponent
The `FatalError.raise()` might seem unmotivated (in most places in
the compiler, `err.emit()` suffices), but it's actually used to
maintain behavior (viz., stop lexing, don't emit potentially spurious
errors looking for the next token after the bad Unicodepoint in the
exponent): the previous revision's `self.err_span_` ultimately calls
`Handler::emit`, which aborts if the `Handler`'s continue_after_error
flag is set, which seems to typically be true during lexing (see
`phase_1_parse_input` and and how `CompileController::basic` has
`continue_parse_after_error: false` in librustc_driver).

Also, let's avoid apostrophes in error messages (the present author
would argue that users expect a reassuringly detached, formal,
above-it-all tone from a Serious tool like a compiler), and use an
RLS-friendly structured suggestion.

Resolves #49746.
2018-05-25 20:48:31 -07:00
bors
67d99d91e5 Auto merge of #51035 - oli-obk:unsupported_crate_type, r=eddyb
Don't ICE if crate has no valid crate types left

fixes #50993
2018-05-26 03:22:39 +00:00
David Tolnay
a49bc9ce59
Rename TokenStream::empty to TokenStream::new
There is no precedent for the `empty` name -- we do not have
`Vec::empty` or `HashMap::empty` etc.
2018-05-25 19:44:10 -07:00
est31
5724dad82e Fail typecheck if we encounter a bogus break
Lone breaks outside of loops create errors in the
loop check pass but as they are not fatal,
compilation continues.

MIR building code assumes all HIR break statements
to point to valid locations and fires ICEs if this
assumption is violated. In normal compilation,
this causes no issues, as code apparently prevents
MIR from being built if errors are present.

However, before that, typecheck runs and with it
MIR const eval. Here we operate differently
from normal compilation: it doesn't check for any
errors except for type checker ones and then
directly builds the MIR.

This constellation causes an ICE-on-error if
bogus break statements are being put into array
length expressions.

This commit fixes this ICE by letting typecheck
fail if bogus break statements are encountered.
This way, MIR const eval fails cleanly with a
type check error.

Fixes #50576
Fixes #50581
2018-05-26 03:09:55 +02:00
bors
49a97ef010 Auto merge of #50070 - toidiu:ak-2093-outlives, r=nikomatsakis
2093 infer outlives requirements

Tracking issue:  #44493
RFC: https://github.com/rust-lang/rfcs/pull/2093

- [x] add `rustc_attrs` flag
- [x] use `RequirePredicates` type
- [x]  handle explicit predicates on `dyn` Trait
- [x] handle explicit predicates on projections
- [x] more tests
- [x]  remove `unused`, `dead_code` and etc..
- [x]  documentation
2018-05-26 01:09:02 +00:00
bors
07c415c215 Auto merge of #51033 - coryshrmn:master, r=dtolnay
stabilize RangeBounds collections_range #30877

The FCP for #30877 closed last month, with the decision to:
1. move from `collections::range::RangeArgument` to `ops::RangeBounds`, and
2. rename `start()` and `end()` to `start_bounds()` and `end_bounds()`.

Simon Sapin already moved it to `ops::RangeBounds` in #49163.

I renamed the functions, and removed the old `collections::range::RangeArgument` alias.

This is my first Rust PR, please let me know if I can improve anything. This passes all tests for me, except the `clippy` tool (which uses `RangeArgument::start()`).

I considered deprecating `start()` and `end()` instead of removing them, but the contribution guidelines indicate we can break `clippy` temporarily. I thought it was best to remove the functions, since we're worried about name collisions with `Range::start` and `end`.

Closes #30877.
2018-05-25 22:18:27 +00:00
Martin Carton
91f7ae26b0
Add inner links in documentation
From [this SO question](https://stackoverflow.com/q/50518757/2733851) it looks like this page isn't really clear.
I personally do think this page is quite clear, the only think I could think of was adding some references.
2018-05-25 22:55:33 +02:00
Matt Brubeck
37cbd11a9f Update nomicon link in transmute docs
The list of "invalid primitive values" has moved to a different URL
within the Rustonomicon.
2018-05-25 11:47:48 -07:00
varkor
d5bf4de0e4 --bless the tests 2018-05-25 17:31:45 +01:00
varkor
03d816fd93 Add a test for returning inside a while loop 2018-05-25 16:53:32 +01:00
varkor
a38a1ce29c Fix behaviour of divergence in while loop conditions
This fixes `'a: while break 'a {};` being treated as diverging, by tracking break expressions in the same way as in `loop` expressions.
2018-05-25 16:53:32 +01:00
Jaro Fietz
5ad84cf3fa
Don't use a char that's already used within the expr 2018-05-25 16:55:38 +02:00
Jaro Fietz
7c97203e2f
Call it 2018-05-25 16:50:59 +02:00
Jaro Fietz
de12d437c9
What does an expression look like, that consists only of special characters? 2018-05-25 16:48:55 +02:00
bors
990d8aa743 Auto merge of #50967 - oli-obk:miri_api_refactor, r=eddyb
Miri api refactor

r? @eddyb

cc @Zoxc

based on https://github.com/rust-lang/rust/pull/50916
2018-05-25 13:59:48 +00:00
toidiu
3da712381d Implement outlives requirements inference for dyn and projections.
Add tests, documentation and attr for feature.
2018-05-25 09:58:00 -04:00
Oliver Schneider
5f599bb490 Adjust test for 32 bit targets 2018-05-25 15:13:54 +02:00
Felix S. Klock II
d8bd5336c9 rust-lang/rust#51025: improve test robustness so that they work under NLL too. 2018-05-25 13:00:51 +02:00
Oliver Schneider
50d3783b95 Sanity abort to_bits if used on zsts 2018-05-25 11:56:33 +02:00
bors
9823cb99c5 Auto merge of #51051 - nikomatsakis:turbofish-impl-trait-method, r=eddyb
prohibit turbofish in `impl Trait` methods

Fix #50950
2018-05-25 09:01:11 +00:00
Niko Matsakis
626818fc42 pacify the mercilous tidy 2018-05-25 04:46:42 -04:00
Oliver Schneider
eceeb63d11 Update comment 2018-05-25 10:18:57 +02:00