about summary refs log tree commit diff
path: root/src/test/ui/closures
AgeCommit message (Collapse)AuthorLines
2022-08-23Use par_body_owners for livenessSeo Sanghyeon-8/+8
2022-08-21Targeted fixes addressing erroneous suggestionsMichael Goulet-8/+0
2022-08-21Note closure kind mismatch causeMichael Goulet-3/+27
2022-08-21Rework point-at-argMichael Goulet-8/+24
2022-08-18Reword "Required because of the requirements on the impl of ..."Andy Wang-2/+2
2022-08-14Rollup merge of #99582 - compiler-errors:issue-99566, r=cjgillotDylan DPC-0/+28
Delay a span bug if we see ty/const generic params during writeback Fixes #99566
2022-08-07Rollup merge of #100194 - est31:box_syntax_tests, r=Mark-SimulacrumMatthias Krüger-6/+4
Remove even more box syntax uses from src/test Prior work, notably #88316 has removed box syntax from most of the testsuite. However, some tests were left out. This commit removes box_syntax uses from more locations in src/test. This migrates the tests where `box` is mostly an "implementation detail" and not the primary thing being tested by the test. Furthermore, some tests from the mir-opt test suite are not being migrated.
2022-08-07Remove even more box syntax uses from src/testest31-6/+4
Prior work, notably 6550021124451628b1efc60c59284465b109e3aa from #88316 has removed box syntax from most of the testsuite. However, some tests were left out. This commit removes box_syntax uses from more locations in src/test. Some tests that are very box syntax specific are not being migrated.
2022-08-07Rollup merge of #100130 - compiler-errors:erroneous-return-span, r=lcnrMatthias Krüger-5/+0
Avoid pointing out `return` span if it has nothing to do with type error This code: ```rust fn f(_: String) {} fn main() { let x = || { if true { return (); } f(""); }; } ``` Emits this: ``` Compiling playground v0.0.1 (/playground) error[E0308]: mismatched types --> src/main.rs:8:11 | 8 | f(""); | ^^- help: try using a conversion method: `.to_string()` | | | expected struct `String`, found `&str` | note: return type inferred to be `String` here --> src/main.rs:6:20 | 6 | return (); | ^^ ``` Specifically, that note has nothing to do with the type error in question. This is because the change implemented in #84244 tries to point out the `return` span on _any_ type coercion error within a closure that happens after a `return` statement, regardless of if the error has anything to do with it. This is really easy to trigger -- just needs a closure (or an `async`) and an early return (or any other form, e.g. `?` operator suffices) -- and super distracting in production codebases. I'm letting #84128 regress because that issue is much harder to fix correctly, and I can re-open that issue after this lands. As a drive-by, I added a `resolve_vars_if_possible` to the coercion error logic, which leads to some error improvements. Unrelated to the issue above, though.
2022-08-05Auto merge of #95977 - FabianWolff:issue-92790-dead-tuple, r=estebankbors-6/+6
Warn about dead tuple struct fields Continuation of #92972. Fixes #92790. The language team has already commented on this in https://github.com/rust-lang/rust/pull/92972#issuecomment-1021511970; I have incorporated their requests here. Specifically, there is now a new allow-by-default `unused_tuple_struct_fields` lint (name bikesheddable), and fields of unit type are ignored (https://github.com/rust-lang/rust/pull/92972#issuecomment-1021815408), so error messages look like this: ``` error: field is never read: `1` --> $DIR/tuple-struct-field.rs:6:21 | LL | struct Wrapper(i32, [u8; LEN], String); | ^^^^^^^^^ | help: change the field to unit type to suppress this warning while preserving the field numbering | LL | struct Wrapper(i32, (), String); | ~~ ``` r? `@joshtriplett`
2022-08-04Don't point out return span on every E0308Michael Goulet-5/+0
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-6/+6
2022-08-03add regression test for #90871Takayuki Maeda-0/+28
2022-07-22Don't suggest unnameable generic argumentsLeón Orell Valerian Liehr-0/+21
2022-07-22Delay a span bug if we see ty/const generic params during writebackMichael Goulet-0/+28
2022-07-19Mention first and last macro in backtraceMichael Goulet-5/+5
2022-07-12add test for implicit stuff in signatures of closures with `for<>`Maybe Waffle-0/+134
2022-07-12Lower closure binders to hir & properly check themMaybe Waffle-3/+12
2022-07-12Parse closure bindersMaybe Waffle-0/+71
This is first step in implementing RFC 3216. - Parse `for<'a>` before closures in ast - Error in lowering - Add `closure_lifetime_binder` feature
2022-07-08Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebankbors-52/+37
Shorten def_span of closures to just their header Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-07Tweak wording and spansEsteban Küber-17/+17
2022-07-07On partial uninit error point at where we need initEsteban Küber-29/+41
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-07Shorten span for closures.Camille GILLOT-52/+37
2022-07-01Auto merge of #93967 - cjgillot:short-struct-span, r=petrochenkovbors-2/+2
Shorten def_span for more items. The `def_span` query only returns the signature span for functions. Struct/enum/union definitions can also have a very long body. This PR shortens the associated span.
2022-07-01Shorten def_span for more items.Camille GILLOT-2/+2
2022-07-01Auto merge of #98402 - cjgillot:undead, r=michaelwoeristerbors-2/+2
Rewrite dead-code pass to avoid fetching HIR. This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-06-23Rollup merge of #98259 - jyn514:improve-obligation-errors, r=estebankMichael Goulet-2/+14
Greatly improve error reporting for futures and generators in `note_obligation_cause_code` Most futures don't go through this code path, because they're caught by `maybe_note_obligation_cause_for_async_await`. But all generators do, and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses. At some point, we may want to consider unifying this with the code for `maybe_note_async_await`, so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points. But both functions are quite complicated, and it's not clear to me how to combine them; this seems like a good incremental improvement. Helps with https://github.com/rust-lang/rust/issues/97332. r? ``@estebank`` cc ``@eholk`` ``@compiler-errors``
2022-06-22Uniform spans in dead code lint.Camille GILLOT-2/+2
2022-06-19Greatly improve error reporting for futures and generators in ↵Joshua Nelson-2/+14
`note_obligation_cause_code` Most futures don't go through this code path, because they're caught by `maybe_note_obligation_cause_for_async_await`. But all generators do, and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses. At some point, we may want to consider unifying this with the code for `maybe_note_async_await`, so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points. But both functions are quite complicated, and it's not clear to me how to combine them; this seems like a good incremental improvement.
2022-06-19collapse dead code warnings into a single diagnosticTakayuki Maeda-17/+15
add comments in `store_dead_field_or_variant` support multiple log level add a item ident label fix ui tests fix a ui test fix a rustdoc ui test use let chain refactor: remove `store_dead_field_or_variant` fix a tiny bug
2022-06-17Auto merge of #97892 - klensy:fix-spaces, r=oli-obkbors-3/+3
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2022-06-16--bless uiMaybe Waffle-12/+9
2022-06-16 fix one more case of trailing spaceklensy-3/+3
2022-06-11Auto merge of #95880 - cjgillot:def-ident-span, r=petrochenkovbors-0/+18
Handle `def_ident_span` like `def_span`. `def_ident_span` had an ad-hoc status in the compiler. This PR refactors it to be a first-class citizen like `def_span`: - it gets encoded in the main metadata loop, instead of the visitor; - its implementation is updated to mirror the one of `def_span`. We do not remove the `Option` in the return type, since some items do not have an ident, AnonConsts for instance.
2022-06-10Bless tests.Camille GILLOT-0/+18
2022-06-07Rollup merge of #97325 - tmiasko:capture-enum-field, r=arora-amanDylan DPC-0/+27
Fix precise field capture of univariant enums When constructing a MIR from a THIR field expression, introduce an additional downcast projection before accessing a field of an enum. When rebasing a place builder on top of a captured place, account for the fact that a single HIR enum field projection corresponds to two MIR projection elements: a downcast element and a field element. Fixes #95271. Fixes #96299. Fixes #96512. Fixes #97378. r? ``@nikomatsakis`` ``@arora-aman``
2022-06-03Fully stabilize NLLJack Huey-105/+9
2022-06-02add new `emit_inference_failure_err`lcnr-1/+6
2022-05-24Suggest adding a semicolon to a closure without blockChayim Refael Friedman-0/+27
This transforms `|| expr` into `|| { expr; }`.
2022-05-23Fix precise field capture of univariant enumsTomasz Miąsko-0/+27
When constructing a MIR from a THIR field expression, introduce an additional downcast projection before accessing a field of an enum. When rebasing a place builder on top of a captured place, account for the fact that a single HIR enum field projection corresponds to two MIR projection elements: a downcast element and a field element.
2022-05-22Use revisions for NLL in closuresJack Huey-18/+36
2022-05-08Move some tests to more reasonable placesCaio-0/+37
2022-05-08Auto merge of #96155 - jackh726:param-heuristics-followup, r=estebankbors-11/+20
Followups for method call error change Each commit is self-contained. Fixes most of the followup reviews from that PR. r? `@estebank`
2022-05-06Resolve vars in note_type_errJack Huey-11/+20
2022-05-05Put the 2229 migration errors in alphabetical orderScott McMurray-3/+3
Looks like they were in FxHash order before, so it might just be luck that this used to be consistent across different word lengths.
2022-04-26Revert "add `DefId` to unsafety violations and display function path in E0133"Oli Scherer-1/+1
This reverts commit 8b8f6653cfd54525714f02efe7af0a0f830e185c.
2022-04-24only show a simple description in E0133 span labelEmil Gardström-2/+2
2022-04-24add `DefId` to unsafety violations and display function path in E0133Emil Gardström-4/+4
this enables consumers to access the function definition that was reported to be unsafe
2022-04-16Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPCbors-11/+22
Rollup of 9 pull requests Successful merges: - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used) - #94605 (Add missing links in platform support docs) - #95372 (make unaligned_references lint deny-by-default) - #95859 (Improve diagnostics for unterminated nested block comment) - #95961 (implement SIMD gather/scatter via vector getelementptr) - #96004 (Consider lifetimes when comparing types for equality in MIR validator) - #96050 (Remove some now-dead code that was only relevant before deaggregation.) - #96070 ([test] Add test cases for untested functions for BTreeMap) - #96099 (MaybeUninit array cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-16Implementation for 65853Jack Huey-5/+25
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.