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

#[derive] suggestion should check for local struct #37522

Closed
durka opened this issue Nov 1, 2016 · 3 comments · Fixed by #47613
Closed

#[derive] suggestion should check for local struct #37522

durka opened this issue Nov 1, 2016 · 3 comments · Fixed by #47613
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@durka
Copy link
Contributor

durka commented Nov 1, 2016

Consider this code:

struct Foo;

fn main() {
    println!("{:?} {:?}",
      /* 1 */ Foo,
      /* 2 */ std::fs::OpenOptions::new());
}

Both marked lines print the error that Debug is not satisfied and note that "if it is defined in your crate, add #[derive(Debug)] or manually implement it". The compiler should be able to check and issue the note only for (1), instead of printing the confusing "if it is defined in your crate".

@Mark-Simulacrum
Copy link
Member

This message is currently printed using #[rustc_on_unimplemented = "..."], so I feel like fixing this will be non-trivial. I'd be willing to try and so, though, if someone could provide some pointers.

@durka
Copy link
Contributor Author

durka commented Nov 2, 2016

So either we need to move it into the compiler, or add another hack like #[rustc_on_unimplemented_for_local]/#[rustc_on_unimplemented_for_remote].

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label May 7, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@zackmdavis
Copy link
Member

(Issue to improve rustc_on_unimplemented is #44755.)

Manishearth added a commit to Manishearth/rust that referenced this issue Feb 7, 2018
…nikomatsakis

Add filtering options to `rustc_on_unimplemented`

- Add filtering options to `rustc_on_unimplemented` for local traits, filtering on `Self` and type arguments.
- Add a way to provide custom notes.
- Tweak binops text.
- Add filter to detect wether `Self` is local or belongs to another crate.
- Add filter to `Iterator` diagnostic for `&str`.

Partly addresses rust-lang#44755 with a different syntax, as a first approach. Fixes rust-lang#46216, fixes rust-lang#37522, CC rust-lang#34297, rust-lang#46806.
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-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants