Uh oh!
There was an error while loading. Please reload this page.
Suggest replacing an inexisting field for an unmentioned field - #87960
Merged
bors merged 1 commit intoSep 19, 2021
Merged
Conversation
rust-highfive
commented
Aug 12, 2021
Contributor
(rust-highfive has picked a reviewer for you, use r? to override) |
hkmatsumotoforce-pushed
the
suggest-inexisting-field-for-unmentioned-field
branch
from
August 12, 2021 10:58
7def33c to
9d9f742CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
LeSeulArtichaut
commented
Aug 18, 2021
Contributor
r? @estebank who will have a much better idea of what the best diagnostics are |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
hkmatsumotoforce-pushed
the
suggest-inexisting-field-for-unmentioned-field
branch
from
September 13, 2021 09:12
9d9f742 to
4caab25CompareUh oh!
There was an error while loading. Please reload this page.
estebank
approved these changes
Sep 13, 2021
estebank
commented
Sep 13, 2021
Contributor
Please squash your commits. Then we can merge this :) |
This PR adds a suggestion to replace an inexisting field for an
unmentioned field. Given the following code:
```rust
enum Foo {
Bar { alpha: u8, bravo: u8, charlie: u8 },
}
fn foo(foo: Foo) {
match foo {
Foo::Bar {
alpha,
beta, // `bravo` miswritten as `beta` here.
charlie,
} => todo!(),
}
}
```
the compiler now emits the error messages below.
```text
error[E0026]: variant `Foo::Bar` does not have a field named `beta`
--> src/lib.rs:9:13
|
9 | beta, // `bravo` miswritten as `beta` here.
| ^^^^
| |
| variant `Foo::Bar` does not have this field
| help: `Foo::Bar` has a field named `bravo`: `bravo`
```
Note that this suggestion is available iff the number of inexisting
fields and unmentioned fields are both 1.hkmatsumotoforce-pushed
the
suggest-inexisting-field-for-unmentioned-field
branch
from
September 13, 2021 12:16
74277a4 to
37196e3Compareestebank
commented
Sep 18, 2021
Contributor
@bors r+ rollup |
bors
commented
Sep 18, 2021
Collaborator
📌 Commit 37196e3 has been approved by |
JohnTitor added a commit
to JohnTitor/rust
that referenced
this pull request
Sep 19, 2021
…d-for-unmentioned-field, r=estebank Suggest replacing an inexisting field for an unmentioned field Fixrust-lang#87938 This PR adds a suggestion to replace an inexisting field for an unmentioned field. Given the following code: ```rust enum Foo { Bar { alpha: u8, bravo: u8, charlie: u8 }, } fn foo(foo: Foo) { match foo { Foo::Bar { alpha, beta, // `bravo` miswritten as `beta` here. charlie, } => todo!(), } } ``` the compiler now emits the error messages below. ```text error[E0026]: variant `Foo::Bar` does not have a field named `beta` --> src/lib.rs:9:13 | 9 | beta, // `bravo` miswritten as `beta` here. | ^^^^ | | | variant `Foo::Bar` does not have this field | help: `Foo::Bar` has a field named `bravo`: `bravo` ``` Note that this suggestion is available iff the number of inexisting fields and unmentioned fields are both 1.
bors added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 19, 2021
Rollup of 10 pull requests Successful merges: - rust-lang#87960 (Suggest replacing an inexisting field for an unmentioned field) - rust-lang#88855 (Allow simd_shuffle to accept vectors of any length) - rust-lang#88966 (Check for shadowing issues involving block labels) - rust-lang#88996 (Fix linting when trailing macro expands to a trailing semi) - rust-lang#89017 (fix potential race in AtomicU64 time monotonizer) - rust-lang#89021 (Add a separate error for `dyn Trait` in `const fn`) - rust-lang#89051 (Add intra-doc links and small changes to `std::os` to be more consistent) - rust-lang#89053 (refactor: VecDeques IntoIter fields to private) - rust-lang#89055 (Suggest better place to add call parentheses for method expressions wrapped in parentheses) - rust-lang#89081 (Fix a typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
hkmatsumoto
deleted the
suggest-inexisting-field-for-unmentioned-field
branch
September 19, 2021 13:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix#87938
This PR adds a suggestion to replace an inexisting field for an
unmentioned field. Given the following code:
the compiler now emits the error messages below.
Note that this suggestion is available iff the number of inexisting
fields and unmentioned fields are both 1.