about summary refs log tree commit diff
path: root/src/test/ui/lifetimes/lifetime-errors
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1035/+0
2023-01-01Verbose suggestionsEsteban Küber-4/+10
2022-09-26address reviewb-naber-1/+1
2022-07-25Report elision failures on the AST.Camille GILLOT-1/+1
2022-06-21Always create parameters for functions-like types.Camille GILLOT-2/+2
2022-06-16 fix one more case of trailing spaceklensy-4/+4
2022-06-11ValuePairs::PolyTraitRefs should be called 'trait'Michael Goulet-2/+2
2022-06-03Fully stabilize NLLJack Huey-610/+68
2022-05-22Use revisions for NLL in lifetimesJack Huey-93/+267
2022-04-30Bless nll tests.Camille GILLOT-2/+5
2022-04-27Recover suggestions to introduce named lifetime under NLLmarmeladema-0/+45
2022-04-24Bless testsmarmeladema-3/+3
2022-03-01update (bless) test resultsFausto-3/+3
2022-02-28Suggest adding a new lifetime parameter when two elided lifetimes should ↵Fausto-0/+18
match up for traits and impls. Issue #94462
2021-11-03Add beginner friendly lifetime elision hint to E0623Nilstrieb-0/+36
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't Issue #90170 This also changes the tests introduced by the previous commits because of another rustc issue (#90258)
2021-09-30Auto merge of #89110 - Aaron1011:adjustment-span, r=estebankbors-16/+16
Use larger span for adjustment THIR expressions Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions. These spans are recoded when we first create the adjustment during typecheck. For example, an autoref adjustment triggered by a method call will record the span of the entire method call. The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-27Improve cause information for NLL higher-ranked errorsAaron Hill-0/+5
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-25Use larger span for adjustments on method callsAaron Hill-16/+16
Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-06Add regression test for #74400Bram van den Heuvel-0/+54
2021-08-18Use more accurate spans when proposing adding lifetime to itemEsteban Kuber-1/+1
2021-08-11Modify structured suggestion outputEsteban Küber-1/+1
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-04-12Compiler error messages: reduce assertiveness of message E0384James Addison-5/+5
This message is emitted as guidance by the compiler when a developer attempts to reassign a value to an immutable variable. Following the message will always currently work, but it may not always be the best course of action; following the 'consider ...' messaging pattern provides a hint to the developer that it could be wise to explore other alternatives.
2021-01-07Reintroduce hir::ExprKind::IfCaio-3/+3
2020-09-02pretty: trim paths of unique symbolsDan Aloni-2/+2
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-03-12update testsMark Mansi-5/+5
2020-02-22update some testsMark Mansi-5/+5
2020-02-05Account for `fn()` types in lifetime suggestionsEsteban Küber-6/+2
2020-02-05review commentsEsteban Küber-1/+1
2020-02-05Suggest `'r` instead of `'lifetime`Esteban Küber-2/+2
2020-02-05When suggesting lifetimes, propose adding the new lifetime to all argumentsEsteban Küber-2/+2
2020-02-05Use spans for input borrowed types unrelated to return typeEsteban Küber-1/+5
2020-01-19review commentsEsteban Küber-1/+1
2020-01-19When encountering an expected named lifetime and none are present, suggest ↵Esteban Küber-1/+5
adding one
2019-11-18Auto merge of #58281 - mark-i-m:synthesis, r=estebankbors-0/+12
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-07Update ui testsGuillaume Gomez-0/+25
2019-10-27update testsMark Mansi-0/+12
2019-09-12update testsMark Mansi-3/+3
2019-06-13Create fewer basic blocks in match MIR loweringMatthew Jasper-3/+3
2019-05-29Update ui test suite to use dynmemoryruins-9/+9
2019-05-12Change compare mode to use -Zborrowck=mirMatthew Jasper-0/+379
2019-05-03Update testsChristopher Vittal-52/+14
2019-04-25Rollup merge of #60160 - xldenis:fix-overlapping-zero-width-annotation, ↵Mazdak Farrokhzad-3/+1
r=estebank Fix #58270, fix off-by-one error in error diagnostics. This fixes #58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.
2019-04-22Fix #58270, fix off-by-one error in error diagnostics.Xavier Denis-3/+1
2019-04-22Remove double trailing newlinesvarkor-3/+0
2019-04-18hide `--explain` hint if error has no extended infoAndy Russell-25/+0
2019-03-11Update testsVadim Petrochenkov-47/+47
2018-12-25Remove licensesMark Rousskov-406/+45
2018-10-17Update output for borrowck=migrate compare mode.David Wood-379/+0
This commit updates the test output for the updated NLL compare mode that uses `-Z borrowck=migrate` rather than `-Z borrowck=mir`. The previous commit changes `compiletest` and this commit only updates `.nll.stderr` files.
2018-10-15Deduplicate testsShotaro Yamada-45/+0
* `ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4` and `ex3-both-anon-regions-both-are-structs-3` * `ui/lint/lint-group-style` and `lint-group-nonstandard-style`
2018-09-19Update ui testsMatthew Jasper-8/+8