-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix exposing fields marked unstable or doc hidden #90358
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8663ee1
Fix omitted_patterns lint showing unstable/doc hidden fields
DevinR528 3344833
Add unstable struct fields to ui tests
DevinR528 4bf281a
Update non-exhaustive omitted_patterns ui output
DevinR528 f481dba
Add struct to stability ui tests in usefulness
DevinR528 ef0d99d
Add struct to doc hidden usefulness ui tests
DevinR528 04210ae
Update output for doc hidden usefulness ui test output
DevinR528 7ffb29d
Only filter doc(hidden) fields/variants when not crate local
DevinR528 c0e76d6
Format reordered imports in tyck/pat
DevinR528 492d8d7
Fix rebase conflicts with stderr files
DevinR528 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
pub enum Foo { | ||
pub enum HiddenEnum { | ||
A, | ||
B, | ||
#[doc(hidden)] | ||
C, | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct HiddenStruct { | ||
pub one: u8, | ||
pub two: bool, | ||
#[doc(hidden)] | ||
pub hide: usize, | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// aux-build:hidden.rs | ||
|
||
extern crate hidden; | ||
|
||
use hidden::HiddenStruct; | ||
|
||
struct InCrate { | ||
a: usize, | ||
b: bool, | ||
#[doc(hidden)] | ||
im_hidden: u8 | ||
} | ||
|
||
fn main() { | ||
let HiddenStruct { one, two } = HiddenStruct::default(); | ||
//~^ pattern requires `..` due to inaccessible fields | ||
|
||
let HiddenStruct { one } = HiddenStruct::default(); | ||
//~^ pattern does not mention field `two` and inaccessible fields | ||
|
||
let HiddenStruct { one, hide } = HiddenStruct::default(); | ||
//~^ pattern does not mention field `two` | ||
|
||
let InCrate { a, b } = InCrate { a: 0, b: false, im_hidden: 0 }; | ||
//~^ pattern does not mention field `im_hidden` | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
error: pattern requires `..` due to inaccessible fields | ||
--> $DIR/doc-hidden-fields.rs:15:9 | ||
| | ||
LL | let HiddenStruct { one, two } = HiddenStruct::default(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: ignore the inaccessible and unused fields | ||
| | ||
LL | let HiddenStruct { one, two, .. } = HiddenStruct::default(); | ||
| ++++ | ||
|
||
error[E0027]: pattern does not mention field `two` and inaccessible fields | ||
--> $DIR/doc-hidden-fields.rs:18:9 | ||
| | ||
LL | let HiddenStruct { one } = HiddenStruct::default(); | ||
| ^^^^^^^^^^^^^^^^^^^^ missing field `two` and inaccessible fields | ||
| | ||
help: include the missing field in the pattern and ignore the inaccessible fields | ||
| | ||
LL | let HiddenStruct { one, two, .. } = HiddenStruct::default(); | ||
| ~~~~~~~~~~~ | ||
help: if you don't care about this missing field, you can explicitly ignore it | ||
| | ||
LL | let HiddenStruct { one, .. } = HiddenStruct::default(); | ||
| ~~~~~~ | ||
|
||
error[E0027]: pattern does not mention field `two` | ||
--> $DIR/doc-hidden-fields.rs:21:9 | ||
| | ||
LL | let HiddenStruct { one, hide } = HiddenStruct::default(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `two` | ||
| | ||
help: include the missing field in the pattern | ||
| | ||
LL | let HiddenStruct { one, hide, two } = HiddenStruct::default(); | ||
| ~~~~~~~ | ||
help: if you don't care about this missing field, you can explicitly ignore it | ||
| | ||
LL | let HiddenStruct { one, hide, .. } = HiddenStruct::default(); | ||
| ~~~~~~ | ||
|
||
error[E0027]: pattern does not mention field `im_hidden` | ||
--> $DIR/doc-hidden-fields.rs:24:9 | ||
| | ||
LL | let InCrate { a, b } = InCrate { a: 0, b: false, im_hidden: 0 }; | ||
| ^^^^^^^^^^^^^^^^ missing field `im_hidden` | ||
| | ||
help: include the missing field in the pattern | ||
| | ||
LL | let InCrate { a, b, im_hidden } = InCrate { a: 0, b: false, im_hidden: 0 }; | ||
| ~~~~~~~~~~~~~ | ||
help: if you don't care about this missing field, you can explicitly ignore it | ||
| | ||
LL | let InCrate { a, b, .. } = InCrate { a: 0, b: false, im_hidden: 0 }; | ||
| ~~~~~~ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0027`. |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// aux-build:unstable.rs | ||
|
||
extern crate unstable; | ||
|
||
use unstable::UnstableStruct; | ||
|
||
fn main() { | ||
let UnstableStruct { stable } = UnstableStruct::default(); | ||
//~^ pattern does not mention field `stable2` and inaccessible fields | ||
|
||
let UnstableStruct { stable, stable2 } = UnstableStruct::default(); | ||
//~^ pattern requires `..` due to inaccessible fields | ||
|
||
// OK: stable field is matched | ||
let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be left as followup, but ideally we should also suggest hiding in one go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the
doc(hidden)
field is being explicitly matched on?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Good point. Not sure.