Commit Graph

295 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
314fbf48cf
Rollup merge of #64749 - matthewjasper:liveness-opt, r=nikomatsakis
Fix most remaining Polonius test differences

This fixes most of the Polonius test differences and also avoids overflow in issue-38591.rs.

r? @nikomatsakis
2019-10-04 07:24:33 +02:00
Matthew Jasper
08a60ac6ed Calculate liveness for the same locals with and without -Zpolonius
This fixes some test differences and also avoids overflow in
issue-38591.rs.
2019-10-02 20:39:01 +01:00
Felix S. Klock II
9fe138aa43 regression test for 64453 borrow check error. 2019-10-01 15:57:27 +02:00
Mazdak Farrokhzad
487f8ab732 add test for #53432. 2019-09-26 06:44:57 +02:00
Mazdak Farrokhzad
6ec9b3a0b6 Adjust & --bless tests due to no longer downgrading NLL errors on 2015. 2019-09-26 06:44:57 +02:00
Mazdak Farrokhzad
0204f36441
Rollup merge of #64428 - GuillaumeGomez:error-explanation-E0524, r=Centril
Error explanation e0524

Part of https://github.com/rust-lang/rust/issues/61137
2019-09-25 03:48:24 +02:00
Guillaume Gomez
d2b873b067 update ui tests 2019-09-21 17:43:56 +02:00
Mazdak Farrokhzad
908636f510
Rollup merge of #64601 - grovesNL:two-backticks, r=jonas-schievink
Fix backticks in documentation

Fix a few typos in comments/documentation where backticks were doubled-up on one side.
2019-09-19 18:31:40 +02:00
Joshua Groves
37bafeafe7 Fix backticks in documentation 2019-09-18 23:17:36 -06:00
lqd
222e920151 Bless output of test borrowck/return-local-binding-from-desugaring.rs for Polonius 2019-09-17 19:30:34 +02:00
bors
45859b7ca7 Auto merge of #63118 - Centril:stabilize-bind-by-move, r=matthewjasper
Stabilize `bind_by_move_pattern_guards` in Rust 1.39.0

Closes https://github.com/rust-lang/rust/issues/15287.

After stabilizing `#![feature(bind_by_move_pattern_guards)]`, you can now use bind-by-move bindings in patterns and take references to those bindings in `if` guards of `match` expressions. For example, the following now becomes legal:

```rust
fn main() {
    let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);

    match array {
        nums
//      ---- `nums` is bound by move.
            if nums.iter().sum::<u8>() == 10
//                 ^------ `.iter()` implicitly takes a reference to `nums`.
        => {
            drop(nums);
//          --------- Legal as `nums` was bound by move and so we have ownership.
        }
        _ => unreachable!(),
    }
}
```

r? @matthewjasper
2019-09-09 12:46:59 +00:00
Mark Rousskov
6fdbece55f Update test stderr with results of enabling unused lints 2019-09-08 11:32:28 -04:00
Mazdak Farrokhzad
642993e6dc Update tests wrt. bind_by_by_move_pattern_guards stabilization. 2019-09-08 01:39:24 +02:00
Mazdak Farrokhzad
afb6a7002d
Rollup merge of #64202 - alexreg:rush-pr-1, r=Centril
Fixed grammar/style in some error messages

Factored out from hacking on rustc for work on the REPL.

r? @Centril
2019-09-06 19:00:49 +02:00
Mazdak Farrokhzad
055409538d Refuse to downgrade NLL errors on Rust >= 2018. 2019-09-06 11:06:18 +02:00
Alexander Regueiro
022d9c8eb5 Fixed grammar/style in error messages and reblessed tests. 2019-09-06 03:46:08 +01:00
Matthew Jasper
365ff62fca Don't unwrap the result of span_to_snippet
It can return `Err` due to macros being expanded across crates or
files.
2019-08-24 18:25:34 +01:00
Mazdak Farrokhzad
ab7155dd97
Rollup merge of #63230 - tmandry:disallow-possibly-uninitialized, r=Centril
Make use of possibly uninitialized data [E0381] a hard error

