respect doc(hidden) when suggesting available fields

This commit is contained in:
Ibraheem Ahmed 2022-01-22 15:47:02 -05:00
parent cbaeec14f9
commit 32ab0b88f4
3 changed files with 44 additions and 0 deletions

View File

@ -1794,6 +1794,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.1;
field.vis.is_accessible_from(def_scope, self.tcx)
})
.filter(|field| !self.tcx.is_doc_hidden(field.did))
.map(|field| field.name)
.collect()
}

View File

@ -0,0 +1,24 @@
#[derive(Default)]
pub struct A {
#[doc(hidden)]
pub hello: i32,
pub bye: i32,
}
#[derive(Default)]
pub struct B {
pub hello: i32,
pub bye: i32,
}
fn main() {
A::default().hey;
//~^ ERROR no field `hey` on type `A`
//~| NOTE unknown field
//~| NOTE available fields are: `bye`
B::default().hey;
//~^ ERROR no field `hey` on type `B`
//~| NOTE unknown field
//~| NOTE available fields are: `hello`, `bye`
}

View File

@ -0,0 +1,19 @@
error[E0609]: no field `hey` on type `A`
--> $DIR/issue-93210-ignore-doc-hidden.rs:15:18
|
LL | A::default().hey;
| ^^^ unknown field
|
= note: available fields are: `bye`
error[E0609]: no field `hey` on type `B`
--> $DIR/issue-93210-ignore-doc-hidden.rs:20:18
|
LL | B::default().hey;
| ^^^ unknown field
|
= note: available fields are: `hello`, `bye`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0609`.