| Age | Commit message (Collapse) | Author | Lines |
|
Fix suggestion for removing &mut from &mut macro!().
Fixes #85933
Before: (Note the suggestions.)
```
error[E0308]: mismatched types
--> src/main.rs:2:21
|
2 | let _: String = &mut format!("");
| ------ ^^^^^^^^^^^^^^^^
| | |
| | expected struct `String`, found `&mut String`
| | help: consider removing the borrow: `mut format!("")`
| expected due to this
error[E0308]: mismatched types
--> src/main.rs:3:21
|
3 | let _: String = &mut (format!(""));
| ------ ^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `String`, found `&mut String`
| | help: consider removing the borrow: `mut (format!(""))`
| expected due to this
```
After:
```
error[E0308]: mismatched types
--> src/main.rs:2:21
|
2 | let _: String = &mut format!("");
| ------ ^^^^^^^^^^^^^^^^
| | |
| | expected struct `String`, found `&mut String`
| | help: consider removing the borrow: `format!("")`
| expected due to this
error[E0308]: mismatched types
--> src/main.rs:3:21
|
3 | let _: String = &mut (format!(""));
| ------ ^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `String`, found `&mut String`
| | help: consider removing the borrow: `format!("")`
| expected due to this
```
|
|
Fix bad suggestions for code from proc_macro
Fixes #85932
This disables these suggestions for spans from external macros, while keeping them for macros defined locally:
Before:
```
3 | #[hello]
| ^^^^^^^^
| |
| expected `&mut i32`, found integer
| help: consider mutably borrowing here: `&mut #[hello]`
```
After:
```
3 | #[hello]
| ^^^^^^^^ expected `&mut i32`, found integer
```
Unchanged:
```
26 | macro_rules! bla { () => { x(123); } }
| ^^^
| |
| expected `&mut i32`, found integer
| help: consider mutably borrowing here: `&mut 123`
...
29 | bla!();
| ------- in this macro invocation
```
|
|
Skip where-clauses when suggesting using indirection in combination with
`?Sized` bounds on type parameters.
|
|
|
|
|
|
Adjust self-type check to require equality
When we encounter `SomeType::<X>::foo`, `self_ty` is `SomeType<X>` and the method is defined in an impl on `SomeType<A>`. Previously, we required simply that `self_ty <: impl_ty`, but this is too lax: we should require equality in order to use the method. This was found as part of unrelated work on never type stabilization, but also fixes one of the wf test cases.
|
|
|
|
Fix missing lifetimes diagnostics after #83759
In #83759 while rebasing I didn't realize there was a new function for suggesting to add lifetime arguments. It relied on some invariants, namely that if a generic type/trait has angle brackets then it must have some generic argument, which is now no longer true. This PR updates that function to handle the new invariants.
This also adds a new regression test but I'm not sure if that's the correct place for it.
Fixes #85347
|
|
Implement the new desugaring from `try_trait_v2`
~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix.
`try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277
Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.
r? `@ghost`
~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
|
|
|
|
|
|
|
|
|
|
When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.
|
|
Improve diagnostics for GATs
Fixes https://github.com/rust-lang/rust/issues/81801
Fixes https://github.com/rust-lang/rust/issues/81961
Fixes https://github.com/rust-lang/rust/issues/81862
r? `@estebank`
|
|
|
|
Fix invalid suggestion of changing impl trait signature
Fix #68049
|
|
|
|
|
|
|
|
|
|
|
|
Add test for suggestion to borrow unsized function parameters
Closes #82820.
This is a regression test for #82820.
This test case is included in more general tests, but I think the error
regressed because there were a bunch of other diagnostic changes in the
test that obscured this regression.
Hopefully, having a test specific to the suggestion, and running rustfix
for the test, will prevent this error from regressing in the future.
|
|
This is a regression test for #82820.
This test case is included in more general tests, but I think the error
regressed because there were a bunch of other diagnostic changes in the
test that obscured this regression.
Hopefully, having a test specific to the suggestion, and running rustfix
for the test, will prevent this error from regressing in the future.
|
|
|
|
Account for unsatisfied bounds in E0599
Fix #84769, follow up to #84499, #83667.
|
|
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021
This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition.
r? `@estebank`
|
|
|
|
Fix #84769, follow up to #84499, #83667.
|
|
|
|
|
|
|
|
Suggest `.as_ref()` on borrow error involving `Option`/`Result`
When encountering a E0382 borrow error involving an `Option` or `Result`
provide a suggestion to use `.as_ref()` on the prior move location to
avoid the move.
Fix #84165.
|
|
When encountering a E0382 borrow error involving an `Option` or `Result`
provide a suggestion to use `.as_ref()` on the prior move location to
avoid the move.
Fix #84165.
|
|
|
|
|
|
Use a more appropriate span for `;` suggestion
Fix #83892.
|
|
Fix #83892.
|
|
Fix #83943.
|
|
revert file
bless with nll mode
|
|
|
|
|
|
|
|
This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
|
|
|
|
Fixes issue #82920
Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.
In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.
Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.
It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.
This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.
To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
compiler to ICE whenver an 'unchanged' query result changes between
compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
difficult to introduce ICEs in the first place.
|
|
Fix turbofish recovery with multiple generic args
This consists of two commits, each can be individually reviewed.
- First commit fixes the issue in [this comment](https://github.com/rust-lang/rust/issues/82566#issuecomment-786924466).
- Second commit fixes #82566
---
r? ````@estebank````
|
|
This adds recovery when in array type syntax user writes
[X; Y<Z, ...>]
instead of
[X; Y::<Z, ...>]
Fixes #82566
Note that whenever we parse an expression and know that the next token
cannot be `,`, we should be calling
check_mistyped_turbofish_with_multiple_type_params for this recovery.
Previously we only did this for statement parsing (e.g. `let x = f<a,
b>;`). We now also do it when parsing the length field in array type
syntax.
|
|
check_mistyped_turbofish_with_multiple_type_params was previously
expecting type arguments between angle brackets, which is not right, as
we can also see const expressions. We now use generic argument parser
instead of type parser.
Test with one, two, and three generic arguments added to check
consistentcy between
1. check_no_chained_comparison: Called after parsing a nested binop
application like `x < A > ...` where angle brackets are interpreted as
binary operators and `A` is an expression.
2. check_mistyped_turbofish_with_multiple_type_params: called by
`parse_full_stmt` when we expect to see a semicolon after parsing an
expression but don't see it.
(In `T2<1, 2>::C;`, the expression is `T2 < 1`)
|
|
0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank
Improve anonymous lifetime note to indicate the target span
Improvement for #81650
Cc #81995
Message after this improvement:
(Improve note in the middle)
```
error[E0311]: the parameter type `T` may not live long enough
--> src/main.rs:25:11
|
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
| -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 | scope.spawn(move |_| {
| ^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40...
--> src/main.rs:24:40
|
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
| ^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
--> src/main.rs:25:11
|
25 | scope.spawn(move |_| {
| ^^^^^
```
r? ``````@estebank``````
|