about summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2019-11-25Auto merge of #66682 - estebank:fn-type-err, r=davidtwcobors-2/+2
Highlight parts of fn in type errors When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each. Examples: <img width="699" alt="" src="https://user-images.githubusercontent.com/1606434/69487597-ab561600-0e11-11ea-9b4e-d4fd9e91d5dc.png"> <img width="528" alt="" src="https://user-images.githubusercontent.com/1606434/69487207-9033d800-0e0a-11ea-93e3-8c4d002411a5.png"> <img width="468" alt="" src="https://user-images.githubusercontent.com/1606434/69487208-9033d800-0e0a-11ea-92e3-2b2cee120335.png"> <img width="775" alt="" src="https://user-images.githubusercontent.com/1606434/69487209-9033d800-0e0a-11ea-9e68-7f6ed5c8cb08.png">
2019-11-23Highlight parts of fn in type errorsEsteban Küber-2/+2
When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each.
2019-11-21Reorganize, bless and add tests for const control flowDylan MacKenzie-2/+4
This creates a new test directory, `ui/consts/control-flow` to hold tests related to control flow in a const context. It also blesses all existing tests with the new error messages, and adds new tests for the `const_if_match` feature.
2019-11-21Auto merge of #66389 - estebank:type-err-labels, r=petrochenkovbors-2/+2
Specific labels when referring to "expected" and "found" types
2019-11-21Remove `#![feature(never_type)]` from tests.Mazdak Farrokhzad-2/+0
Also remove `never_type` the feature-gate test.
2019-11-19Rollup merge of #66155 - GuillaumeGomez:long-err-explanation-E0594, r=Dylan-DPCMazdak Farrokhzad-14/+29
Add long error explanation for E0594 Part of #61137. r? @Dylan-DPC
2019-11-18Auto merge of #58281 - mark-i-m:synthesis, r=estebankbors-0/+2
Add outlives suggestions for some lifetime errors This PR implements suggestion diagnostics for some lifetime mismatch errors. When the borrow checker finds that some lifetime 'a doesn't outlive some other lifetime 'b that it should outlive, then in addition to the current lifetime error, we also emit a suggestion for how to fix the problem by adding a bound: - If a and b are normal named regions, suggest to add the bound `'a: 'b` - If b is static, suggest to replace a with static - If b also needs to outlive a, they must be the same, so suggest unifying them We start with a simpler implementation that avoids diagnostic regression or implementation complexity: - We only makes suggestions for lifetimes the user can already name (eg not closure regions or elided regions) - For now, we only emit a help note, not an actually suggestion because it is significantly easier. Finally, there is one hack: it seems that implicit regions in async fn are given the name '_ incorrectly. To avoid suggesting '_: 'x, we simply filter out such lifetimes by name. For more info, see this internals thread: https://internals.rust-lang.org/t/mechanical-suggestions-for-some-borrow-checker-errors/9049/3 TL;DR Make suggestions to add a `where 'a: 'b` constraint for some lifetime errors. Details are in the paper linked from the internals thread above. r? @estebank TODO - [x] Clean up code - [x] Only make idiomatic suggestions - [x] don't suggest naming `&'a self` - [x] rather than `'a: 'static`, suggest replacing `'a` with `'static` - [x] rather than `'a: 'b, 'b: 'a`, suggest replacing `'a` with `'b` or vice versa - [x] Performance (maybe need a perf run when this is closer to the finish line?) - perf run was clean... - EDIT: perf run seems to only check non-error performance... How do we check that error performance didn't regress? - [x] Needs ui tests - [x] Integrate the `help` message into the main lifetime `error`
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-2/+2
2019-11-18Update ui testsGuillaume Gomez-14/+29
2019-11-13Bless const tests with improved diagnosticsDylan MacKenzie-30/+4
2019-11-13Rollup merge of #66186 - GuillaumeGomez:long-err-explanation-E0623, r=Dylan-DPCYuki Okushi-0/+1
Add long error explanation for E0623 Part of #61137. r? @Dylan-DPC
2019-11-11Evaluate borrow and struct expressions in `into`Matthew Jasper-2/+2
This fixes some ordering problems around assignment expressions.
2019-11-11Fix soundness issue with index bounds checksMatthew Jasper-0/+117
An expression like `x[1][{ x = y; 2}]` would perform the bounds check for the inner index operation before evaluating the outer index. This would allow out of bounds memory accesses.
2019-11-07Update ui testsGuillaume Gomez-0/+1
2019-11-04Use check-pass in ui tests where appropriateTomasz Miąsko-1/+1
2019-10-27update testsMark Mansi-0/+2
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+2
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-11Print lifetimes with backticksYuki Okushi-2/+2
2019-10-04Rollup merge of #64749 - matthewjasper:liveness-opt, r=nikomatsakisMazdak Farrokhzad-239/+0
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-02Calculate liveness for the same locals with and without -ZpoloniusMatthew Jasper-239/+0
This fixes some test differences and also avoids overflow in issue-38591.rs.
2019-10-01regression test for 64453 borrow check error.Felix S. Klock II-0/+58
2019-09-26add test for #53432.Mazdak Farrokhzad-0/+22
2019-09-26Adjust & --bless tests due to no longer downgrading NLL errors on 2015.Mazdak Farrokhzad-509/+20
2019-09-25Rollup merge of #64428 - GuillaumeGomez:error-explanation-E0524, r=CentrilMazdak Farrokhzad-9/+8
Error explanation e0524 Part of https://github.com/rust-lang/rust/issues/61137
2019-09-21update ui testsGuillaume Gomez-9/+8
2019-09-19Rollup merge of #64601 - grovesNL:two-backticks, r=jonas-schievinkMazdak Farrokhzad-1/+1
Fix backticks in documentation Fix a few typos in comments/documentation where backticks were doubled-up on one side.
2019-09-18Fix backticks in documentationJoshua Groves-1/+1
2019-09-17Bless output of test borrowck/return-local-binding-from-desugaring.rs for ↵lqd-0/+16
Polonius
2019-09-09Auto merge of #63118 - Centril:stabilize-bind-by-move, r=matthewjasperbors-29/+5
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-08Update test stderr with results of enabling unused lintsMark Rousskov-4/+4
2019-09-08Update tests wrt. bind_by_by_move_pattern_guards stabilization.Mazdak Farrokhzad-29/+5
2019-09-06Rollup merge of #64202 - alexreg:rush-pr-1, r=CentrilMazdak Farrokhzad-181/+181
Fixed grammar/style in some error messages Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-06Refuse to downgrade NLL errors on Rust >= 2018.Mazdak Farrokhzad-10/+11
2019-09-06Fixed grammar/style in error messages and reblessed tests.Alexander Regueiro-181/+181
2019-08-24Don't unwrap the result of `span_to_snippet`Matthew Jasper-0/+45
It can return `Err` due to macros being expanded across crates or files.
2019-08-06Rollup merge of #63230 - tmandry:disallow-possibly-uninitialized, r=CentrilMazdak Farrokhzad-0/+49
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-05Make use of possibly uninitialized data a hard errorTyler Mandry-0/+49
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-07-30Add tests for #27282, #31287 as hard errors.Mazdak Farrokhzad-0/+50
2019-07-30borrowck-migrate-to-nll: use #38899 for testing.Mazdak Farrokhzad-30/+32
2019-07-30borrowck-mutate-in-guard: update test.Mazdak Farrokhzad-61/+8
2019-07-28Rollup merge of #63051 - estebank:borrow-ice, r=matthewjasperMazdak Farrokhzad-0/+45
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-28borrowck-describe-lvalue: --bless --compare-mode=nll.Mazdak Farrokhzad-8/+8
2019-07-28--bless tests due to new subslice syntax.Mazdak Farrokhzad-22/+22
2019-07-28Use new 'p @ ..' syntax in tests.Mazdak Farrokhzad-20/+20
2019-07-27review commentsEsteban Küber-19/+34
2019-07-27Avoid ICE when referencing desugared local binding in borrow errorEsteban Küber-0/+30
2019-07-27tests: Move run-pass tests with naming conflicts to uiVadim Petrochenkov-0/+341
2019-07-27tests: Move run-pass tests without naming conflicts to uiVadim Petrochenkov-0/+709
2019-07-22Bless output of test borrowck/promote-ref-mut-in-let-issue-46557.rs for ↵lqd-0/+59
Polonius
2019-07-22Bless output of test borrowck/two-phase-surprise-no-conflict.rs for Poloniuslqd-0/+148