Skip to content

Rustc isn’t warning about usage of and even suggests importing #[doc(hidden)] items. #80948

@steffahn

Description

@steffahn

Motivated by this thread on URLO, I’m wondering if we shouldn’t add warnings for using items that are hidden in documentations, in particular hidden modules (but e.g. also hidden fields that can be used to make structs with public fields extensible while still supporting Struct { foo: 1, bar: 2 ..Struct::default() }-style initialization).

Even more unfortunate is how rustc even suggests hidden re-export modules, e.g. in this playground, the compiler suggests, among other things, to add use pin_utils::core_reexport::fmt::Formatter; or use serde::export::Formatter;, which are semver-hazards.

   Compiling playground v0.0.1 (/playground)
error[E0412]: cannot find type `Formatter` in this scope
 --> src/lib.rs:2:16
  |
2 | pub fn foo(_f: Formatter) {}
  |                ^^^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
2 | use core::fmt::Formatter;
  |
2 | use env_logger::fmt::Formatter;
  |
2 | use pin_utils::core_reexport::fmt::Formatter;
  |
2 | use serde::export::Formatter;
  |
    and 3 other candidates

@rustbot modify labels: C-enhancement, T-compiler, A-diagnostics, A-suggestion-diagnostics, D-invalid-suggestion

(regarging D-invalid-suggestion: I would consider code that explicitly uses unstable internal (for macros) re-exports of another crate to be “incorrect”)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions