Skip to content

Suggest use if import, using, or require is used instead #100140

Closed

Description

I was looking at namely issue #99751 when I thought about this. If work is being put into improving error messages when somebody uses a keyword that defines a function in another language, there should also be improved error messages if someone uses the incorrect directive to bring something into the scope of their module or namespace/

Given the following code: Playground Link

import std::mem;
using std::mem;
require std::mem;

The current output is:

error: expected one of `!` or `::`, found `std`
 --> src/main.rs:1:8
  |
1 | import std::mem;
  |        ^^^ expected one of `!` or `::`

error: could not compile `playground` due to previous error

The error message should preferably suggest the user to use the use directive to bring something into scope of their module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

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