Skip to content

Clean up resolve error reporting #7379

@emberian

Description

@emberian

Currently, resolve does a lot of redundant error reporting. For example,

/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: unresolved name
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~
/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: use of undeclared module `ast`
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~
/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: `ast::ident` does not name a structure
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~

This should be a single error, "error: use of undeclared module ast".

Another example:

/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: unresolved name
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~
/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: use of undeclared module `ast`
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~
/home/cmr/hacking/rust/src/libextra/interner.rs:161:8: 161:18 error: `ast::ident` does not name a structure
/home/cmr/hacking/rust/src/libextra/interner.rs:161         ast::ident { repr: off, ctxt: 0 }
                                                            ^~~~~~~~~~

Fixing this will require careful finagling of resolve. The best way to handle this is probably some central error reporting infrastructure, and as soon as one error is reported, stop making new errors for the current span. This is going to be tricky because every error path needs to be followed to ensure that an error is reported, and that if only one error is reported, it is the right error. Needs vastly improved test coverage in compile-fail. Shouldn't be hard, but will take time.

Nominating for production-ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.metabugIssues about issues themselves ("bugs about bugs")

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions