"implement the missing item: …" suggestion does not substitute type parameter #89220
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0bc82986aeab6421699562569505aa40
The current output is:
(Note: The whitespace in strings is probably not real due to my manual JSON prettification.)
compiler-message json
(with
"suggested_replacement": "fn a(&self) -> &T { todo!() }\n"
and its message being invalid)Ideally the output should look like:
compiler-message json
(with
"suggested_replacement": "fn a(&self) -> &B { todo!() }\n"
and its message being valid)This seems like something the compiler could in theory take care of, and it's not always immediately clear to the programmer (that is: me) why exactly there's an error highlighted if there's another
T
like in the example above.That said, the error message resulting from the invalid suggestion already does a fairly decent job of pointing out the fix here, and the suggestion there ("change the output type to match the trait:
&B
") is correct.I first misfiled this as rust-lang/rust-analyzer#10327 after reporting rust-lang/rust-analyzer#10326. If the generic type parameter is expanded to something like
dyn 'a + Trait
, it would also need to be parenthesised in some cases.The text was updated successfully, but these errors were encountered: