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 message doesn't give full path in suggestion. #83513

Closed
Lokathor opened this issue Mar 26, 2021 · 3 comments · Fixed by #83673
Closed

Error message doesn't give full path in suggestion. #83513

Lokathor opened this issue Mar 26, 2021 · 3 comments · Fixed by #83673
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Lokathor
Copy link
Contributor

Lokathor commented Mar 26, 2021

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d854c189b0a198c091da3ccf429e0ec9

It suggests adding Sum to the bounds, but Sum is not in scope, so typing directly what it says just leads to another error.

Interestingly, Mul was suggested as std::ops::Mul.

So it should likely suggest the correct prefix for the Sum trait.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 26, 2021
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Mar 26, 2021
@Rustin170506
Copy link
Member

@rustbot claim

@Rustin170506
Copy link
Member

@estebank I've found the corresponding suggest and trait_ref, but I don't know how to get its prefix, do you have any suggestions?

@estebank
Copy link
Contributor

@hi-rustin you'll want to use this function where the suggestion is being created

/// Prevent path trimming if it is turned on. Path trimming affects `Display` impl
/// of various rustc types, for example `std::vec::Vec` would be trimmed to `Vec`,
/// if no other `Vec` is found.
pub fn with_no_trimmed_paths<F: FnOnce() -> R, R>(f: F) -> R {
NO_TRIMMED_PATH.with(|flag| {
let old = flag.replace(true);
let result = f();
flag.set(old);
result
})
}

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 30, 2021
…r=estebank

give full path of constraint in suggest_constraining_type_param

close rust-lang#83513
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2021
…r=estebank

give full path of constraint in suggest_constraining_type_param

close rust-lang#83513
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2021
…r=estebank

give full path of constraint in suggest_constraining_type_param

close rust-lang#83513
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 1, 2021
…r=estebank

give full path of constraint in suggest_constraining_type_param

close rust-lang#83513
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 2, 2021
…r=estebank

give full path of constraint in suggest_constraining_type_param

close rust-lang#83513
@bors bors closed this as completed in 6cb74ad Apr 2, 2021
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-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. 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.

4 participants