Commit Graph

78841 Commits

Author SHA1 Message Date
Felix S. Klock II
7f0c8f6638 Review feedback: Remove a fixme/tbd note and just add a note for the post-NLL future.
Driveby: just inline the two-line `fn inject_borrow` into its one call
site and remove its definition.
2018-05-29 23:02:40 +02:00
Felix S. Klock II
a4a5fa2934 Review feedback: update fixme comment to reflect reality. 2018-05-29 23:02:40 +02:00
Felix S. Klock II
2b5aa90500 review feedback: fix indentation of pattern candidates to match code elsewhere in file. 2018-05-29 23:02:40 +02:00
Felix S. Klock II
98d5e134f9 Tests illustrating the bug fixes for #27282 and #24535. 2018-05-29 23:02:40 +02:00
Felix S. Klock II
5eebd36c93 Test update: Fallout from ReadForMatch statements + changes to codegen under NLL. 2018-05-29 23:02:40 +02:00
Felix S. Klock II
3bc5073dbb Expand two-phase-borrows so that a case like this still compiles:
```rust
fn main() {
    fn reuse<X>(_: &mut X) {}
    let mut t = 2f64;
    match t {
        ref mut _b if { false } => { reuse(_b); }
        _ => {}
    }
}
```

Note: The way this is currently written is confusing; when `autoref`
is off, then the arm body bindings (introduced by
`bind_matched_candidate_for_arm_body`) are *also* used for the guard.
(Any attempt to fix this needs to still ensure that the bindings used
by the guard are introduced before the guard is evaluated.)

(Once we turn NLL on by default, we can presumably simplify all of
that.)
2018-05-29 23:02:40 +02:00
Felix S. Klock II
638acd300f Fallout from allowing some mutation in guards.
For some reason, allowing restricted mutation in match arms exposed an
obvious case where a unique borrow can indeed fail, namely something
like:

```rust
match b {
    ...
    ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); false } => { &mut *r }
    //                             ~~~~~~~
    //                                |
    // This ends up holding a `&unique` borrow of `r`, but there ends up being an
    // implicit shared borrow in the guard thanks to rust-lang/rust#49870
    ...
}
```
2018-05-29 23:02:40 +02:00
Felix S. Klock II
5c30dc85c2 rust-lang/rust#41962 has a new error with my new code. Incorporate that into my code.
In particular, I am adding an implicit injected borrow on the pattern
matches, and when we go around the loop, the compiler is reporting
that this injected borrow is conflicting with the move of the original
value when the match succeeds.
2018-05-29 23:02:40 +02:00
Felix S. Klock II
173315e353 rust-lang/rust#27282: emit ReadForMatch on each match arm.
Also, turn on ReadForMatch emission by default (when using NLL).
2018-05-29 23:02:39 +02:00
Felix S. Klock II
24abe6f363 rust-lang/rust#27282: Add StatementKind::ReadForMatch to MIR.
(This is just the data structure changes and some boilerplate match
code that followed from it; the actual emission of these statements
comes in a follow-up commit.)
2018-05-29 23:01:36 +02:00
Felix S. Klock II
47bb3fd505 Debug flag to bypass restriction of mutation in match guards.
Now, if you pass `-Z disable-ast-check-for-mutation-in-guard`, then we
will just allow you to mutably-borrow and assign in guards of `match`
arms.

This is wildly unsound with AST-borrowck. It is also unsound with
MIR-borrowck without further adjustments, which come in later in the
commit series on this Pull Request.

See also rust-lang/rust#24535 and rust-lang/rfcs#1006.
2018-05-29 23:01:36 +02:00
Mike Hommey
0f4ef003ac Pass a Layout to oom
As discussed in
https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456
and subsequent, there are use-cases where the OOM handler needs to know
the size of the allocation that failed. The alignment might also be a
cause for allocation failure, so providing it as well can be useful.
2018-05-30 05:35:48 +09:00
Niko Matsakis
3a9134dec5 fix off by one error 2018-05-29 15:09:48 -04:00
Niko Matsakis
948f77c71f tweak debug output some more 2018-05-29 15:09:37 -04:00
David Wood
62b1e6532a
Ensure that all statements in block are visited not just successors of a block. 2018-05-29 19:38:04 +01:00
Niko Matsakis
9c637144f5 add some debugging statements 2018-05-29 14:03:26 -04:00
David Wood
4500fe004b
Refactored DFS to be much cleaner. Added continue after noting that borrow is out of scope at location. 2018-05-29 18:22:01 +01:00
bors
524ad9b9e0 Auto merge of #51165 - SimonSapin:opt2, r=alexcrichton
Revert "Set opt-level to 3"

This reverts commit aad9840ad4.

Level 3 (possibly indirectly, the underlying bug might be in XCode’s linker) causes unit tests to sefault when compiled with some versions of XCode: https://github.com/rust-lang/rust/issues/50867

