Skip to content

Suggest to move/copy use statement from parent into inline module declaration #40341

Closed
@Mark-Simulacrum

Description

@Mark-Simulacrum

Given the below Rust code, we can probably produce a more user friendly error message than today's "failed to resolve. Use of undeclared type or module File".

use std::fs::File;

mod foo {
    fn some_function(f: File) {}
}

It'd be nice to suggest something like "Possibly move use std::fs::File from outer scope into module foo". This will help beginners understand how to deal with the File use in the parent module not being in scope within the child module.

Metadata

Metadata

Assignees

No one assigned

    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