Skip to content

"Did you mean" for attributes should be the same style as functions #112439

Closed
@shepmaster

Description

@shepmaster

Code

In the playground (which has a large number of dependencies already):

#[instrument(skip_all)]
fn demo() {
    time::sleep();
}

Current output

error: cannot find attribute `instrument` in this scope
  --> src/main.rs:19:3
   |
19 | #[instrument(skip_all)]
   |   ^^^^^^^^^^
   |
   = help: consider importing one of these items:
           tracing::instrument
           tracing_attributes::instrument
error[E0425]: cannot find function `sleep` in crate `time`
  --> src/main.rs:11:19
   |
11 |             time::sleep(Duration::from_millis(100)).await;
   |                   ^^^^^ not found in `time`
   |
help: consider importing one of these items
   |
1  + use libc::sleep;
   |
1  + use openssl_sys::sleep;
   |
1  + use std::thread::sleep;
   |
1  + use tokio::time::sleep;

Desired output

The first block should match the second block:

error: cannot find attribute `instrument` in this scope
  --> src/main.rs:19:3
   |
19 | #[instrument(skip_all)]
   |   ^^^^^^^^^^
   |
help: consider importing one of these items
   |
1  + use tracing::instrument;
   |
1  + use tracing_attributes::instrument;

(I'd also love it if the line between each use suggestions was gone, but that's an extra request.)

Rationale and extra context

Consistency is nice. The playground uses a regex to make these into clickable suggestions, but the regex only matches the latter.

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyT-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