It also appears to cause some segfaults on Windows: https://github.com/rust-lang/rust/pull/50329#issuecomment-386853473, and regressions in some rustc performance benchmarks: https://github.com/rust-lang/rust/pull/50329#issuecomment-388084894
2018-05-29 17:17:53 +00:00
Simon Sapin
5067d2f133 Change the comment on opt-level = 2 to point to https://github.com/rust-lang/rust/issues/50867 2018-05-29 17:38:23 +02:00
bors
59c0f5913d Auto merge of #51133 - spastorino:make_borrowck_use_output, r=nikomatsakis
Make borrowck use polonius output
2018-05-29 15:02:39 +00:00
Niko Matsakis
c3d688962d WIP fix rustc-hash cargo.lock entry for polonius-engine 2018-05-29 09:39:32 -04:00
Santiago Pastorino
4c10a65b14
Whitelist datafrog on tidy 2018-05-29 10:19:47 -03:00
Santiago Pastorino
a8b36c9e9a
Run rustfmt 2018-05-29 10:19:47 -03:00
Santiago Pastorino
9de4e342df
Use polonius_output 2018-05-29 10:19:46 -03:00
Douglas Campos
db39ec8f9a
store output in FlowState 2018-05-29 10:19:46 -03:00
Douglas Campos
2cd09f27b8
store polonius output in MirBorrowCtx 2018-05-29 10:19:46 -03:00
Douglas Campos
b45aebfdf6
it compiles, but we do not use the output yet 2018-05-29 10:19:46 -03:00
Douglas Campos
4f88283869
expose -Zpolonius flag 2018-05-29 10:19:46 -03:00
Douglas Campos
422fe7c8e8
bump polonius engine 2018-05-29 10:19:45 -03:00
bors
889d8dcaa7 Auto merge of #51134 - RalfJung:from_raw_parts, r=SimonSapin
extend from_raw_parts docs for slices and strs to mention alignment requirement

The documentation for `str::from_raw_parts_mut` seems to not be visible because that method is private, bit I figured it could still be fixed. I also removed the reference to the no-longer-existing `str::from_raw_parts` while I was at it.

Alternatively, should I remove `str::from_raw_parts_mut` completely? it is only used in `str::split_at_mut`, where it might as well be inlined.
2018-05-29 12:50:06 +00:00
Simon Sapin
01e8616be9 Revert "Set opt-level to 3"
This reverts commit aad9840ad4.

Level 3 (possibly indirectly, the underlying bug might be in XCode’s linker)
causes unit tests to sefault when compiled with some versions of XCode:
https://github.com/rust-lang/rust/issues/50867

It also appears to cause some segfaults on Windows:
https://github.com/rust-lang/rust/pull/50329#issuecomment-386853473

… and regressions in some rustc performance benchmarks:
https://github.com/rust-lang/rust/pull/50329#issuecomment-388084894
2018-05-29 14:44:42 +02:00
bors
61f35e507a Auto merge of #51019 - Zoxc:hash-bytes, r=michaelwoerister
Hash up to 8 bytes at once with FxHasher

r? @michaelwoerister
2018-05-29 10:18:35 +00:00
bors
4f6d9bf209 Auto merge of #51142 - nickbabcock:doc-inspect, r=frewsxcv
Document additional use case for iter::inspect

Adds docs for `iter::inspect` showing the non-debug use case

Closes #49564
2018-05-29 06:50:12 +00:00
bors
fe5c45bb53 Auto merge of #51144 - tmccombs:unix-epoch-stable, r=Mark-Simulacrum
Stabilize SystemTime::UNIX_EPOCH

Fixes #49502
2018-05-29 03:22:20 +00:00
bors
5ae5361cdd Auto merge of #50475 - csmoe:debr, r=nikomatsakis
Refactor DebruijnIndex to be 0-based

Fixes #49813
2018-05-29 01:11:24 +00:00
Thayne McCombs
855ec8b6d5 Stabilize SystemTime::UNIX_EPOCH 2018-05-28 18:24:01 -06:00
Nick Babcock
18cf47bc7d Document additional use case for iter::inspect 2018-05-28 18:50:16 -05:00
Niko Matsakis
783fe4f880 change to 0-based indices
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:05 -04:00
Niko Matsakis
22a25d9b49 make depth private
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:05 -04:00
Niko Matsakis
7e15e0baff remove use of depth from TyS and replace with a debruijn index
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:05 -04:00
Niko Matsakis
8f15d1ea25 replace binder_depth in LateBoundRegionsDetector
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
06b2a3fbdb convert LateBoundRegionsCollector to track a debruijn index
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
4aeb6efb6d replace use of DebruijnIndex in for_each_free_region
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
34c9ae77f7 refactor resolve_lifetime to track outer-index, not depth
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
f965b79ccf rewrite the hasher to not access depth field
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
e2f7f4a7b7 port nice_region_error code to not track depth but rather index
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
8bd4bffe50 stop invoking DebruijnIndex::new directly
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:04 -04:00
Niko Matsakis
b5018de0ed make shifted_in and shifted_out const fns
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:03 -04:00
Niko Matsakis
9c5a45044a port fold_regions and friends to use debruijn indices directly
They no longer talk about plain integers.

Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28 19:47:03 -04:00
bors
e9a489be94 Auto merge of #50465 - clarcharr:wrapping, r=KodrAus
Add missing Wrapping methods, use doc_comment!

Re-opened version of #49393 . Finishing touches for #32463.

Note that this adds `Shl` and `Shr` implementations for `Wrapping<i128>` and `Wrapping<u128>`, which were previously missed. This is technically insta-stable, but I don't know why this would be a problem.
2018-05-28 22:28:43 +00:00