about summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2018-08-16tests: prefer edition: directives to compile-flags:--edition.Eduard-Mihai Burtescu-3/+3
2018-08-15Add files I forgot to commit earlierashtneoi-0/+12
2018-08-15Bless testsashtneoi-45/+138
2018-08-15Bless UI testsashtneoi-34/+91
2018-08-15Removed `ignore-test-compare-mode-nll` from borrowck-closures-two-mut-fail.rsFelix S. Klock II-10/+93
by strengthening the tests there.
2018-08-15Removed `ignore-test-compare-mode-nll` from borrowck-closures-unique.rsFelix S. Klock II-8/+90
by strengthening the tests there. In almost all cases the strengthening amount to just encoding a use that models the original lexical lifetime. A more invasive revision was made in one case where it seems the actual issue is MIR-borrowck's greater "knowledge" of unreachable code in the control flow...
2018-08-15Updated the most glaring instances of weak tests w.r.t. NLL that came from ↵Felix S. Klock II-125/+573
#53196. See also the bulletpoint list on #53351.
2018-08-14Update former compile-fail testsMatthew Jasper-4/+4
2018-08-14Improved how upvars are detected when presenting errors using prefixes.David Wood-0/+3
2018-08-14Label definition of captured variables in errors.David Wood-0/+5
2018-08-14Tidy no longer fails when there are no files or subdirectories in a test ↵David Wood-0/+78
directory.
2018-08-14Merged migrated compile-fail tests and ui tests. Fixes #46841.David Wood-78/+16395
2018-08-10Auto merge of #53177 - ↵bors-20/+14
nikomatsakis:nll-redundant-borrows-and-escaping-values, r=pnkfelix optimize redundant borrows and escaping paths in NLL This builds on https://github.com/rust-lang/rust/pull/53168 and adds a commit that addresses https://github.com/rust-lang/rust/issues/53176 -- or at least I think it does. I marked this as WIP because I want to see the test results (and measure the performance). I also want to double check we're not adding in any unsoundness here.
2018-08-09Auto merge of #52788 - LukasKalbertodt:improve-index-mut-error, r=estebankbors-0/+74
Add help message for missing `IndexMut` impl Code: ```rust let mut map = HashMap::new(); map.insert("peter", 23); map["peter"] = 27; ``` Before: ``` error[E0594]: cannot assign to immutable indexed content --> src/main.rs:7:5 | 7 | map["peter"] = 27; | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable ``` With this change (just the `help` was added): ``` error[E0594]: cannot assign to immutable indexed content --> index-error.rs:7:5 | 7 | map["peter"] = 27; | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for std::collections::HashMap<&str, i32> ``` --- Yesterday I did some pair programming with a Rust-beginner. We created a type and implemented `Index` for it. Trying to modify the value returned by the index operation returns in a rather vague error that was not very clear for the Rust beginner. So I tried to improve the situation. ## Notes/questions for reviewers: - Is the formulation OK like that? I'm fine with changing it. - Can we be absolutely sure that `IndexMut` is actually not implemented in the case my `help` message is added? I'm fairly sure myself, but there could be some cases I didn't think of. Also, I don't know the compiler very well, so I don't know what exactly certain enum variants are used for. - It would be nice to test if `IndexMut` is in fact not implemented for the type, but I couldn't figure out how to check that. If you think that additional check would be beneficial, could you tell me how to check if a trait is implemented? - Do you think I should change the error message instead of only adding an additional help message?
2018-08-08Add and update tests for `IndexMut` help messageLukas Kalbertodt-0/+74
2018-08-07avoid computing liveness when a variable doesn't need itNiko Matsakis-20/+14
In particular, we skip computing liveness for a variable X if all the regions in its type are known to outlive free regions.
2018-08-07Auto merge of #53109 - nikomatsakis:nll-escaping-into-return-revert, ↵bors-14/+63
r=nikomatsakis revert #52991 Reverts https://github.com/rust-lang/rust/pull/52991 which is flawed. I have an idea how to fix it but might as well revert first since it is so wildly flawed. That's what I get for opening PRs while on PTO =) r? @pnkfelix
2018-08-06add test case showing how previous attempt was unsoundNiko Matsakis-0/+43
2018-08-06revert #52991Niko Matsakis-14/+20
2018-08-06Auto merge of #53045 - ↵bors-5/+40
pnkfelix:issue-53026-migrate-never-looser-than-ast-borrowck, r=estebank Fix NLL migration mode so that reports region errors when necessary. 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 (!). Thus causing #53026 (I hope it is the only instance of such a scenario, but we will see.) Anyway, this PR fixes that by only doing the "clever" skipping of region error reporting when we are not in migration mode. As noted in the FIXME, I'm not really thrilled with this band-aid, but it is small enough to be back-ported easily if that is necessary. 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: AST-borrowck, NLL, and NLL migration mode. (To 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.) Fix #53026
2018-08-05Auto merge of #52959 - matthewjasper:closure-spans, r=pnkfelixbors-14/+18
[NLL] Use smaller spans for errors involving closure captures Closes #51170 Closes #46599 Error messages involving closures now point to the captured variable/closure args. r? @pnkfelix
2018-08-05Auto merge of #52991 - nikomatsakis:nll-escaping-into-return, r=pnkfelixbors-20/+14
avoid computing liveness for locals that escape into statics Fixes #52713 I poked at this on the plane and I think it's working -- but I want to do a bit more investigation and double check. The idea is to identify those local variables where the entire value will "escape" into the return -- for them, we don't need to compute liveness, since we know that the outlives relations from the return type will force those regions to be equal to free regions. This should help with html5ever in particular. - [x] test performance - [x] verify correctness - [x] add comments r? @pnkfelix cc @lqd
2018-08-04An 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-08-03Update tests for new spans for nll errors involving closuresMatthew Jasper-14/+18
2018-08-03Auto merge of #52948 - davidtwco:issue-52633-later-loop-iteration, r=pnkfelixbors-1/+1
NLL: Better Diagnostic When "Later" means "A Future Loop Iteration" Part of #52663. r? @pnkfelix
2018-08-03update error messages -- in some cases maybe we should investigateNiko Matsakis-20/+14
2018-08-02When we turn on NLL migration in the 2018 edition, we need two-phase borrows ↵Felix S. Klock II-0/+32
too! Fix #52967.
2018-08-01Errors are more specific in cases where borrows are used in future ↵David Wood-1/+1
iterations of loops.
2018-08-01Rollup merge of #52907 - ↵Pietro Albini-20/+31
pnkfelix:issue-52877-original-source-should-precede-suggestions, r=petrochenkov NLL: On "cannot move out of type" error, print original before rewrite NLL: On "cannot move out of type" error, print original source before rewrite. * Arguably this change is sometimes injecting noise into the output (namely in the cases where the suggested rewrite is inline with the suggestion and we end up highlighting the original source code). I would not be opposed to something more aggressive/dynamic, like revising the suggestion code to automatically print the original source when necessary (e.g. when the error does not have a span that includes the span of the suggestion). * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion` says: ```rust /// The message /// /// * should not end in any punctuation (a `:` is added automatically) /// * should not be a question /// * should not contain any parts like "the following", "as shown" ``` * but the `:` is *not* added when the emitted line appears out-of-line relative to the suggestion. I find that to be an unfortunate UI experience. ---- As a drive-by fix, also changed code to combine multiple suggestions for a pattern into a single multipart suggestion (which vastly improves user experience IMO). ---- Includes the updates to expected NLL diagnostics. Fix #52877
2018-07-31NLL: On "cannot move out of type" error, print original source before rewrite.Felix S. Klock II-20/+31
* Arguably this change is sometimes injecting noise into the output (namely in the cases where the suggested rewrite is inline with the suggestion and we end up highlighting the original source code). I would not be opposed to something more aggressive/dynamic, like revising the suggestion code to automatically print the original source when necessary (e.g. when the error does not have a span that includes the span of the suggestion). * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion` says: /// The message /// /// * should not end in any punctuation (a `:` is added automatically) /// * should not be a question /// * should not contain any parts like "the following", "as shown" but the `:` is *not* added when the emitted line appears out-of-line relative to the suggestion. I find that to be an unfortunate UI experience. ---- As a drive-by fix, also changed code to combine multiple suggestions for a pattern into a single multipart suggestion (which vastly improves user experience IMO). ---- Includes the updates to expected NLL diagnostics.
2018-07-31Update tests that use `-Z borrowck=compare` or `#[feature(nll)]` to ↵Felix S. Klock II-25/+25
accmmodate diagnostic change.
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