respect doc(hidden) when suggesting available fields
This commit is contained in:
parent
cbaeec14f9
commit
32ab0b88f4
3 changed files with 44 additions and 0 deletions
|
@ -1794,6 +1794,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.1;
|
.1;
|
||||||
field.vis.is_accessible_from(def_scope, self.tcx)
|
field.vis.is_accessible_from(def_scope, self.tcx)
|
||||||
})
|
})
|
||||||
|
.filter(|field| !self.tcx.is_doc_hidden(field.did))
|
||||||
.map(|field| field.name)
|
.map(|field| field.name)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
24
src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs
Normal file
24
src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs
Normal 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`
|
||||||
|
}
|
|
@ -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`.
|
Loading…
Add table
Add a link
Reference in a new issue