Suggest using dotdot for ignoring pat fields#137623
Suggest using dotdot for ignoring pat fields#137623TaKO8Ki wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
rustbot has assigned @petrochenkov. Use |
|
I think this PR is way too specific for a single error case, since this only works for singular wildcard patterns for tuple structs. I don't think this is worth the implementation complexity unless it can be generalized. |
|
Hmm, why does the test example even compiles with |
Compare: mod foo {
struct Bar;
pub enum Foo {
#[allow(private_interfaces)]
A(Bar),
}
}
fn main() {
let _ = foo::Foo::A; // error: type `Bar` is private
} |
|
I've submitted a fix for the privacy hole in #138458, but even if we are not able to land it due to regressions, using it is probably not something that we should recommend. |
Fixes a part of #135903
The following case where multiple fields are ignored, as shown below, has been excluded from this implementation. In such cases, all underscores should be replaced with
... However, in the current implementation of the ItemIsPrivate error, errors for different fields are output as completely separate errors. To fix this, a somewhat substantial change to the TypePrivacyVisitor is necessary.Also, a similar suggestion for struct patterns has not been implemented in this pull request.