about summary refs log tree commit diff
path: root/src/test/ui/unboxed-closures
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-3010/+0
2023-01-05Detect closures assigned to binding in blockEsteban Küber-11/+16
Fix #58497.
2023-01-05Auto merge of #105409 - compiler-errors:closure-infer-cycle, r=jackh726bors-1/+6
Don't deduce a signature that makes a closure cyclic Sometimes when elaborating supertrait bounds for closure signature inference, we end up deducing a closure signature that is cyclical because either a parameter or the return type references a projection mentioning `Self` that also has escaping bound vars, which means that it's not eagerly replaced with an inference variable. Interestingly, this is not *just* related to my PR that elaborates supertrait bounds for closure signature deduction. The committed test `supertrait-hint-cycle-3.rs` shows **stable** code that is fixed by this PR: ```rust trait Foo<'a> { type Input; } impl<F: Fn(u32)> Foo<'_> for F { type Input = u32; } fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {} fn main() { needs_super(|_: u32| {}); } ``` Fixes #105401 Fixes #105396 r? types
2023-01-01Verbose suggestionsEsteban Küber-8/+17
2022-12-27Restore cyclic closure messageMichael Goulet-8/+8
2022-12-27Don't deduce a signature that makes a closure cyclicMichael Goulet-8/+13
2022-12-20Re-enable fn trait call notation errorMichael Goulet-0/+26
2022-12-15Trim paths in E0599Esteban Küber-2/+2
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-3/+0
available
2022-11-05Merge conflicts and rebase onto masterMichael Goulet-12/+10
2022-11-05Adjust diagnostics, bless testsMichael Goulet-11/+11
2022-10-01bless ui testsMaybe Waffle-2/+2
2022-09-26address reviewb-naber-18/+18
2022-09-04Rollup merge of #100647 - obeis:issue-99875, r=nagisaMatthias Krüger-9/+9
Make trait bound not satisfied specify kind Closes #99875
2022-08-29Make the trait bound is not satisfied specify kindObei Sideg-9/+9
2022-08-27Only suggest call on nonexistent fields and methods if they make senseMichael Goulet-3/+1
2022-08-21Make check for overlapping closure span more accurateMichael Goulet-4/+2
2022-08-21Note closure kind mismatch causeMichael Goulet-1/+11
2022-08-21Rework point-at-argMichael Goulet-3/+5
2022-08-16Fix error message with non-tupled bare fn traitMichael Goulet-0/+25
2022-08-12Adjust span of closure paramMichael Goulet-1/+1
2022-08-12And for closuresMichael Goulet-3/+3
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-1/+1
2022-07-25Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkovbors-0/+5
Resolve function lifetime elision on the AST ~Based on https://github.com/rust-lang/rust/pull/97720~ Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST. This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`. This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR. r? `@petrochenkov`
2022-07-25Report elision failures on the AST.Camille GILLOT-0/+5
2022-07-16Use typeck_results to avoid duplicate ast_ty_to_ty callMichael Goulet-7/+6
2022-07-07Fix borrowck closure span.Camille GILLOT-2/+6
2022-07-07Shorten span for closures.Camille GILLOT-38/+24
2022-07-01Only label place where type is needed if span is meaningfulMichael Goulet-1/+3
2022-06-17Auto merge of #97892 - klensy:fix-spaces, r=oli-obkbors-2/+2
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-4/+3
2022-06-16 fix one more case of trailing spaceklensy-2/+2
2022-06-15Refactor path segment parameter errorEdwinRy-4/+6
2022-06-03Fully stabilize NLLJack Huey-53/+3
2022-06-02add new `emit_inference_failure_err`lcnr-6/+7
2022-05-06Point at closure args tooJack Huey-0/+5
2022-04-26Add new diagnosticGeorge-3/+3
2022-04-16Implementation for 65853Jack Huey-1/+3
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.
2022-04-05Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, ↵Dylan DPC-6/+12
r=compiler-errors diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut Fixes #90073
2022-04-05Rollup merge of #95591 - jackh726:nll-revisions-1, r=oli-obkDylan DPC-7/+21
Use revisions to track NLL test output (part 1) The idea here is 2 fold: 1) When we eventually do make NLL default on, that PR should be systematic in "delete revisions and corresponding error annotations" 2) This allows us to look at test NLL outputs in chunks. (Though, I've opted here not to "mark" these tests. There are some tests with NLL revisions *now* that will be missed. I expect we do a second pass once we have all the tests with NLL revisions; these tests should be easy enough to eyeball.) The actual review here should be "easy", but a bit tedious. I expect we should manually go through each test output and confirm it's okay. The majority of these are either: 1) Only span change (the one I see most common is highlighting an entire function call, rather than just the function name in that call) 2) "E0308 mismatched types" -> "lifetime does not live long enough" 3) "E0495 cannot infer an appropriate lifetime for lifetime parameter" -> "lifetime does not live long enough" 4) "E0312 lifetime of reference outlives lifetime of borrowed content" -> "lifetime does not live long enough" 5) "E0759 `XXX` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement" -> "lifetime does not live long enough" 6) "E0623 lifetime mismatch" -> "lifetime does not live long enough" Other than the now lack of an error code, most of these look fine (with most giving more helpful suggestions now). `rfc1623` output isn't great. cc ``@marmeladema`` if you want to look through these Let's r? ``@oli-obk`` since you've commented on the Zulip thread ;)
2022-04-05diagnostics: tweak error message to give more rationale to unsafe FnMichael Howell-12/+12
2022-04-05unboxed-closures and type-alias-impl-trait nll revisionsJack Huey-7/+21
2022-04-04diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMutMichael Howell-0/+6
Fixes #90073
2022-03-23Better suggestions for Fn trait selection errorsMichael Goulet-0/+1
2022-03-07Try to normalize associated types before processing obligationsJack Huey-21/+2
2022-03-03Cleanup feature gates.Camille GILLOT-4/+3
2021-11-06Move some tests to more reasonable directoriesCaio-0/+10
2021-10-13Remove textual span from diagnostic stringOli Scherer-2/+2
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-2/+1
2021-09-17Rollup merge of #87460 - FabianWolff:issue-87456, r=Aaron1011Guillaume Gomez-4/+16
Point to closure when emitting 'cannot move out' for captured variable Attempts to fix #87456. The error message now points to the capturing closure, but I was not able to explain _why_ the closure implements `Fn` or `FnMut` (`TypeckResults::closure_kind_origins` did not contain anything for the closure in question). cc `@Aaron1011`