about summary refs log tree commit diff
path: root/src/test/ui/object-lifetime
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-878/+0
2022-09-03Do not call object_lifetime_default on lifetime params.Camille GILLOT-33/+71
2022-06-03Fully stabilize NLLJack Huey-214/+22
2022-05-22Use revisions for NLL in object-lifetimeJack Huey-35/+67
2022-04-25Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLLmarmeladema-0/+5
2022-03-03Bless nll tests.Camille GILLOT-1/+1
2022-03-03Cleanup feature gates.Camille GILLOT-3/+2
2021-12-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-1/+1
During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2021-12-10Tweak wordingEsteban Kuber-1/+1
2021-12-10Use a more accurate `Span` for `'static` obligation from return typeEsteban Kuber-2/+2
2021-12-10Point at return type when it introduces `'static` obligationEsteban Kuber-0/+8
2021-11-14Move some tests to more reasonable directoriesCaio-0/+276
2021-10-13Remove textual span from diagnostic stringOli Scherer-7/+7
2021-10-05Note specific regions involved in 'borrowed data escapes' errorAaron Hill-2/+7
Fixes #67007 Currently, a 'borrowed data escapes' error does not mention the specific lifetime involved (except indirectly through a suggestion about adding a lifetime bound). We now explain the specific lifetime relationship that failed to hold, which improves otherwise vague error messages.
2021-10-03Don't suggest replacing region with 'static in NLLAaron Hill-6/+0
Fixes #73159 This is similar to #69350 - if the user didn't initially write out a 'static lifetime, adding 'static in response to a lifetime error is usually the wrong thing to do.
2021-09-16Propagate coercion cause into `try_coerce`Aaron Hill-2/+2
Currently, `coerce_inner` discards its `ObligationCause` when calling `try_coerce`. This interfers with other diagnostc improvements I'm working on, since we will lose the original span by the time the actual coercion occurs. Additionally, we now use the span of the trailing expression (rather than the span of the entire function) when performing a coercion in `check_return_expr`. This currently has no visible effect on any of the unit tests, but will unblock future diagnostic improvements.
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-02-02Update ui tests (nll)Jesus Rubio-0/+1
2020-09-02pretty: trim paths of unique symbolsDan Aloni-3/+3
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-07-22Further tweak wording of E0759 and introduce E0767Esteban Küber-2/+2
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-2/+2
2020-06-15small tweaksEsteban Küber-1/+1
2020-06-15Register new eror codeEsteban Küber-1/+2
2020-06-15review comments: wordingEsteban Küber-1/+1
2020-06-15Tweak wording and add error codeEsteban Küber-4/+4
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-2/+2
2020-06-15When `'static` is explicit, suggest constraining argument with itEsteban Küber-1/+1
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-12/+5
2020-05-30Update nll testsEsteban Küber-3/+3
2020-05-30review comment: tweak wording and account for span overlapEsteban Küber-4/+1
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-6/+21
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-27Fix spacing of expected/found notes without a labelEsteban Küber-4/+4
2020-05-12add long error explanation for E0228Jade McGough-0/+4
2019-12-03Include a span in more `expected...found` notesAaron Hill-6/+14
In most places, we use a span when emitting `expected...found` errors. However, there were a couple of places where we didn't use any span, resulting in hard-to-interpret error messages. This commit attaches the relevant span to these notes, and additionally switches over to using `note_expected_found` instead of manually formatting the message
2019-11-21Auto merge of #66389 - estebank:type-err-labels, r=petrochenkovbors-6/+6
Specific labels when referring to "expected" and "found" types
2019-11-18Auto merge of #58281 - mark-i-m:synthesis, r=estebankbors-0/+10
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-6/+6
2019-11-07Update ui testsGuillaume Gomez-1/+2
2019-10-27update testsMark Mansi-0/+10
2019-10-11Print lifetimes with backticksYuki Okushi-7/+7
2019-10-07update ui testsGuillaume Gomez-0/+1
2019-08-19use static as object-lifetime default for type XX in `Foo<Item=XX>`Niko Matsakis-0/+132
Currently the default is "inherited" from context, so e.g. `&impl Foo<Item = dyn Bar>` would default to `&'x impl Foo<Item = dyn Bar + 'x>`, but this triggers an ICE and is not very consistent. This patch doesn't implement what I expect would be the correct semantics, because those are likely too complex. Instead, it handles what I'd expect to be the common case -- where the trait has no lifetime parameters.
2019-06-30Make sure `#[rustc_doc_only_macro]` and other rustc attributes are registeredVadim Petrochenkov-24/+24
2019-06-03Update tests for changes to cannot move errorsMatthew Jasper-2/+2
2019-05-29Update ui test suite to use dynmemoryruins-53/+53
2019-05-12Change compare mode to use -Zborrowck=mirMatthew Jasper-0/+82
2019-04-18hide `--explain` hint if error has no extended infoAndy Russell-4/+1
2019-03-11Update testsVadim Petrochenkov-13/+13
2018-12-25Remove licensesMark Rousskov-106/+36
2018-10-17Update output for borrowck=migrate compare mode.David Wood-82/+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.