Commit Graph

70361 Commits

Author SHA1 Message Date
Ariel Ben-Yehuda
bef4fe98b1 Revert "fix treatment of local types in "remote coherence" mode"
That commit had accidentally snuck in into #44884. Revert it.

This reverts commit c48650ec25.
2017-11-28 14:54:01 +02:00
Basile Desloges
503d25cbfd mir-borrowck: describe_lvalue() can fail if a local doesn't have a name 2017-11-28 13:44:09 +01:00
Michael Woerister
3bb25d6bfb incr.comp.: Add some missing DepNode [input] annotations. 2017-11-28 13:03:39 +01:00
Michael Woerister
687e099b44 incr.comp.: Make a bunch of query results encodable. 2017-11-28 13:03:39 +01:00
Michael Woerister
8fbc91cfe1 incr.comp.: Make MIR encoding fit for incr.comp. caching. 2017-11-28 12:44:45 +01:00
bors
3bde5e78ae Auto merge of #46175 - GuillaumeGomez:fix-global-search, r=QuietMisdreavus
Fix global search

Fixes #46021.

r? @QuietMisdreavus
2017-11-28 10:41:47 +00:00
gnzlbg
32a36d8f6e white list MMX and MSA target features 2017-11-28 10:28:15 +01:00
bors
436ac8928a Auto merge of #46123 - Gankro:c-repr, r=eddyb
Implement the special repr(C)-non-clike-enum layout

This is the second half of https://github.com/rust-lang/rfcs/pull/2195

which specifies that

```rust
#[repr(C, u8)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
enum MyEnum {
    A(u32),                 // Single primitive value
    B { x: u8, y: i16 },    // Composite, and the offset of `y` depends on tag being internal
    C,                      // Empty
    D(Option<u32>),         // Contains an enum
    E(Duration),            // Contains a struct
}
```

Has the same layout as

```rust
#[repr(C)]
struct MyEnumRepr {
    tag: MyEnumTag,
    payload: MyEnumPayload,
}

#[repr(C)]
#[allow(non_snake_case)]
union MyEnumPayload {
    A: MyEnumVariantA,
    B: MyEnumVariantB,
    D: MyEnumVariantD,
    E: MyEnumVariantE,
}

#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E }
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32);
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 }
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option<u32>);
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration);

```
2017-11-28 08:04:58 +00:00
Lukas Kalbertodt
c5aad96739 Change since attribute from ctype methods from 1.23 to 1.24
The changes didn't land in time for 1.23 and stabilizations won't
be backported to beta.
2017-11-28 08:50:40 +01:00
Alexis Beingessner
0e63d2727c Fix and improve test for enum repr sizes 2017-11-28 00:54:16 -05:00
bors
7745a7a817 Auto merge of #46142 - eddyb:even-mirer-2, r=nikomatsakis
MIR: split Operand::Consume into Copy and Move.

By encoding the choice of leaving the source untouched (`Copy`) and invalidating it (`Move`) in MIR, we can express moves of copyable values and have MIR borrow-checking enforce them, *including* ownership transfer of stack locals in calls  (when the ABI passes by indirection).

Optimizations could turn a "last-use" `Copy` into a `Move`, and the MIR borrow-checker, at least within the confines of safe code, could even do this when the underlying lvalue was borrowed.
(However, that last part would be the first time lifetime inference affects code generation, AFAIK).

Furthermore, as `Move`s invalidate borrows as well, for any local that is initialized only once, we can ignore borrows that happened before a `Move` and safely reuse/replace its memory storage.
This will allow us to perform NRVO in the presence of short-lived borrows, unlike LLVM (currently), and even compute optimal `StorageLive...StorageDead` ranges instead of discarding them.
2017-11-28 05:38:19 +00:00
Eduard-Mihai Burtescu
919ed409b0 tests: update to include move annotations in MIR. 2017-11-28 04:18:32 +02:00
Eduard-Mihai Burtescu
170b88dc79 rustc_mir: require that Copy(L) satisfies typeof L: Copy. 2017-11-28 04:18:32 +02:00
Eduard-Mihai Burtescu
c42a118188 MIR: split Operand::Consume into Copy and Move. 2017-11-28 04:18:32 +02:00
Eduard-Mihai Burtescu
73f5bab33f rustc_mir: enforce that arguments are replaced with Local's only. 2017-11-28 04:11:09 +02:00
Eduard-Mihai Burtescu
0477319afb rustc_mir: move storage_dead_or_drop_error_reported logic to access_lvalue. 2017-11-28 04:11:09 +02:00
bors
3e9a7f7fbb Auto merge of #46102 - kennytm:45861-step-1, r=alexcrichton
[auto-toolstate][1/8] Always ignore build failure of failable tools (rls, rustfmt, clippy)

