about summary refs log tree commit diff
path: root/src/test/ui/borrowck
AgeCommit message (Collapse)AuthorLines
2022-10-27Erase regions from CallArgument, add test + blessMichael Goulet-0/+66
2022-10-25Rollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillotYuki Okushi-0/+28
Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait` The issue here is that when we have: ``` trait Trait<'a> { .. } fn foo(arg: impl Trait) { .. } ``` The anonymous lifetime `'_` that we generate for `arg: impl Trait` doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty. Fixes #101660 r? ``@cjgillot``
2022-10-23Rollup merge of #103305 - c410-f3r:moar-errors, r=petrochenkovDylan DPC-0/+30
Move some tests to more reasonable places r? `@petrochenkov`
2022-10-22Don't ICE on regions from anonymous_lifetime_in_impl_traitMichael Goulet-0/+28
2022-10-20Move some tests for more reasonable placesCaio-0/+30
2022-10-19Erase regions before checking for default in uninitialized binding errorMichael Goulet-0/+54
2022-10-16Auto merge of #102080 - yanchen4791:issue-99824-fix, r=cjgillotbors-2/+8
Fix missing explanation of where the borrowed reference is used when the same borrow occurs multiple times due to loop iterations Fix #99824. Problem of the issue: If a borrow occurs in a loop, the borrowed reference could be invalidated at the same place at next iteration of the loop. When this happens, the point where the borrow occurs is the same as the intervening point that might invalidate the reference in the loop. This causes a problem for the current code finding the point where the resulting reference is used, so that the explanation of the cause will be missing. As the second point of "explain all errors in terms of three points" (see [leveraging intuition framing errors in terms of points"](https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points), this explanation is very helpful for user to understand the error. In the current implementation, the searching region for finding the location where the borrowed reference is used is limited to between the place where the borrow occurs and the place where the reference is invalidated. If those two places happen to be the same, which indicates that the borrow and invalidation occur at the same place in a loop, the search will fail. One solution to the problem is when these two places are the same, find the terminator of the loop, and then use the location of the loop terminator instead of the location of the borrow for the region to find the place where the borrowed reference is used.
2022-10-13Move some tests to more reasonable directoriesCaio-0/+19
2022-10-07make const_err a hard errorRalf Jung-63/+15
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-6/+6
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01bless ui testsMaybe Waffle-6/+6
2022-09-29Generate synthetic impl region even in closure body in associated fnMichael Goulet-0/+50
2022-09-28Fix missing explanation of where borrowed reference is used when the borrow ↵Yan Chen-2/+8
occurs in loop iteration
2022-09-26Auto merge of #102184 - chenyukang:fix-102087-add-binding-sugg, r=nagisabors-0/+361
Suggest Default::default() when binding isn't initialized Fixes #102087
2022-09-26fix #102087, Suggest Default::default() when binding isn't initializedyukang-0/+361
2022-09-25Rollup merge of #101431 - compiler-errors:move-place-ty-for-move-place-sugg, ↵fee1-dead-0/+50
r=cjgillot Look at move place's type when suggesting mutable reborrow Not sure why we are looking at the use site's ty instead of the move site's ty in order to suggest reborrowing the move site, but it was suppressing a perfectly valid reborrow suggestion. r? `@estebank` who i think touched this last in 520461f1fb2730f8edb17922f3bcc74fccdc52d3, though that was quite a while ago so feel free to reassign.
2022-09-06Shrink span for bindings with subpatterns.Camille GILLOT-61/+61
2022-09-05Look at move place's type when suggesting mutable reborrowMichael Goulet-0/+50
2022-09-05Don't suggest reborrow if usage is inside a closureMichael Goulet-0/+31
2022-09-01do not suggest adding `move` to closure when `move` is already usedTakayuki Maeda-0/+26
2022-08-31Fix a bunch of typoDezhi Wu-3/+3
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-25Provide structured suggestion for `hashmap[idx] = val`Esteban Küber-7/+16
2022-08-23Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexingChayim Refael Friedman-0/+3
The error can be quite confusing to newcomers.
2022-08-20Rollup merge of #100507 - cameron1024:suggest-lazy, r=compiler-errorsMatthias Krüger-0/+1
suggest `once_cell::Lazy` for non-const statics Addresses https://github.com/rust-lang/rust/issues/100410 Some questions: - removing the `if` seems to include too many cases (e.g. calls to non-const functions inside a `const fn`), but this code excludes the following case: ```rust const FOO: Foo = non_const_fn(); ``` Should we suggest `once_cell` in this case as well? - The original issue mentions suggesting `AtomicI32` instead of `Mutex<i32>`, should this PR address that as well?
2022-08-20Rollup merge of #100186 - compiler-errors:or-as_mut, r=fee1-deadMatthias Krüger-4/+1
Mention `as_mut` alongside `as_ref` in borrowck error message Kinda fixes #99426 but I guess that really might be better staying open to see if we could make it suggest `as_mut` in a structured way. Not sure how to change borrowck to know that info tho.
2022-08-16Make as_ref suggestion a noteMichael Goulet-4/+1
2022-08-15Fix #95079 by adding help and suggestion for missing move in nested closureYan Chen-0/+59
2022-08-14suggest lazy-static for non-const staticscameron-0/+1
2022-08-14Suggest as_ref or as_mutMichael Goulet-1/+1
2022-08-03fix trailing whitespace in error messageklensy-1/+1
2022-07-31Improve `cannot move out of` error messageObei Sideg-2/+2
2022-07-19Mention first and last macro in backtraceMichael Goulet-12/+12
2022-07-15Move tests to fit in limitEsteban Küber-0/+89
2022-07-15Provide structured suggestion for dropped temp valueEsteban Küber-6/+22
2022-07-13remove untagged_union feature gateRalf Jung-25/+23
2022-07-08Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebankbors-199/+152
Shorten def_span of closures to just their header Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-07Wording tweakEsteban Küber-9/+11
2022-07-07Fix label on uninit binding field assignmentEsteban Küber-2/+2
2022-07-07Add test for `for` loop maybe initializing bindingEsteban Küber-0/+20
2022-07-07Review comments: wordingEsteban Küber-17/+18
2022-07-07Tweak wording and spansEsteban Küber-173/+173
2022-07-07On partial uninit error point at where we need initEsteban Küber-187/+391
When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
2022-07-07Fix borrowck closure span.Camille GILLOT-22/+48
2022-07-07Shorten span for closures.Camille GILLOT-187/+114
2022-07-01Shorten def_span for more items.Camille GILLOT-26/+14
2022-06-29Make RPIT and TAIT work exactly the sameOli Scherer-4/+15
2022-06-28Do not use a suggestion to change a binding's name to a typeMichael Goulet-12/+13
2022-06-28Remove redundant logic to suggest `as_ref`Michael Goulet-0/+47
2022-06-25bless after rebaseRalf Jung-0/+39
2022-06-24Auto merge of #98109 - nikomatsakis:issue-98095, r=jackh726bors-68/+5
fix universes in the NLL type tests In the NLL code, we were not accommodating universes in the `type_test` logic. Fixes #98095. r? `@compiler-errors` This breaks some tests, however, so the purpose of this branch is more explanatory and perhaps to do a crater run.