summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2018-08-25An attempt to fix NLL migration mode so that reports region errors when ↵Felix S. Klock II-5/+40
necessary. Namely, the code here was trying to be clever, and say "lets not report diagnostics when we 'know' NLL will report an error about them in the future." The problem is that in migration mode, when no error was reported here, the NLL error that we "knew" was coming was downgraded to a warning (!). This fixes that by only doing the "clever" skipping of region error reporting when we are not in migration mode. Rather than make a separate test for issue 53026, I just took the test that uncovered this in a first place, and extended it (via our revisions system) to explicitly show all three modes in action: ACT-borrowck, NLL, and NLL migration mode. (Tto be honest I hope not to have to add such revisions to many tests. Instead I hope to adopt some sort of new `compare-mode` for either borrowck=migrate or for the 2018 edition as a whole.)
2018-07-28Auto merge of #52678 - matthewjasper:better-spans, r=nikomatsakisbors-14/+10
[NLL] Use better spans in some errors * Use the span of the discriminant and patterns for "fake" statements created to properly check matches. I plan to special case these soon, but this felt like a good first step * Use the span of the statement, rather than the initialization, when reporting move errors for `let x = ...`, which avoids giving an unhelpful suggestion to use `&{ }`. r? @nikomatsakis cc @pnkfelix
2018-07-27Auto merge of #52733 - ↵bors-0/+33
pnkfelix:issue-51348-make-temp-for-each-candidate-in-arm, r=nikomatsakis [NLL] make temp for each candidate in `match` arm In NLL, `ref mut` patterns leverage the two-phase borrow infrastructure to allow the shared borrows within a guard before the "activation" of the mutable borrow when we begin execution of the match arm's body. (There is further discussion of this on PR #50783.) To accommodate the restrictions we impose on two-phase borrows (namely that there is a one-to-one mapping between each activation and the original initialization), this PR is making separate temps for each candidate pattern. So in an arm like this: ```rust PatA(_, ref mut ident) | PatB(ref mut ident) | PatC(_, _, ref mut ident) | PatD(ref mut ident) if guard_stuff(ident) => ... ``` instead of 3 temps (two for the guard and one for the arm body), we now have 4 + 2 temps associated with `ident`: one for each candidate plus the actual temp that the guard uses directly, and then the sixth is the temp used in the arm body. Fix #51348
2018-07-27Auto merge of #52681 - pnkfelix:z-borrowck-migrate, r=nikomatsakisbors-0/+147
Add `-Z borrowck=migrate` This adds `-Z borrowck=migrate`, which represents the way we want to migrate to NLL under Rust versions to come. It also hooks this new mode into `--edition 2018`, which means we're officially turning NLL on in the 2018 edition. The basic idea of `-Z borrowck=migrate` that there are cases where NLL is fixing old soundness bugs in the borrow-checker, but in order to avoid just breaking code by immediately rejecting the programs that hit those soundness bugs, we instead use the following strategy: If your code is accepted by NLL, then we accept it. If your code is rejected by both NLL and the old AST-borrowck, then we reject it. If your code is rejected by NLL but accepted by the old AST-borrowck, then we emit the new NLL errors as **warnings**. These warnings will be turned into hard errors in the future, and they say so in these diagnostics. Fix #46908
2018-07-26Use better spans for dummy accesses used in matchesMatthew Jasper-14/+10
2018-07-26Auto merge of #52735 - Mark-Simulacrum:rollup, r=Mark-Simulacrumbors-2/+2
Rollup of 16 pull requests Successful merges: - #52558 (Add tests for ICEs which no longer repro) - #52610 (Clarify what a task is) - #52617 (Don't match on region kinds when reporting NLL errors) - #52635 (Fix #[linkage] propagation though generic functions) - #52647 (Suggest to take and ignore args while closure args count mismatching) - #52649 (Point spans to inner elements of format strings) - #52654 (Format linker args in a way that works for gcc and ld) - #52667 (update the stdsimd submodule) - #52674 (Impl Executor for Box<E: Executor>) - #52690 (ARM: expose `rclass` and `dsp` target features) - #52692 (Improve readability in a few sorts) - #52695 (Hide some lints which are not quite right the way they are reported to the user) - #52718 (State default capacity for BufReader/BufWriter) - #52721 (std::ops::Try impl for std::task::Poll) - #52723 (rustc: Register crates under their real names) - #52734 (sparc ABI issue - structure returning from function is returned in 64bit registers (with tests)) Failed merges: - #52678 ([NLL] Use better spans in some errors) r? @ghost
2018-07-26Regression test for the bug.Felix S. Klock II-0/+33
2018-07-26Incorporate edition flag testing into tests of `-Z borrowck=migrate`.Felix S. Klock II-7/+52
2018-07-26Bug fix: `#![feature(nll)]` takes precedence over `-Z borrowck=migrate`.Felix S. Klock II-0/+46
(Includes test illustrating desired behavior; compare its diagnostic output to that of the file `borrowck-migreate-to-nll.rs`.)
2018-07-26Test for `-Z borrowck=migrate`.Felix S. Klock II-0/+56
Note that this test is carefully crafted to *try* to not segfault during its run. Howver, it really is representing unsound code that should be rejected after we manage to remove the AST-borrowck entirely from the compiler.
2018-07-25consolidate and use `find_sub_region_live_at` for everythingNiko Matsakis-12/+21
remove the old blame system
2018-07-23Don't match on region kinds when reporting NLL errorsMatthew Jasper-2/+2
With NLL region kinds are always ReVar
2018-07-22Fallback to general error handling in ICE cases.David Wood-4/+4
2018-07-22Improved closure errors.David Wood-16/+16
2018-07-22Classify aggregate rvalues as assignments.David Wood-4/+4
2018-07-21Add specific message when moving from upvars in a non-FnOnce closureMatthew Jasper-4/+4
2018-07-20Update tests for new NLL mutability errorsMatthew Jasper-12/+784
2018-07-09find and highlight the `&` or `'_` in `region_name`Niko Matsakis-1/+1
2018-07-06Auto merge of #52021 - nikomatsakis:nll-region-errors, r=estebankbors-14/+36
refactor and cleanup region errors for NLL This is a WIP commit. It simplifies some of the code from https://github.com/rust-lang/rust/pull/51536 and extends a few more steps towards the errors that @davidtwco and I were shooting for. These are intended as a replacement for the general "unable to infer lifetime" messages -- one that is actually actionable. We're certainly not there yet, but the overall shape hopefully gets a bit clearer. I'm thinking about trying to open up an internals thread to sketch out the overall plan and perhaps discuss how to get the wording right, which special cases to handle, etc. r? @estebank cc @davidtwco
2018-07-05fix for issue #8636Mikhail Modin-0/+256
2018-07-04write code to extract region names and emit new style messageNiko Matsakis-14/+36
2018-06-30Auto merge of #51862 - estebank:lifetime-spans, r=nikomatsakisbors-18/+32
Point to lifetime spans on lifetime errors
2018-06-28Also point to free named region on lifetime errorsEsteban Küber-28/+8
2018-06-28Extend support to `get_generics` for all `NodeItem`sEsteban Küber-2/+2
2018-06-28Point to lifetime in fn definition on lifetime error noteEsteban Küber-1/+21
2018-06-28Point at lifetimes instead of def span for E0195Esteban Küber-13/+27
2018-06-27Update tests for grouped nll move errorsMatthew Jasper-55/+80
2018-06-22Fix erroneous error note when using field after moveSantiago Pastorino-8/+8
2018-06-21use `pat_ty_adjusted` from `expr_use_visitor` to type of argumentsNiko Matsakis-0/+42
2018-06-19Update the existing UI tests to reflect diagnostic changes in NLL.Felix S. Klock II-1/+1
2018-06-19NLL: Updates to diagnostic output in `test/ui`.Felix S. Klock II-3/+5
2018-06-06Update the expected error output to reflect changes in this PR.Felix S. Klock II-38/+63
2018-06-06Drive-by: Make assignment conflict tests in borrowck-vec-pattern-nesting.rs ↵Felix S. Klock II-0/+5
robust for NLL.
2018-06-05Auto merge of #51242 - ytausky:mut-ref, r=estebankbors-0/+43
Suggest not mutably borrowing a mutable reference This PR would (hopefully) solve #45392. I deviated a bit from @estebank's instructions since the error span only included the borrowed expression (e.g. the `b` in `&mut b`). I also didn't check the mutability of the local binding, since this whole case is concerned with an immutable local. I can see two outstanding questions: 1. `note_immutability_blame` is called in two places, but I only have one test case. I think it covers the call in `report_bckerror`, but I'm not sure how to trigger the call from `report_aliasability_violation`. 2. There is one failing test, where the local binding is `self: &mut Self`. I'm not entirely sure what the correct output should be, but I think the new message should also apply. Unfortunately, since this parameter is parsed differently, its `let_span` covers both the pattern and the type, leading to a wrong suggestion text. I'm not sure how to correctly identify this case.
2018-06-01Suggest not mutably borrowing a mutable referenceYaron Tausky-0/+43
This commit is concerned with the case where the user tries to mutably borrow a mutable reference, thereby triggering an error. Instead of the existing suggestion to make the binding mutable, the compiler will now suggest to avoid borrowing altogether.
2018-06-01also check `let` arms and nested patterns for mutable borrowsNiko Matsakis-0/+161
2018-05-31change `PointerKind::Implicit` to a noteNiko Matsakis-0/+52
`PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo. The `note` field, in contrast, is intended more-or-less primarily for this purpose of adding extra data.
2018-05-29rust-lang/rust#41962 has a new error with my new code. Incorporate that into ↵Felix S. Klock II-8/+16
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-25rust-lang/rust#51025: improve test robustness so that they work under NLL too.Felix S. Klock II-28/+80
2018-05-09rework causal tracking to explore outlives relationshipsNiko Matsakis-3/+12
Instead of tracking the "cause" of each bit that gets added, try to recover that by walking outlives relationships. This is currently imprecise, since it ignores the "point" where the outlives relationship is incurred -- but that's ok, since we're about to stop considering that overall in a later commit. This does seem to affect one error message negatively, I didn't dig *too* hard to find out why.
2018-04-18Removed `.nll.stderr` files that currently match their corresponding ↵Felix S. Klock II-78/+0
`.stderr` files.
2018-04-18Trivial updates to `.nll.stderr` files post-rebase, reflecting s/-Znll/nll/ ↵Felix S. Klock II-5/+5
in messages.
2018-04-18Update the previously checkpointed (but unused by bors) tests to reflect ↵Felix S. Klock II-1/+1
current reality.
2018-04-15remove -Znll -- borrowck=mir implies nll nowNiko Matsakis-27/+28
2018-04-11Checkpoint the current status of NLL on `ui` tests via compare-mode=nll.Felix S. Klock II-0/+394
2018-04-11Workaround rust-lang/rust#49855 by forcing rustc_error in any mode, ↵Felix S. Klock II-4/+4
including NLL. NOTE: I was careful to make each change in a manner that preserves the existing diagnostic output (usually by ensuring that no lines were added or removed). This means that the resulting source files are not as nice to read as they were at the start. But we will have to review these cases by hand anyway as follow-up work, so cleanup could reasonably happen then (or not at all).
2018-04-06Add test from #49736bobtwinkles-0/+49
Fixes #49736
2018-04-04two-phase borrows: support multiple activations in one statementbobtwinkles-0/+35
The need for this has arisen since the introduction of two-phase borrows on method autorefs. Fixes 49635 Fixes 49662
2018-04-03Auto merge of #49348 - bobtwinkles:extend_2pb, r=nikomatsakisbors-0/+29
Extend two-phase borrows to apply to method receiver autorefs Fixes #48598 by permitting two-phase borrows on the autorefs created when functions and methods.
2018-03-24Extend two-phase borrows to apply to method receiver autorefsbobtwinkles-0/+29
This is required to compile things like src/test/ui/borrowck/two-phase-method-receivers.rs