summary refs log tree commit diff
path: root/src/test/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2022-06-13Revert "Check that closures satisfy their where bounds"Oli Scherer-20/+7
This reverts commit 253408b4090bc15b88bb5faecaf1e9765be80587.
2022-06-07Remove arg_matrix.rs, bless testsMichael Goulet-21/+10
2022-05-13Check that closures satisfy their where boundsOli Scherer-7/+20
2022-05-11Gracefully fail to resolve associated items instead of `delay_span_bug`.Camille GILLOT-5/+33
2022-05-11Rollup merge of #96717 - BoxyUwU:gats_const_param_types_mismatch_err, r=lcnrYuki Okushi-15/+124
Handle mismatched generic param kinds in trait impls betterly - Check that generic params on a generic associated type are the same as in the trait definition - Check that const generics are not used in place of type generics (and the other way round too) r? `@lcnr`
2022-05-08Rollup merge of #96830 - JohnTitor:issue-96654, r=compiler-errorsMatthias Krüger-1/+16
Add and tweak const-generics tests Closes #96654 Also correct the src/test/ui/const-generics/issues/issue-77357.rs test's issue number.
2022-05-08Auto merge of #96155 - jackh726:param-heuristics-followup, r=estebankbors-29/+0
Followups for method call error change Each commit is self-contained. Fixes most of the followup reviews from that PR. r? `@estebank`
2022-05-08Correct the issue number of a testYuki Okushi-1/+1
2022-05-08Add regression test for #96654Yuki Okushi-0/+15
2022-05-06Remove previously deleted test filesJack Huey-29/+0
2022-05-07Make the test `check-pass` not to produce a JSON fileYuki Okushi-1/+1
`run-pass` produces a JSON file when enabling save analysis.
2022-05-06wording tweaksEllen-15/+15
2022-05-05 make `compare_generic_param_kinds` errors consistentEllen-39/+84
2022-05-05exit out of `compare_number_of_generics` earlyEllen-29/+16
2022-05-05 handle mismatched generic parameter kindsEllen-0/+77
2022-05-01Enable full revision in const generics ui testsAlex Macleod-71/+291
2022-04-30Auto merge of #95776 - cjgillot:ast-lifetimes-static, r=petrochenkovbors-68/+236
Enforce static lifetimes in consts during late resolution This PR moves the handling of implicitly and explicitly static lifetimes in constants from HIR to the AST.
2022-04-30Bless tests.Camille GILLOT-67/+225
2022-04-29Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebankbors-6/+6
Enforce Copy bounds for repeat elements while considering lifetimes fixes https://github.com/rust-lang/rust/issues/95477 this is a breaking change in order to fix a soundness bug. Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't. r? `@lcnr`
2022-04-29Bless tests.Camille GILLOT-1/+11
2022-04-28Revert diagnostic duplication and accidental stabilizationOli Scherer-49/+3
2022-04-28Update the diagnostic message to match the new spanOli Scherer-2/+2
2022-04-28Check that repeat expression elements are Copy (ignoring lifetimes) in ↵Oli Scherer-4/+4
typeck and that they are Copy (with proper lifetime checks) in borrowck
2022-04-17show suggestion to replace generic bounds with associated types in more casesRobin Appelman-1/+1
2022-04-16Implementation for 65853Jack Huey-10/+50
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-12Rollup merge of #95820 - OliverMD:95150, r=lcnrfee1-dead-20/+4
simplify const params diagnostic on stable Resolves #95150
2022-04-11simplify const params diagnostic on stableOliver Downard-20/+4
2022-04-09Bless tests.Camille GILLOT-0/+3
2022-04-05Rollup merge of #95654 - notriddle:notriddle/issue-95616, r=davidtwcoDylan DPC-21/+21
diagnostics: use correct span for const generics Fixes #95616
2022-04-04Remove hack, fix fmt and testsEsteban Kuber-3/+3
2022-04-04Refer to the TraitRef::identity in the message to be clearerEsteban Kuber-3/+3
2022-04-04Dedup logic and improve output for other types that impl traitEsteban Kuber-23/+23
2022-04-04Fix list lengthEsteban Kuber-0/+4
2022-04-04Fix #90970, doesn't address #87437Esteban Kuber-0/+1
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-17/+9
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-04-04diagnostics: use correct span for const genericsMichael Howell-21/+21
Fixes #95616
2022-03-28Revert to inference variable based hidden type computation for RPITOli Scherer-13/+60
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-12/+12
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-25Rollup merge of #95179 - b-naber:eval-in-try-unify, r=lcnrDylan DPC-189/+114
Try to evaluate in try unify and postpone resolution of constants that contain inference variables We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables. r? `@lcnr`
2022-03-22fix previous failures and address reviewb-naber-58/+70
2022-03-22cancel a not emitted error after parsing const generic argsTakayuki Maeda-0/+13
2022-03-21add/update testsb-naber-137/+50
2022-03-17Rollup merge of #94731 - TaKO8Ki:const-generic-expr-recovery, ↵Dylan DPC-0/+75
r=davidtwco,oli-obk Suggest adding `{ .. }` around a const function call with arguments closes #91020
2022-03-10Rollup merge of #94440 - compiler-errors:issue-94282, r=lcnrMatthias Krüger-0/+45
Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]` This PR implements a somewhat rudimentary heuristic to suggest using `#![feature(generic_const_exprs)]` in a child crate when a function from a foreign crate (that may have used `#![feature(generic_const_exprs)]`) fails to normalize during codegen. cc: #79018 cc: #94287
2022-03-09suggest enabling generic_const_exprs feature if const is unevaluatableMichael Goulet-0/+45
2022-03-08suggest adding `{ .. }` around a const function with argumentsTakayuki Maeda-0/+75
2022-03-07Update tests after feature stabilizationEric Holk-2/+2
2022-03-03Cleanup feature gates.Camille GILLOT-1/+1
2022-02-28Rollup merge of #93389 - cameron1024:issue-90847-regression, r=Mark-SimulacrumMatthias Krüger-0/+9
regression for issue 90847 Adds a regression test for issue #90847
2022-02-25Suggest {} around more bad const generic exprsMichael Goulet-0/+81