Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
shepmaster opened this issue Jun 8, 2023 · 1 comment · Fixed by #112452
Closed

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

shepmaster opened this issue Jun 8, 2023 · 1 comment · Fixed by #112452
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@shepmaster
Copy link
Member

shepmaster commented Jun 8, 2023

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

@shepmaster shepmaster added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 8, 2023
@Noratrieb Noratrieb added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Jun 9, 2023
@mu001999
Copy link
Contributor

mu001999 commented Jun 9, 2023

@rustbot claim

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 9, 2023
…chenkov

Make "consider importing" consistent for macros

Fixes rust-lang#112439
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 9, 2023
…chenkov

Make "consider importing" consistent for macros

Fixes rust-lang#112439
@bors bors closed this as completed in d0ee190 Jun 10, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants