Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing::instrument breaks "type ... is more private than the item" warnings #3207

Open
grahamc opened this issue Feb 2, 2025 · 0 comments

Comments

@grahamc
Copy link

grahamc commented Feb 2, 2025

Bug Report

Version

tracing 0.1.41

Platform

Darwin Grahams-MacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:02:12 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6031 arm64 arm Darwin

but also play.rust-lang.org.

Crates

  • tracing

Description

Marking a function with tracing::instrument obscures type visibility errors.

The following code has a warning that the pub function hi returns Foo, which is not pub:

struct Foo {}

pub fn hi() -> Foo {
    Foo {}
}

and the error:

warning: type `Foo` is more private than the item `hi`
 --> src/lib.rs:5:1
  |
5 | pub fn hi() -> Foo {
  | ^^^^^^^^^^^^^^^^^^ function `hi` is reachable at visibility `pub`
  |
note: but type `Foo` is only usable at visibility `pub(crate)`
 --> src/lib.rs:3:1
  |
3 | struct Foo {}
  | ^^^^^^^^^^
  = note: `#[warn(private_interfaces)]` on by default

However, if I mark hi with tracing::instrument...:

use tracing; // 0.1.41;

struct Foo {}

#[tracing::instrument]
pub fn hi() -> Foo {
    Foo {}
}

The warning goes away:

   Compiling playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.41s

I would expect Rust to continue issuing warnings about these types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant