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

stray #[derive( in possible candidate is found in another module diagnostic #44566

Closed
arielb1 opened this issue Sep 14, 2017 · 9 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. P-high High priority 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.
Milestone

Comments

@arielb1
Copy link
Contributor

arielb1 commented Sep 14, 2017

Meta

This occurs in 539f208 (from 13-09) and 1.21 beta, but not on stable

STR

#[derive(Debug)]
pub struct X;

impl Add for X {} // trigger unused import

fn main() {}

Expected result

On stable, you get a correct candidate suggestion:

   Compiling playground v0.0.1 (file:///playground)
error[E0405]: cannot find trait `Add` in this scope
 --> src/main.rs:4:6
  |
4 | impl Add for X {} // trigger unused import
  |      ^^^ not found in this scope
  |
help: possible candidate is found in another module, you can import it into scope
  |
1 | use std::ops::Add;
  |

Actual Result

The suggestion contains a stray derive:

   Compiling playground v0.0.1 (file:///playground)
error[E0405]: cannot find trait `Add` in this scope
 --> src/main.rs:4:6
  |
4 | impl Add for X {} // trigger unused import
  |      ^^^ not found in this scope
  |
help: possible candidate is found in another module, you can import it into scope
  |
1 | #[derive(use std::ops::Add; <--- STRAY DERIVE IN SUGGESTION
  |

cc @jseyfried @estebank

@arielb1 arielb1 added A-diagnostics Area: Messages for errors, warnings, and lints 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. labels Sep 14, 2017
@arielb1
Copy link
Contributor Author

arielb1 commented Sep 14, 2017

Started a bisection run

@oli-obk
Copy link
Contributor

oli-obk commented Sep 14, 2017

dupe of #44210

@arielb1
Copy link
Contributor Author

arielb1 commented Sep 14, 2017

This is a regression to beta, and the other PR doesn't have a bisection run, so I'm continuing with it.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 14, 2017

Also happens on nightly. Was introduced in #43929

@nikomatsakis
Copy link
Contributor

@oli-obk do you plan to fix this and #44210?

@nikomatsakis
Copy link
Contributor

triage: P-high

@nikomatsakis
Copy link
Contributor

In #44210, which was closed as a duplicate, @oli-obk wrote:

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.

which seems worth preserving.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 14, 2017

I have a fix open as a PR: #44215

It fixes the regular command line output once and for all. But the structured json suggestions are still not right. This is discussed in the PR together with possible solutions. We can merge it as it is and fix the json stuff later. No one is really expecting structured suggestions to be fully correct anyway at the moment.

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 3, 2017

The bad suggestion line was moved to #44995 (because it's not a regression). Closing this issue as it is fixed and backported to beta in #44918.

@arielb1 arielb1 closed this as completed Oct 3, 2017
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. P-high High priority 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

No branches or pull requests

6 participants