-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
188 additions
and
131 deletions.
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
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,6 @@ | ||
#[derive(Default)] | ||
pub struct B { | ||
#[doc(hidden)] | ||
pub hello: i32, | ||
pub bye: i32, | ||
} |
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,38 @@ | ||
// Regression test for issue #93210. | ||
|
||
// aux-crate:doc_hidden_fields=doc-hidden-fields.rs | ||
// edition: 2021 | ||
|
||
#[derive(Default)] | ||
pub struct A { | ||
#[doc(hidden)] | ||
pub hello: i32, | ||
pub bye: i32, | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct C { | ||
pub hello: i32, | ||
pub bye: i32, | ||
} | ||
|
||
fn main() { | ||
// We want to list the field `hello` despite being marked | ||
// `doc(hidden)` because it's defined in this crate. | ||
A::default().hey; | ||
//~^ ERROR no field `hey` on type `A` | ||
//~| NOTE unknown field | ||
//~| NOTE available fields are: `hello`, `bye` | ||
|
||
// Here we want to hide the field `hello` since it's marked | ||
// `doc(hidden)` and comes from an external crate. | ||
doc_hidden_fields::B::default().hey; | ||
//~^ ERROR no field `hey` on type `B` | ||
//~| NOTE unknown field | ||
//~| NOTE available fields are: `bye` | ||
|
||
C::default().hey; | ||
//~^ ERROR no field `hey` on type `C` | ||
//~| NOTE unknown field | ||
//~| NOTE available fields are: `hello`, `bye` | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr
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,27 @@ | ||
error[E0609]: no field `hey` on type `A` | ||
--> $DIR/dont-suggest-doc-hidden-fields.rs:22:18 | ||
| | ||
LL | A::default().hey; | ||
| ^^^ unknown field | ||
| | ||
= note: available fields are: `hello`, `bye` | ||
|
||
error[E0609]: no field `hey` on type `B` | ||
--> $DIR/dont-suggest-doc-hidden-fields.rs:29:37 | ||
| | ||
LL | doc_hidden_fields::B::default().hey; | ||
| ^^^ unknown field | ||
| | ||
= note: available fields are: `bye` | ||
|
||
error[E0609]: no field `hey` on type `C` | ||
--> $DIR/dont-suggest-doc-hidden-fields.rs:34:18 | ||
| | ||
LL | C::default().hey; | ||
| ^^^ unknown field | ||
| | ||
= note: available fields are: `hello`, `bye` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0609`. |
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,33 @@ | ||
// Regression test for issue #116334. | ||
// Don't include hygienic fields in the list of available or similarly named fields. | ||
|
||
#![feature(decl_macro)] | ||
|
||
macro compound($Ty:ident) { | ||
#[derive(Default)] | ||
struct $Ty { | ||
field: u32, // field `field` is hygienic | ||
} | ||
} | ||
|
||
macro component($Ty:ident) { | ||
struct $Ty(u64); // field `0` is hygienic (but still accessible via the constructor) | ||
} | ||
|
||
compound! { Compound } | ||
component! { Component } | ||
|
||
fn main() { | ||
let ty = Compound::default(); | ||
|
||
let _ = ty.field; //~ ERROR no field `field` on type `Compound` | ||
let _ = ty.fieeld; //~ ERROR no field `fieeld` on type `Compound` | ||
|
||
let Compound { field } = ty; | ||
//~^ ERROR struct `Compound` does not have a field named `field` | ||
//~| ERROR pattern requires `..` due to inaccessible fields | ||
|
||
let ty = Component(90); | ||
|
||
let _ = ty.0; //~ ERROR no field `0` on type `Component` | ||
} |
Oops, something went wrong.