diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 23cc4b0ffc8..371f12fa6f4 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -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() } diff --git a/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs b/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs new file mode 100644 index 00000000000..0efc7daa3e1 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs @@ -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` +} diff --git a/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr b/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr new file mode 100644 index 00000000000..784986d3b95 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr @@ -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`.