about summary refs log tree commit diff
path: root/src/test/ui/nll
AgeCommit message (Collapse)AuthorLines
2018-10-07Auto merge of #54782 - pnkfelix:issue-54556-semi-on-tail-diagnostic, ↵bors-6/+535
r=nikomatsakis NLL: temps in block tail expression diagnostic This change adds a diagnostic that explains when temporaries in a block tail expression live longer than block local variables that they borrow, and attempts to suggest turning the tail expresion into a statement (either by adding a semicolon at the end, when its result value is clearly unused, or by introducing a `let`-binding for the result value and then returning that). Fix #54556
2018-10-06Improve closure region bound errorsMatthew Jasper-75/+54
Now use the category and span that are associated to the most interesting bound that led to the closure bound.
2018-10-05Rollup merge of #54812 - ↵Pietro Albini-0/+42
pnkfelix:issue-32382-index-assoc-type-with-lifetime, r=nikomatsakis Regression test for #32382.
2018-10-05Unit tests for issue #54556. Some were also taken from issues #21114, #46413.Felix S. Klock II-0/+529
2018-10-05Updates to .stderr output in ui tests from earlier changes.Felix S. Klock II-6/+6
2018-10-05Auto merge of #54703 - davidtwco:issue-52086, r=nikomatsakisbors-2/+41
error message when trying to move from an Rc or Arc is ungreat Fixes #52086. r? @nikomatsakis
2018-10-04Auto merge of #54666 - matthewjasper:mir-function-spans, r=pnkfelixbors-44/+39
[NLL] Improve "borrow later used here" messages * In the case of two conflicting borrows, the later used message says which borrow it's referring to * If the later use is a function call (from the users point of view) say that the later use is for the call. Point just to the function. r? @pnkfelix Closes #48643
2018-10-04Regression test for #32382.Felix S. Klock II-0/+42
2018-10-03Rewrite the `UnconditionalRecursion` lint to use MIRWesley Wiser-5/+18
Part of #51002
2018-10-04Auto merge of #54447 - KiChjang:issue-54331, r=nikomatsakisbors-0/+32
Lower type ascriptions to HAIR and MIR Fixes #54331. r? @nikomatsakis
2018-10-03Clearer later use messages for callsMatthew Jasper-44/+39
Give a special message when the later use is from a call. Use the span of the callee instead of the whole expression. For conflicting borrow messages say that the later use is of the first borrow.
2018-10-03Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakisbors-0/+83
NLL fails to suggest "try removing `&mut` here" Fixes #51191. This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already. r? @nikomatsakis
2018-10-02Auto merge of #54343 - blitzerr:master, r=nikomatsakisbors-2/+2
First shot at #54015 Closes #54015
2018-10-02Improve mutability error suggestions.David Wood-15/+24
This commit improves mutability error suggestions by suggesting the removal of `&mut` where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`.
2018-10-02Improve implicit self mutability suggestions.David Wood-0/+74
This commit adds an `ImplicitSelfKind` to the HIR and the MIR that keeps track of whether a implicit self argument is immutable by-value, mutable by-value, immutable reference or mutable reference so that the addition of the `mut` keyword can be suggested for the immutable by-value case.
2018-10-01Add special cases for move from `Rc`/`Arc` errors.David Wood-2/+41
This commit special cases the move out of borrowed content error, previously: ``` error[E0507]: cannot move out of borrowed content --> src/main.rs:7:10 | 7 | drop(x.field); | ^ cannot move out of borrowed content ``` to instead mention that it is a move out of a `Rc`/`Arc` which is more helpful: ``` error[E0507]: cannot move out of an `Rc` --> src/main.rs:7:10 | 7 | drop(x.field); | ^ cannot move out of an `Rc` ```
2018-09-29Add UI test for preserving user types in type ascriptionsKeith Yeung-0/+32
2018-09-28Test fixes for the change of error message for issue #54015Rusty Blitzerr-2/+2
2018-09-28Prefer `#![feature(bind_by_move_pattern_guards)]` over `-Z ↵Felix S. Klock II-1/+1
disable_ast_check_for_mutation_in_guard`
2018-09-27Auto merge of #54468 - matthewjasper:fix-polonius, r=nikomatsakisbors-0/+92
[NLL] Get Polonius borrow check to work in simple cases * Restores the generation of outlives facts from subtyping. * Restore liveness facts. * Generate invalidates facts at the start point of each location, where we check for errors. * Add a small test for simple cases (previously these cases have compiled, and more recently ICEd). Closes #54212 cc #53142 (will need test) ### Known limitations * Two phase borrows aren't implemented for Polonius yet * Invalidation facts haven't been updated for some of the recent changes to make `Drop` terminators access fewer things. * Fact generation is not as optimized as it could be. * Around 30 tests fail in compare mode, often tests that are ignored in nll compare mode r? @nikomatsakis
2018-09-27Auto merge of #54355 - pnkfelix:issue-22323-regression-test, r=davidtwcobors-0/+32
NLL: regression test for "dropck: track order of destruction for r-value temporaries" Once this lands, we can remove the E-needstest from #22323. (We shouldn't close the bug itself, however, because we are leaving the NLL-fixed-by-NLL bugs open until NLL is turned on by default.)
2018-09-26Get Polonius borrow check to work in simple casesMatthew Jasper-0/+92
* Restores the generation of outlives facts from subtyping. * Restore liveness facts. * Generate invalidates facts at the start point of each location, where we check for errors. * Add a small test for simple cases.
2018-09-26pacify the mercilous tidy.Niko Matsakis-3/+15
2018-09-26update tests and add stderr filesNiko Matsakis-81/+72
2018-09-26make NLL handle `IfEq` bounds by using SCC normalizationNiko Matsakis-0/+510
2018-09-26use approx. bounds to decide whether to add outlives obligationsNiko Matsakis-29/+14
Before, if we had a projection like `<T as Foo<'0>>::Bar: 'x` and a where clause like `<T as Foo<'a>>::Bar: 'a`, we considered those to have nothing to do with one another. Therefore, we would use the "overconstrained" path of adding `T: 'x` and `'0: 'x` requirements. We now do a "fuzzy" match where we erase regions first and hence we see the env bound `'a`.
2018-09-25Change the diagnostic number from 714 to 716.Felix S. Klock II-21/+21
2018-09-25add "temporary value dropped while borrowed" errorMikhail Modin-35/+37
Issue #54131
2018-09-24Update ui testsMatthew Jasper-14/+2
2018-09-24Add tests for new match borrowsMatthew Jasper-0/+413
2018-09-23Rework checking for borrows conflicting with dropsMatthew Jasper-0/+96
Previously, we would split the drop access into multiple checks for each field of a struct/tuple/closure and through `Box` dereferences. This changes this to check if the borrow is accessed by the drop in places_conflict. This also allows us to handle enums in a simpler way, since we don't have to construct any new places.
2018-09-23Only annotate if borrow is returned.David Wood-20/+60
Error now correctly checks whether the borrow that does not live long enough is being returned before annotating the error with the arguments and return type from the signature - as this would not be relevant if the borrow was not being returned.
2018-09-23Correctly handle named lifetimes.David Wood-10/+103
Enhances annotation logic to properly consider named lifetimes where lifetime elision rules that were previously implemented would not apply. Further, adds new help and note messages to diagnostics and highlights only lifetime when dealing with named lifetimes.
2018-09-23Added note about dangling references.David Wood-0/+18
This error can only occur within a function when a borrow of data owned within the function is returned; and when there are arguments that could have been returned instead. Therefore, it is always applicable to add a specific note that links to the relevant rust documentation about dangling references.
2018-09-23Fixed off-by-one span.David Wood-6/+6
Fixes the off-by-one span issue where closure argument spans were pointing to the token after the argument.
2018-09-23Added multiple parameter closure test.David Wood-2/+20
New test has multiple parameters in a closure with longer names in order to clarify the issues relating to odd spans.
2018-09-23Improve 'dropped here' note.David Wood-5/+5
Start mentioning function name that the variable is valid within in notes to provide context.
2018-09-23Improve borrow errors for closures.David Wood-8/+134
Adds improved messages for closures where returned type does not match the inferred return lifetime of the closure.
2018-09-23Auto merge of #54310 - pnkfelix:issue-52059-report-borrow-drop-conflict, ↵bors-6/+100
r=nikomatsakis Report when borrow could cause `&mut` aliasing during Drop We were already issuing an error for the cases where this cropped up, so this is not fixing any soundness holes. The previous diagnostic just wasn't accurately describing the problem in the user's code. Fix #52059
2018-09-23Auto merge of #54262 - matthewjasper:explain-in-typeck, r=nikomatsakisbors-89/+160
[NLL] Record more infomation on free region constraints in typeck Changes: * Makes the span of the MIR return place point to the return type * Don't try to use a path to a type alias as a path to the adt it aliases (fixes an ICE) * Don't claim that `self` is declared outside of the function. [see this test](https://github.com/rust-lang/rust/commit/f2995d5b1ad0401a80ac4579ebc89295818c3eed#diff-0c9e6b1b204f42129b481df9ce459d44) * Remove boring/interesting distinction and instead add a `ConstraintCategory` to the constraint. * Add categories for implicit `Sized` and `Copy` requirements, for closure bounds, for user type annotations and `impl Trait`. * Don't use the span of the first statement for Locations::All bounds (even if it happens to work on the tests we have) Future work: * Fine tuning the heuristic used to choose the place the report the error. * Reporting multiple places (behind a flag) * Better closure bounds reporting. This probably requires some discussion. r? @nikomatsakis
2018-09-20Rollup merge of #54367 - spastorino:add-thread-local-static-borrow-test, ↵kennytm-0/+35
r=pnkfelix Add regression test for thread local static mut borrows FIXME(#54366) - We probably shouldn't allow `#[thread_local] static mut` to get a `'static` lifetime, but for now, we should at least test the behavior that `rustc` currently has.
2018-09-20Auto merge of #54255 - spastorino:use-of-moved-value-error, r=nikomatsakisbors-0/+71
Inspect parents paths when checking for moves Closes #52669
2018-09-19Add regression test for thread local static mut borrowsSantiago Pastorino-0/+35
2018-09-19Update ui testsMatthew Jasper-89/+105
2018-09-19Don't try to use a path to a type alias as a path to the adt it aliasesMatthew Jasper-0/+55
2018-09-19Regression test for rust-lang/rust#22323.Felix S. Klock II-0/+32
2018-09-18De-duplicate moved variable errors.David Wood-0/+49
By introducing a new map that tracks the errors reported and the `Place`s that spawned those errors against the move out that the error was referring to, we are able to silence duplicate errors by emitting only the error which corresponds to the most specific `Place` (that which other `Place`s which reported errors are prefixes of). This generally is an improvement, however there is a case - `liveness-move-in-while` - where the output regresses.
2018-09-18Regression test for this particular change.Felix S. Klock II-0/+94
2018-09-18Updates to tests reflecting the diangostic changes in previous commit.Felix S. Klock II-6/+6
It is worth pointing out that the reason that so few diagnostics are effected is because of the filter I put in where it only goes down the new path if the borrowed place is *not* a prefix of the dropped place. (Without that filter, a *lot* of the tests would need this change, and it would probably be a net loss for the UX, since you'd see it even in cases like borrows of generic types where there is no explicit mention of `Drop`.)
2018-09-17Inspect parents paths when checking for movesSantiago Pastorino-0/+71