If build failed for these tools, they will be automatically skipped from distribution, and will not fail the whole build.

Test failures are *not* ignored, nor build failure of other tools (e.g. cargo). Therefore it should have no observable effect to the current CI system.

This is step 1/8 of automatic management of broken tools #45861. The purpose is concentrate all failure detection about tools into a single CI job for easy management, while keeping the ability to distribute these tools in the nightlies.

r? @Mark-Simulacrum
2017-11-28 02:08:52 +00:00
bors
b087a991fc Auto merge of #46312 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #45506, #46174, #46231, #46240, #46249, #46258, #46262, #46275, #46282, #46285
- Failed merges:
2017-11-27 23:40:16 +00:00
Julien Cretin
8424cacff8 Use an unstable feature linked to #46316 2017-11-27 22:31:00 +01:00
Oliver Middleton
71d766bd55
Change version number for impl From<bool> for AtomicBool to 1.24.0 2017-11-27 21:26:19 +00:00
kennytm
83a6f38556 Rollup merge of #46285 - SimonSapin:twos-complement, r=GuillaumeGomez
Document non-obvious behavior of fmt::UpperHex & co for negative integers

Before stabilization I’d have suggested changing the behavior,  but that time is past.
2017-11-28 03:16:50 +08:00
kennytm
8dd10e62cc Rollup merge of #46282 - estebank:impl-trait-cicle-span, r=arielb1
Shorten output of E0391

Use the shorter `def_span` on the impl-Trait cyclic reference errors.
2017-11-28 03:16:49 +08:00
kennytm
81ba35228c Rollup merge of #46275 - dtolnay:compiletest-libc, r=Mark-Simulacrum
Compiletest libc dependency can be unix-only

In main.rs libc is imported as:

```rust
#[cfg(unix)]
extern crate libc;
```

This came up in https://github.com/laumann/compiletest-rs/pull/90.
2017-11-28 03:16:48 +08:00
kennytm
7707b18621 Rollup merge of #46262 - udoprog:linked-list-remove-if, r=dtolnay
Introduce LinkedList::drain_filter

This introduces `LinkedList::remove_if`.

This operation embodies one of the use-cases where `LinkedList` would typically be preferred over `Vec`: random removal and retrieval.

There are a number of considerations with this:

Should there be two `remove_if` methods? One where elements are only removed, one which returns a collection of removed elements.

Should this be implemented using a draining iterator pattern that covers both cases? I suspect that would incur a bit of overhead (moving the element into the iterator, then into a new collection). But I'm not sure. Maybe that's an acceptable compromise to maximize flexibility.

I don't feel I've had enough exposure to unsafe programming in rust to be certain the implementation is correct. This relies quite heavily on moving around copies of Shared pointers to make the code reasonable. Please help me out :).
2017-11-28 03:16:47 +08:00
kennytm
f33edd2ed0 Rollup merge of #46258 - colinmarsh19:master, r=estebank
Remove semicolon note

In reference to issue #46186
r? @estebank

First time doing a pull request, if there are any suggestions on how to improve this please let me know.
@jjolly
2017-11-28 03:16:47 +08:00
kennytm
a60ffa06ae Rollup merge of #46249 - estebank:suggest-slice, r=arielb1
Suggest using slice when encountering `let x = ""[..];`

