Skip to content

Clean up resolve error reporting #7379

New issue

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

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

Already on GitHub? Sign in to your account

Closed
emberian opened this issue Jun 25, 2013 · 2 comments
Closed

Clean up resolve error reporting #7379

emberian opened this issue Jun 25, 2013 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. metabug Issues about issues themselves ("bugs about bugs")

Comments

@emberian
Copy link
Member

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.

@catamorphism
Copy link
Contributor

I actually implemented a change similar to this in my fix for #6702. I think there are probably some duplicate errors still, but the infrastructure is now there for doing what this bug suggests (I added a flag in the context saying whether or not to emit errors, and a method on the context to run a closure without emitting any errors).

@catamorphism
Copy link
Contributor

I think my changes provide support for doing this -- feel free to open another bug with specific test cases where it still goes wrong. Closing.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 1, 2021
Do not spawn blacklisted_name lint in test context

---

fixed rust-lang#7305

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: `blacklisted_name` lint is not spawned in the test context anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. metabug Issues about issues themselves ("bugs about bugs")
Projects
None yet
Development

No branches or pull requests

2 participants