Skip to content

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

@Lokathor

Description

@Lokathor
Contributor

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.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-papercutDiagnostics: An error or lint that needs small tweaks.
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Mar 26, 2021
added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
on Mar 26, 2021
0xPoe

0xPoe commented on Mar 27, 2021

@0xPoe
Member

@rustbot claim

0xPoe

0xPoe commented on Mar 29, 2021

@0xPoe
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

estebank commented on Mar 30, 2021

@estebank
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
})
}

added a commit that references this issue on Mar 30, 2021
51fa639
added 2 commits that reference this issue on Mar 31, 2021
918166e
cb59053

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @estebank@Lokathor@JohnTitor@0xPoe

    Issue actions

      Error message doesn't give full path in suggestion. · Issue #83513 · rust-lang/rust