Fix #26319.
2017-11-28 03:16:46 +08:00
kennytm
840e6c12ba Rollup merge of #46240 - SimonSapin:from_str_radix-docs, r=estebank
Expand docs of <$Int>::from_str_radix, based on that of char::to_digit
2017-11-28 03:16:45 +08:00
kennytm
26330b1757 Rollup merge of #46231 - ritiek:verbs, r=arielb1
MIR: Fix value moved diagnose messages

#45960. I believe this will take a different approach. Simply replacing all nouns to verbs (`desired_action`) messes up the message `use of moved value` (although fixes the message in original issue). Here is what happens:

<pre>
$ rustc -Zborrowck-mir src/test/ui/borrowck/borrowck-reinit.rs

error[E0382]: <b>used</b> of moved value: `x` (Mir)
  --> src/test/ui/borrowck/borrowck-reinit.rs:18:16
   |
17 |     drop(x);
   |          - value moved here
18 |     let _ = (1,x);
   |                ^ value used here after move

error: aborting due to 2 previous errors
</pre>
(Notice: *"**used** of moved value: `x`"* instead of *"**use**"*)

Which does not seem to be okay.

After experimenting a bit, it looks like [`report_use_of_moved_value()`](1dc0b573e7/src/librustc_mir/borrow_check.rs (L1319)) tries to handle both these messages by taking in only one form of`desired_action`.

These messages rise from: *"[{noun} of moved value](1dc0b573e7/src/librustc_mir/borrow_check.rs (L1338-L1342))"* and *"[value {verb} here after move](1dc0b573e7/src/librustc_mir/borrow_check.rs (L1343))"*.

This PR fixes *"value {verb} here after move"* type messages by passing a corresponding verb (`desired_action`) instead of the original noun.
2017-11-28 03:16:44 +08:00
kennytm
aa99bd96fd Rollup merge of #46174 - stjepang:stabilize-spinloophint, r=sfackler
Stabilize spin_loop_hint

Stabilize `spin_loop_hint` in release `1.23.0`.
I've also renamed feature `hint_core_should_pause` to `spin_loop_hint`.

cc #41196
2017-11-28 03:16:43 +08:00
kennytm
2f012e4405 Rollup merge of #45506 - ia0:mpsc_recv_error_from, r=alexcrichton
Implement From<RecvError> for TryRecvError and RecvTimeoutError

According to the documentation, it looks to me that `TryRecvError` and `RecvTimeoutError` are strict extensions of `RecvError`. As such, it makes sense to allow conversion from the latter type to the two former types without constraining future developments.

This permits to write `input.recv()?` and `input.recv_timeout(timeout)?` in the same function for example.
2017-11-28 03:16:41 +08:00
Stjepan Glavina
d5e8b61054 Change the stabilization version to 1.24.0 2017-11-27 19:24:13 +01:00
bors
560a5da9f1 Auto merge of #46022 - matthewjasper:cannot-assign-twice-error, r=arielb1
Mir Borrowck: Parity with Ast for E0384 (Cannot assign twice to immutable)

- Closes #45199
- Don't allow assigning to dropped immutable variables
- Show the "first assignment" note on the first assignment that can actually come before the second assignment.
- Make "first assignment" notes point to function parameters if needed.
- Don't show a "first assignment" note if the first and second assignment have the same span (in a loop). This matches ast borrowck for now, but maybe this we should add "in previous loop iteration" as with some other borrowck errors. (Commit 2)
- Use revisions to check mir borrowck for the existing tests for this error. (Commit 3)

~~Still working on a less ad-hoc way to get 'first assignment' notes to show on the correct assignment. Also need to check mutating function arguments.~~ Now using a new dataflow pass.
2017-11-27 17:13:20 +00:00
bors
58e1234cdd Auto merge of #44884 - arielb1:pack-safe, r=nikomatsakis,eddyb
Make accesses to fields of packed structs unsafe

To handle packed structs with destructors (which you'll think are a rare
case, but the `#[repr(packed)] struct Packed<T>(T);` pattern is
ever-popular, which requires handling packed structs with destructors to
avoid monomorphization-time errors), drops of subfields of packed
structs should drop a local move of the field instead of the original
one.

