| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
Add some more regression tests for #67945
Closes #67945, added two tests from https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285, other snippets were already added in #71952 and #77439
r? `@compiler-errors`
|
|
Normalize consts' tys when relating with `adt_const_params`
Fixes #97007
|
|
|
|
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.
|
|
some additional `need_type_info.rs` cleanup
also fixes #97698, fixes #97806
cc `@estebank`
|
|
Stabilize explicit_generic_args_with_impl_trait
This is a stabilisation PR for `explicit_generic_args_with_impl_trait`.
* [tracking issue](https://github.com/rust-lang/rust/issues/83701)
- [Stabilisation report](https://github.com/rust-lang/rust/issues/83701#issuecomment-1109949897)
- [FCP entered](https://github.com/rust-lang/rust/issues/83701#issuecomment-1120285703)
* [implementation PR](https://github.com/rust-lang/rust/pull/86176)
* [Reference PR](https://github.com/rust-lang/reference/pull/1212)
* There is no mention of using the turbofish operator in the book (other than an entry in the operator list in the appendix), so there is no documentation to change/add there, unless we felt like we should add a section on using turbofish, but that seems orthogonal to `explicit_generic_args_with_impl_trait`
|
|
|
|
|
|
Signed-off-by: Nick Cameron <nrc@ncameron.org>
|
|
|
|
|
|
|
|
|
|
b-naber:adt-const-params-structural-match-violation, r=michaelwoerister
Output correct type responsible for structural match violation
Previously we included the outermost type that caused a structural match violation in the error message and stated that that type must be annotated with `#[derive(Eq, PartialEq)]` even if it already had that annotation. This PR outputs the correct type in the error message.
Fixes https://github.com/rust-lang/rust/issues/97278
|
|
Add tests for lint on type dependent on consts
r? `@lcnr`
|
|
|
|
|
|
TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk
Fix misleading `cannot infer type for type parameter` error
closes #93198
|
|
fix ci error
emit err for `impl_item`
|
|
|
|
|
|
|
|
|
|
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`
|
|
Add and tweak const-generics tests
Closes #96654
Also correct the src/test/ui/const-generics/issues/issue-77357.rs test's issue number.
|
|
Followups for method call error change
Each commit is self-contained. Fixes most of the followup reviews from that PR.
r? `@estebank`
|
|
|
|
|
|
|
|
`run-pass` produces a JSON file when enabling save analysis.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
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`
|
|
|
|
|
|
|
|
typeck and that they are Copy (with proper lifetime checks) in borrowck
|
|
|
|
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.
|
|
simplify const params diagnostic on stable
Resolves #95150
|
|
|
|
|
|
diagnostics: use correct span for const generics
Fixes #95616
|