This is one of the behaviors we no longer allow in NLL. Since it can
lead to undefined behavior, I think it's definitely worth making it a
hard error without waiting to turn off migration mode (#58781).

Closes #60450.

My ulterior motive here is making it impossible to leave variables
partially initialized across a yield (see #60889, discussion at #63035), so
tests are included for that.

cc #54987

---

I'm not sure if bypassing the buffer is a good way of doing this. We could also make a `force_errors_buffer` or similar that gets recombined with all the errors as they are emitted. But this is simpler and seems fine to me.

r? @Centril
cc @cramertj @nikomatsakis @pnkfelix @RalfJung
2019-08-06 08:17:38 +02:00
Tyler Mandry
9058bf2100 Make use of possibly uninitialized data a hard error
This is one of the behaviors we no longer allow in NLL. Since it can
lead to undefined behavior, I think it's definitely worth making it a
hard error without waiting to turn off migration mode (#58781).

Closes #60450.

My ulterior motive here is making it impossible to leave variables
partially initialized across a yield (see discussion at #63035), so
tests are included for that.
2019-08-05 14:57:12 -07:00
Mazdak Farrokhzad
0201cb8e49 Add tests for #27282, #31287 as hard errors. 2019-07-30 06:43:06 +02:00
Mazdak Farrokhzad
a421e51266 borrowck-migrate-to-nll: use #38899 for testing. 2019-07-30 06:43:06 +02:00
Mazdak Farrokhzad
513852f68b borrowck-mutate-in-guard: update test. 2019-07-30 06:43:06 +02:00
Mazdak Farrokhzad
a558668cf2
Rollup merge of #63051 - estebank:borrow-ice, r=matthewjasper
Avoid ICE when referencing desugared local binding in borrow error

To avoid leaking the names of local bindings from expressions like for loops, #60984 explicitly ignored them, but an assertion that `LocalKind::Var` *must* have a name would trigger an ICE.

Before this change, the binding generated by desugaring the for loop would leak into the diagnostic (#63027):
```
error[E0515]: cannot return value referencing local variable `__next`
  --> return-local-binding-from-desugaring.rs:LL:CC
   |
LL |     for ref x in xs {
   |         ----- `__next` is borrowed here
...
LL |     result
   |     ^^^^^^ returns a value referencing data owned by the current function
```

Ideally `LocalKind` would carry more information to more accurately explain the problem, but for now, in order to avoid the ICE (fix #63026), we accept `LocalKind::Var` without a name and produce the following output:

```
error[E0515]: cannot return value referencing local binding
  --> $DIR/return-local-binding-from-desugaring.rs:30:5
   |
LL |     for ref x in xs {
   |                  -- local binding introduced here
...
LL |     result
   |     ^^^^^^ returns a value referencing data owned by the current function
```
2019-07-28 11:11:12 +02:00
Mazdak Farrokhzad
d33696fcb4 borrowck-describe-lvalue: --bless --compare-mode=nll. 2019-07-28 07:04:16 +02:00
Mazdak Farrokhzad
91c8b53f45 --bless tests due to new subslice syntax. 2019-07-28 06:53:39 +02:00
Mazdak Farrokhzad
75da43dc87 Use new 'p @ ..' syntax in tests. 2019-07-28 06:53:39 +02:00
Esteban Küber
01ba0e3718 review comments 2019-07-27 19:15:25 -07:00
Esteban Küber
b523b2d51e Avoid ICE when referencing desugared local binding in borrow error 2019-07-27 13:25:09 -07:00
Vadim Petrochenkov
5486cc69bd tests: Move run-pass tests with naming conflicts to ui 2019-07-27 18:56:17 +03:00
Vadim Petrochenkov
9be35f82c1 tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
lqd
0bd2b32358 Bless output of test borrowck/promote-ref-mut-in-let-issue-46557.rs for Polonius 2019-07-22 11:36:44 +02:00
lqd
7db61e78c0 Bless output of test borrowck/two-phase-surprise-no-conflict.rs for Polonius 2019-07-22 10:32:40 +02:00
lqd
6fe52928a3 Bless output of test borrowck/borrowck-escaping-closure-error-2.rs for Polonius 2019-07-22 10:32:40 +02:00
lqd
273bfd43c1 Ignore two-phase-reservation-sharing-interference-2.rs in Polonius compare mode
This is just a difference from the test construction, it's ignore-compare-mode-nll and manually checks migrate/nll over edition2015/2018.

This failure is because the `migrate2015` and `migrate2018`  revisions are ran with `-Zpolonius`. There is no actual difference in the errors output by NLLs and Polonius.
2019-07-22 10:32:37 +02:00
lqd
d4ca9a349c Ignore test issue-45983 in the polonius compare mode
There is no difference between the NLL and Polonius outputs, and it manually tests NLLs.
2019-07-22 10:32:37 +02:00
lqd
c442dae5b8 Ignore NLL migrate mode test in the Polonius compare-mode
This is test specific to the NLL migrate mode which is irrelevant to -Z polonius.
It can't currently be encoded depending on migrate-mode and NLL/Polonius mode, so the NLL compare-mode also ignores it.
2019-07-22 10:32:36 +02:00
Samy Kacimi
e5e1397adb
normalize use of backticks in compiler messages for librustc/lint
https://github.com/rust-lang/rust/issues/60532
2019-07-17 22:49:48 +02:00
bors
ec30876f30 Auto merge of #62468 - rust-lang:mutable-overloaded-operators, r=estebank
Improve diagnostics for invalid mutation through overloaded operators

Closes #58864
Closes #52941
Closes #57839
2019-07-13 13:44:40 +00:00
Mazdak Farrokhzad
5760bc6e98
Rollup merge of #62465 - matthewjasper:never-type-storage, r=pnkfelix
Sometimes generate storage statements for temporaries with type `!`

Closes #62165
cc #42371
2019-07-10 16:08:21 +02:00
bors
b8ec4c4d11 Auto merge of #62233 - matthewjasper:exit-arm-scopes, r=pnkfelix
Exit arm scopes

Due to a bug in the HIR CFG construction, borrows for arm scopes were incorrectly leaking into other arms.
This PR also includes some drive-by improvements to `-Zunpretty=hir,identified` that would have been helpful while investigating this.

Closes #62107
2019-07-09 13:10:31 +00:00
Matthew Jasper
38306adf16 Add help message for mutation though overloaded place operators 2019-07-07 15:24:19 +01:00
Matthew Jasper
163c059354 Only omit StorageLive/Dead for variable that are never initialized
With `feature(never_type)`, it's not guaranteed that any variable with
type `!` isn't ever assigned to.
2019-07-07 15:04:43 +01:00
Matthew Jasper
de5c6ec1f4 Exit arm scopes correctly in the HIR CFG
When a match evaluates to false we jump to the next arm, when we do so
we need to make sure that we exit the scope for that arm.
2019-07-06 21:56:03 +01:00
Samy Kacimi
7a2a17af09
normalize use of backticks/lowercase in compiler messages for librustc_mir
https://github.com/rust-lang/rust/issues/60532

r? @alexreg
2019-07-06 20:40:40 +02:00
Mazdak Farrokhzad
547735457f Make WhileTrue into an EarlyLintPass lint. 2019-07-06 06:43:58 +02:00
Yuki Okushi
c004451a20 Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
Matthew Jasper
da22793a35 Create fewer basic blocks in match MIR lowering 2019-06-13 21:05:21 +01:00
Kenny Goodin
de677b993f Remove asterisk suggestion for move errors in borrowck
As per issue #54985 removes the not useful suggestion to remove asterisk in
move errors. Includes minor changes to tests in the `ui` suite to account
for the removed suggestion.
2019-06-04 13:31:40 -04:00
Matthew Jasper
8ffa408059 Update tests for changes to cannot move errors 2019-06-03 14:55:29 +01:00
bors
d461555e44 Auto merge of #61460 - Centril:rollup-8txhjx4, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #61380 (Fix some issues with `unwrap_usize` instead of `assert_usize`)
 - #61423 (codegen: change `$6d$` to `$u6d$`)
 - #61438 (Point at individual type args on arg count mismatch)
 - #61441 (Tweak wording when encountering `fn` call in pattern)
 - #61451 (Fix missing semicolon in doc)
 - #61458 (Fix typo in AsRef doc)

Failed merges:

r? @ghost
2019-06-02 14:42:11 +00:00