Skip to content

Trait suggestions should use outermost candidates #31323

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
AndiDog opened this issue Jan 31, 2016 · 3 comments
Closed

Trait suggestions should use outermost candidates #31323

AndiDog opened this issue Jan 31, 2016 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@AndiDog
Copy link
Contributor

AndiDog commented Jan 31, 2016

Beginning with issue #21405, Rust combines multiple identical candidates into one (in some way). Since crates typically pub use the traits on the outermost level (e.g. module::TheTrait instead of module::inner::detail::TheTrait), the outermost candidate should be displayed as suggestion.

Here's a real-life example:

main.rs:44:21: 44:62 error: no method named `json_as` found for type `&'r mut nickel::request::Request<'mw, 'conn, _>` in the current scope
main.rs:44                let dir = request.json_as::<BlaBla>().unwrap().dir;
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<nickel macros>:24:12: 24:42 note: in this expansion of as_block! (defined in <nickel macros>)
<nickel macros>:10:1: 10:60 note: in this expansion of _middleware_inner! (defined in <nickel macros>)
main.rs:43:47: 48:3 note: in this expansion of middleware! (defined in <nickel macros>)
main.rs:44:21: 44:62 help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
main.rs:44:21: 44:62 help: candidate #1: use `nickel::json_body_parser::JsonBody`

However the trait "JsonBody" can be imported with just use nickel::JsonBody.

@Aatch
Copy link
Contributor

Aatch commented Feb 1, 2016

I'm not sure what the code is doing there, but using the shortest path version might be acceptable.

@Aatch Aatch added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 1, 2016
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
@steveklabnik
Copy link
Member

Triage: I can't reproduce this because there aren't good enough instructions; could you provide some example code that triggers this? Thanks!

@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 25, 2019
@Dylan-DPC
Copy link
Member

Closing this as this issue is vague and there's no further updates on it.

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2023
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. 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