about summary refs log tree commit diff
path: root/src/test/ui/nll
AgeCommit message (Collapse)AuthorLines
2020-02-06don't mention specific region numbers in the ~ERROR messageNiko Matsakis-2/+2
2020-02-03Tweak borrow error on `FnMut` when `Fn` is expectedEsteban Küber-60/+60
2020-02-02Add a resume type parameter to `Generator`Jonas Schievink-1/+1
2020-01-31Auto merge of #68080 - varkor:declared-here, r=petrochenkovbors-5/+5
Address inconsistency in using "is" with "declared here" "is" was generally used for NLL diagnostics, but not other diagnostics. Using "is" makes the diagnostics sound more natural and readable, so it seems sensible to commit to them throughout. r? @Centril
2020-01-25Use better bound names in `-Zverbose` modeEsteban Küber-16/+16
2020-01-24Normalise notes with the/isvarkor-3/+3
2020-01-24Normalise diagnostics with respect to "the X is declared/defined here"varkor-2/+2
2020-01-23Use check-pass mode for nll testsTomasz Miąsko-15/+15
2020-01-12Diagnostics should start lowercasevarkor-99/+99
2020-01-02Use drop instead of the toilet closure `|_| ()`Lzu Tao-1/+1
2019-12-06add subset relations test using poloniusRemy Rakic-0/+44
It's a relatively simple smoke-test for subset errors, executed outside of the polonius compare-mode.
2019-12-06bless polonius output due to lacking the 'static special-casingRemy Rakic-0/+60
2019-12-06bless polonius output of test ui/nll/outlives-suggestion-simple.rsRemy Rakic-0/+121
The polonius output has one more error which should be displayed in the regular case, but error reporting in the regular case stopped at the first error. Admittedly it would be nice to combine suggestions for the same source lifetime so that `'a: 'b` and `'a: 'c` are not bothsuggested, but instead a single `'a: 'b + 'c` is.
2019-12-06Auto merge of #66911 - eddyb:nicer-rustc_regions, r=matthewjasperbors-307/+99
rustc_mir: use nicer path printing for #[rustc_regions] NLL tests. Similar to #66850, spotted while working on #66907. r? @matthewjasper
2019-12-03Include a span in more `expected...found` notesAaron Hill-24/+56
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-30rustc_mir: use nicer path printing for #[rustc_regions] NLL tests.Eduard-Mihai Burtescu-307/+99
2019-11-30rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.Eduard-Mihai Burtescu-20/+20
2019-11-25Tweak move error due to non-CopyEsteban Küber-12/+2
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-19Rollup merge of #66155 - GuillaumeGomez:long-err-explanation-E0594, r=Dylan-DPCMazdak Farrokhzad-2/+8
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/+451
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-2/+8
2019-11-11Evaluate borrow and struct expressions in `into`Matthew Jasper-2/+2
This fixes some ordering problems around assignment expressions.
2019-11-07Rollup merge of #66087 - tmiasko:ui-mode, r=CentrilMazdak Farrokhzad-25/+25
Update some build-pass ui tests to use check-pass where applicable Helps with issue https://github.com/rust-lang/rust/issues/62277.
2019-11-05rustc: remove "GlobalMetaData" dead code from hir::map::definitions.Eduard-Mihai Burtescu-104/+104
2019-11-04Use check-pass in ui tests where appropriateTomasz Miąsko-25/+25
2019-10-27update testsMark Mansi-183/+95
2019-10-27add test for complex suggestionsMark Mansi-0/+128
2019-10-27implement outlive suggestionsMark Mansi-0/+411
2019-10-26Rollup merge of #65773 - estebank:sugg-whitespace, r=CentrilMazdak Farrokhzad-0/+1
Increase spacing for suggestions in diagnostics Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages. r? @Centril
2019-10-24Fix more `ReEmpty` ICEsMatthew Jasper-2/+20
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+1
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-14Rollup merge of #65292 - JohnTitor:add-backticks, r=varkor,CentrilMazdak Farrokhzad-15/+15
Print lifetimes with backticks Fixes #65287 r? @varkor
2019-10-13Auto merge of #65099 - pnkfelix:issue-63154-needed-more-normalize, r=nagisabors-0/+34
MIR typeck needed more normalize Add some missing normalization calls (@nagisa [was right](https://github.com/rust-lang/rust/issues/63154#issuecomment-517305589)). Fix #63154
2019-10-11Print lifetimes with backticksYuki Okushi-15/+15
2019-10-07update ui testsGuillaume Gomez-0/+5
2019-10-07Update src/test/ui/nll/issue-63154-normalize.rs Felix S Klock II-1/+1
review feedback Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-10-04Regression test for #63154.Felix S. Klock II-0/+34
2019-10-04Rollup merge of #64749 - matthewjasper:liveness-opt, r=nikomatsakisMazdak Farrokhzad-32/+15
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-02Make lifetimes in constants live at the point of useMatthew Jasper-0/+8
2019-10-02Calculate liveness for the same locals with and without -ZpoloniusMatthew Jasper-32/+7
This fixes some test differences and also avoids overflow in issue-38591.rs.
2019-10-01Improve HRTB error span when -Zno-leak-check is usedAaron Hill-0/+42
As described in #57374, NLL currently produces unhelpful higher-ranked trait bound (HRTB) errors when '-Zno-leak-check' is enabled. This PR tackles one half of this issue - making the error message point at the proper span. The error message itself is still the very generic "higher-ranked subtype error", but this can be improved in a follow-up PR. The root cause of the bad spans lies in how NLL attempts to compute the 'blamed' region, for which it will retrieve a span for. Consider the following code, which (correctly) does not compile: ```rust let my_val: u8 = 25; let a: &u8 = &my_val; let b = a; let c = b; let d: &'static u8 = c; ``` This will cause NLL to generate the following subtype constraints: d :< c c :< b b <: a Since normal Rust lifetimes are covariant, this results in the following region constraints (I'm using 'd to denote the lifetime of 'd', 'c to denote the lifetime of 'c, etc.): 'c: 'd 'b: 'c 'a: 'b From this, we can derive that 'a: 'd holds, which implies that 'a: 'static must hold. However, this is not the case, since 'a refers to 'my_val', which does not outlive the current function. When NLL attempts to infer regions for this code, it will see that the region 'a has grown 'too large' - it will be inferred to outlive 'static, despite the fact that is not declared as outliving 'static We can find the region responsible, 'd, by starting at the *end* of the 'constraint chain' we generated above. This works because for normal (non-higher-ranked) lifetimes, we generally build up a 'chain' of lifetime constraints *away* from the original variable/lifetime. That is, our original lifetime 'a is required to outlive progressively more regions. If it ends up living for too long, we can look at the 'end' of this chain to determine the 'most recent' usage that caused the lifetime to grow too large. However, this logic does not work correctly when higher-ranked trait bounds (HRTBs) come into play. This is because HRTBs have *contravariance* with respect to their bound regions. For example, this code snippet compiles: ```rust let a: for<'a> fn(&'a ()) = |_| {}; let b: fn(&'static ()) = a; ``` Here, we require that 'a' is a subtype of 'b'. Because of contravariance, we end up with the region constraint 'static: 'a, *not* 'a: 'static This means that our 'constraint chains' grow in the opposite direction of 'normal lifetime' constraint chains. As we introduce subtypes, our lifetime ends up being outlived by other lifetimes, rather than outliving other lifetimes. Therefore, starting at the end of the 'constraint chain' will cause us to 'blame' a lifetime close to the original definition of a variable, instead of close to where the bad lifetime constraint is introduced. This PR improves how we select the region to blame for 'too large' universal lifetimes, when bound lifetimes are involved. If the region we're checking is a 'placeholder' region (e.g. the region 'a' in for<'a>, or the implicit region in fn(&())), we start traversing the constraint chain from the beginning, rather than the end. There are two (maybe more) different ways we generate region constraints for NLL: requirements generated from trait queries, and requirements generated from MIR subtype constraints. While the former always use explicit placeholder regions, the latter is more tricky. In order to implement contravariance for HRTBs, TypeRelating replaces placeholder regions with existential regions. This requires us to keep track of whether or not an existential region was originally a placeholder region. When we look for a region to blame, we check if our starting region is either a placeholder region or is an existential region created from a placeholder region. If so, we start iterating from the beginning of the constraint chain, rather than the end.
2019-09-26remove feature(nll) in more cases.Mazdak Farrokhzad-62/+41
2019-09-26remove feature(nll) from #27868 test.Mazdak Farrokhzad-3/+1
2019-09-26remove feature(nll) from #31567 test.Mazdak Farrokhzad-3/+1
2019-09-26Adjust & --bless tests due to no longer downgrading NLL errors on 2015.Mazdak Farrokhzad-3/+1
2019-09-25Rollup merge of #64428 - GuillaumeGomez:error-explanation-E0524, r=CentrilMazdak Farrokhzad-1/+1
Error explanation e0524 Part of https://github.com/rust-lang/rust/issues/61137
2019-09-21update ui testsGuillaume Gomez-1/+1
2019-09-12update ui testsGuillaume Gomez-0/+5