That's it, I think I'll use a strategy suggested by @Zoxc, where this mir
```
drop(packed_struct.field)
```

is replaced by
```
tmp0 = packed_struct.field;
drop tmp0
```

cc #27060 - this should deal with that issue after codegen of drop glue
is updated.

The new errors need to be changed to future-compatibility warnings, but
I'll rather do a crater run first with them as errors to assess the
impact.

cc @eddyb

Things which still need to be done for this:
 - [ ] - handle `repr(packed)` structs in `derive` the same way I did in `Span`, and use derive there again
 - [ ] - implement the "fix packed drops" pass and call it in both the MIR shim and validated MIR pipelines
 - [ ] - do a crater run
 - [ ] - convert the errors to compatibility warnings
2017-11-27 14:23:02 +00:00
Esteban Küber
fa44927d2c reword to "consider borrowing here: {suggestion}" 2017-11-27 06:03:40 -08:00
Esteban Küber
487daabb52 Fix test 2017-11-27 06:01:16 -08:00
Esteban Küber
8a93deca9a Make main span in impl-trait ciclic reference point to def_span 2017-11-27 06:00:20 -08:00
bors
5face5f4f5 Auto merge of #46292 - cramertj:update-libc, r=alexcrichton
Update libc to include latest Fuchsia fix

r? @alexcrichton

cc @smklein
2017-11-27 11:44:17 +00:00
Matthew Jasper
d64a31882f Update tests involving E0384 for mir-borrowck 2017-11-27 08:07:58 +00:00
Matthew Jasper
6853b34f0e Don't show first assignment in loops
Matches current ast-borrowck behavior.
2017-11-27 08:07:49 +00:00
Matthew Jasper
d409dbf983 Add initialization info to MoveData
* Used for new dataflow to track if a variable has every been initialized
* Used for other dataflows that need to be updated for initializations
2017-11-27 08:06:36 +00:00
bors
ea51b19dc7 Auto merge of #46286 - SimonSapin:patch-6, r=alexcrichton
Increment Nightly version to 1.24.0

The beta channel is now at 1.23.0-beta.1.
2017-11-27 07:54:39 +00:00
bors
8270faf8dc Auto merge of #46284 - SimonSapin:deprecate-formatter-flags, r=sfackler
Deprecate the Formatter::flags method, fix #46237

This fixes #46237.
2017-11-27 05:26:23 +00:00
bors
73df30d467 Auto merge of #46273 - semarie:openbsd-libc++, r=alexcrichton
make OpenBSD to use libc++ instead of (e)stdc++
2017-11-27 01:43:41 +00:00
Oliver Middleton
652a4bd26c impl From<bool> for AtomicBool 2017-11-27 01:23:04 +00:00
Taylor Cramer
9d96d77f77 Update libc to include latest Fuchsia fix 2017-11-26 17:01:15 -08:00
Simon Sapin
6c5f53e65e Stabilize const-calling existing const-fns in std
Fixes #46038
2017-11-26 23:43:44 +01:00
Simon Sapin
ef7cd00c8e
Increment Nightly version to 1.24.0
The beta channel is now at 1.23.0-beta.1.
2017-11-26 23:04:40 +01:00
Simon Sapin
a326d8d1ba Document non-obvious behavior of fmt::UpperHex & co for negative integers
Before stabilization I’d have suggested changing the behavior,
but that time is past.
2017-11-26 22:53:03 +01:00
Simon Sapin
5e11c8fc2b Deprecate the Formatter::flags method, fix #46237 2017-11-26 22:45:28 +01:00
bors
9015b142b4 Auto merge of #46168 - durka:macro-backtrace, r=durka
mention nightly in -Z external-macro-backtrace note

Fix #46167 by mentioning that you need nightly in the message that tells you to pass `-Z external-macro-backtrace`.

Rationale:

1. The reason for having this message is to increase discoverability of the functionality. If the message is only shown on nightly it's less disoverable.
2. The same approach is taken if you call a const fn in const context without its feature gate (previously, if you called it without `#![feature(const_fn)]`).

cc @kennytm
2017-11-26 21:30:28 +00:00