summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2018-09-16Auto merge of #54157 - euclio:structured-suggestion, r=estebankbors-43/+43
use structured suggestion for "missing mut" label Fixes #54133 for both NLL and non-NLL. r? @estebank I'm not super happy with the existing wording here, since it's now a suggestion. I wonder if the message would work better as something like "help: make binding mutable: `mut foo`"? Also, are the `HELP` and `SUGGESTION` comments necessary?
2018-09-12use structured suggestion for "missing mut" labelAndy Russell-43/+43
Fixes #54133.
2018-09-09Suggest a let binding to extend temporary lifetimes with NLLMatthew Jasper-0/+3
2018-09-08Rollup merge of #53932 - matthewjasper:remove-base-path, r=nikomatsakiskennytm-24/+14
[NLL] Remove base_place This function was supposed to make `Box` less special. But * I think that the consensus is that MIR borrowck is going to fully special case `Box` * It wasn't implemented correctly, it's looking at the type of the wrong `Place`, resulting in weird behaviour: ```rust #![feature(nll)] type A = Box<i32>; // If this is changed to another type then this will compile. pub fn foo(x: Box<(String, A)>) { let a = x.0; // This will compile if these lines are swapped let b = x.1; } ``` r? @nikomatsakis
2018-09-07Auto merge of #54021 - kennytm:rollup, r=kennytmbors-0/+692
Rollup of 17 pull requests Successful merges: - #53299 (Updated core/macros.rs to note it works in a no_std environment.) - #53376 (Cross reference io::copy and fs::copy in docs.) - #53455 (Individual docs for {from,to}_*_bytes) - #53550 (librustc_lint: In recursion warning, change 'recurring' to 'recursing') - #53860 (Migrate (some) of run-pass/ to ui) - #53874 (Implement Unpin for Box, Rc, and Arc) - #53895 (tidy: Cleanups and clippy warning fixes) - #53946 (Clarify `ManuallyDrop` docs) - #53948 (Minimized clippy test from when NLL disabled two-phase borrows) - #53959 (Add .git extension to submodule paths missing it) - #53966 (A few cleanups and minor improvements to mir/dataflow) - #53967 (propagate build.python into cmake) - #53979 (Remove `#[repr(transparent)]` from atomics) - #53991 (Add unchecked_shl/shr check for intrinsics to fix miri's test suit) - #53992 (migrate run-pass/borrowck to ui/run-pass) - #53994 (migrate run-pass/*/ to ui/run-pass) - #54023 (update clippy submodule)
2018-09-07Auto merge of #53830 - davidtwco:issue-53228, r=nikomatsakisbors-0/+44
Add help message for missing IndexMut impl with NLL Fixes #53228. r? @nikomatsakis
2018-09-04Minimized (and then greatly expanded) test of failure cases from ↵Felix S. Klock II-0/+692
rust-lang/rust#52934.
2018-09-03remove base_placeMatthew Jasper-24/+14
2018-09-03Auto merge of #53865 - zilbuz:issue-52768, r=pnkfelixbors-38/+1
Remove 'not reporting regions error due to nll' warning Fix #52768
2018-09-01Update testsBasile Desloges-38/+1
2018-08-31Restrict most uses of `const_fn` to `min_const_fn`Oliver Schneider-1/+1
2018-08-31Omit 'missing IndexMut impl' suggestion when IndexMut is implemented.David Wood-0/+40
2018-08-30Added help message for missing IndexMut impl.David Wood-0/+4
2018-08-21Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkorkennytm-1/+1
Fix typos found by codespell.
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-08-19move tests to borrowck directory, remove feature(nll)Niko Matsakis-0/+361
now compare-mode can show us the differences
2018-08-18Auto merge of #53175 - matthewjasper:more-return-stuff, r=nikomatsakisbors-4/+4
[NLL] Returns are interesting for free regions Based on #53088 - creating now to get feedback. Closes #51175 * Make assigning to the return type interesting. * Use "returning this value" instead of "return" in error messages. * Prefer one of the explanations that we have a name for to a generic interesting cause in some cases. * Treat causes that involve the destination of a call like assignments.
2018-08-17Auto merge of #53369 - ↵bors-125/+573
pnkfelix:partial-53351-make-some-ported-compile-fail-tests-more-robust-wrt-nll, r=davidtwco Make some ported cfail tests robust w.r.t. NLL Updated the most glaring instances of weak tests w.r.t. NLL that came from #53196. See also the bulletpoint list on #53351.
2018-08-17Rollup merge of #53413 - eddyb:featured-in-the-latest-edition, r=varkorCorey Farwell-3/+3
Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018. cc @varkor @petrochenkov @joshtriplett
2018-08-17Rollup merge of #53407 - ↵Corey Farwell-18/+183
pnkfelix:partial-53351-make-more-ported-compile-fail-tests-more-robust-wrt-nll, r=nikomatsakis make more ported compile fail tests more robust w.r.t. NLL This is similar to PR #53369, except it covers a disjoint (and much smaller) set of tests that I needed to look at more carefully before being 100% certain they were the same kind of issue.
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.