-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Type checker gives confusing tip when collecting std::str::Char into std::rc::Rc using std::from::From. #70959
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Hey everyone,
I noticed that when collecting an
std::str::Charsinto astd::rc::RcusingRc::from(...), the compiler tells you to annotate the type on your variable, when you actually need to annotate the type of yourstd::Iter::collect()call.This code produces the bug:
The compiler tells me to annotate the type of
r, which already has a type annotation.In actuality the fix is to annotate the
collect()-call:Meta
I used the following version:
rustc --version --verbose:The current beta (1.43.0-beta.5) and stable (1.42.0) on the rust playground produce the same output.