Skip to content

Help message when importing item from wrong module is wrong #105566

Closed
@Aloso

Description

@Aloso

Given the following code: playground link

use serde::{Serialize, IgnoredAny};

The current output is:

error[E0432]: unresolved import `serde::IgnoredAny`
 --> src/lib.rs:1:24
  |
1 | use serde::{Serialize, IgnoredAny};
  |                        ^^^^^^^^^^ no `IgnoredAny` in the root
  |
help: consider importing this struct instead
  |
1 | use serde::{Serialize, serde::de::IgnoredAny;
  |                        ~~~~~~~~~~~~~~~~~~~~~~

The help message is wrong for two reasons:

  • The closing bracket is missing
  • The crate name (serde) is repeated in the path, so the suggested code would import serde::serde::de::IgnoredAny instead of serde::de::IgnoredAny.

Ideally the output should look like:

help: consider importing this struct instead
  |
1 | use serde::{Serialize, de::IgnoredAny};
  |                        ~~~~~~~~~~~~~~

Note that the help message was only added recently, so this bug exists only on beta and nightly at the moment.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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