Skip to content
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

Error suggestions for import contain erroneous derive #44210

Closed
nrc opened this issue Aug 31, 2017 · 3 comments · Fixed by #44215
Closed

Error suggestions for import contain erroneous derive #44210

nrc opened this issue Aug 31, 2017 · 3 comments · Fixed by #44215
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nrc
Copy link
Member

nrc commented Aug 31, 2017

E.g.,

error[E0412]: cannot find type `Path` in this scope
  --> src/actions/compiler_message_parsing.rs:77:55
   |
77 | fn make_suggestions(message: &CompilerMessage, file: &Path) -> Vec<Suggestion> {
   |                                                       ^^^^ not found in this scope
   |
help: possible candidates are found in other modules, you can import them into scope
   |
20 | #[derive(use build::rustc::rustc::hir::Path;
   |
20 | #[derive(use build::rustc::syntax::ast::Path;
   |
20 | #[derive(use std::path::Path;

cc @oli-obk

@nrc nrc added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 31, 2017
@nrc
Copy link
Member Author

nrc commented Aug 31, 2017

The first non-comment, non-use line in the file is #[derive(Debug)], which might be where this is coming from?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 31, 2017

No, the first item is inside the expansion. We need a macro check. I don't think Rust's lints have any, but clippy has a convenience function in almost every lint. We should probably upstream it. There are so many diagnostics that choke on expansions.

@shepmaster shepmaster added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 1, 2017
@arielb1 arielb1 added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Sep 14, 2017
@nikomatsakis
Copy link
Contributor

Closing as duplicate of #44566.

bors added a commit that referenced this issue Sep 21, 2017
don't suggest placing `use` statements into expanded code

r? @nrc

fixes #44210

```rust
#[derive(Debug)]
struct Foo;

type X = Path;
```

will try to place `use std::path::Path;` between `#[derive(Debug)]` and `struct Foo;`

I am not sure how to obtain a span before the first attribute, because derive attributes are removed during expansion.

It would be trivial to detect this case and place the `use` after the item, but that would be somewhat weird I think.
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 C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants