Repository navigation
Closed
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I think the suggestion is trying to suggest a type, but gets a TyKind::Error due to the type error in the body of the const. Ideally we would just not suggest a type, but there are probably a lot of other places that this issue occurs.
const FOO = "hello" + 1;Errors:
Compiling playground v0.0.1 (/playground)
error[E0369]: cannot add `{integer}` to `&str`
--> src/lib.rs:1:21
|
1 | const FOO = "hello" + 1;
| ------- ^ - {integer}
| |
| &str
error: missing type for `const` item
--> src/lib.rs:1:7
|
1 | const FOO = "hello" + 1;
| ^^^ help: provide a type for the item: `FOO: [type error]`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0369`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Reacted by oli, Esteban Kuber, chansuke, Aaron Hill and Henry Boisdequin
Metadata
Metadata
Assignees
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
oli-obk commentedon Nov 14, 2020
Fix instructions:
provide a type for the itemsuggestion is emittedty::Errty::FnDef(const FOO = main; fn main() {}gives that)ty::Closureoli-obk commentedon Nov 14, 2020
Cool! You can mark yourself as workin on this issue by writing
@rustbot claimin it. Feel free to ask away with anything that is unclear. Or actually, just anything ^^ If you prefer chat over github messages, you can also reach out in zulip by opening a new thread.oli-obk commentedon Nov 26, 2020
I like the
delay_as_bug()variant more.Though I think we should add an
ignoremethod that takes aDelaySpanBugEmitted, which we get from thety::Error. What do you think @rust-lang/wg-diagnosticspetar-dambovaliev commentedon Nov 30, 2020
Shouldn't it also be
cannot add `&str` to `{integer}, same order as in the code?1 remaining item
oli-obk commentedon Nov 30, 2020
The order is indeed odd, but at least grammatically correct. If you have
5 + 6, you are adding6to5. This along with another order swap around<SomeType as Add<OtherType>>being for animpl Add<OtherType> for SomeTypeand meaning an operationvalue_of_some_type + value_of_other_type. I think we could have an entire design meeting just around how to get all of that into a diagnostic without causing more confusion than the status quo. If you want you can open an issue about just the order confusion, I'll add the appropriate tags.estebank commentedon Nov 30, 2020
I'm concerned about the possibility of there being a case where
[type error]is generated without any other error (but that shouldn't happen). The_case is weird and I think we should emit the error in that case (although maybe not a suggestion, but not the end of the world). I like the possibility of usingemit_unless:petar-dambovaliev commentedon Dec 1, 2020
I don't know enough about the language design space to be opening up meaningful issues. I was just making a comment. I don't know whether it's an issue or not and I certainly don't want to create issues that will be closed immediately.
estebank commentedon Dec 1, 2020
@petar-dambovaliev That shouldn't stop you. Some times there are things that the team hasn't yet noticed and it is a good idea to rise the point. Other times tickets are duplicated but that is also a useful signal that can be a proxy for urgency.
We treat these kind of issues seriously. We rarely immediately close tickets around here unless they are a duplicate (where we close with a link) or completely off-topic (where we point of more reasonable venues). If you still feel this comment isn't worth a new ticket but still want to have a conversation around it, feel free to visit https://internals.rust-lang.org/ and start a new thread.
IIRC, I am the one that wrote that message and I went back and forth between a sentence that made grammatical sense and one that looked like the provided code, and landed in the current message and a main label in the order of the code. Since the output has changed slightly and the later has been "lost". As the "culprit" of the current state, I welcome any conversation around this. That's how we improve :)
Fix diagnostic suggests adding type `[type error]`
henryboisdequin commentedon Mar 3, 2021
@rustbot claim
#82720 is open :)
Rollup merge of rust-lang#82720 - henryboisdequin:fix-79040, r=oli-obk
Rollup merge of rust-lang#82720 - henryboisdequin:fix-79040, r=oli-obk
Rollup merge of rust-lang#82720 - henryboisdequin:fix-79040, r=oli-obk
Rollup merge of rust-lang#82720 - henryboisdequin:fix-79040, r=oli-obk
Rollup merge of rust-lang#82720 - henryboisdequin:fix-79040, r=oli-obk