-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
overflowing_literals error is confusing because of type inference #79744
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.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 lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.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.
While experimenting with the Rust By Example playground on the Inference section at https://doc.rust-lang.org/stable/rust-by-example/types/inference.html I came across what I believe is an error in the error produced by the compiler.
I do not expect this example to work but the error
literal out of range for 'i8'is reported against line 4let e2 = 230;which is a perfectly valid statement. The problem is lower down where two different types are pushed onto the same Vector but possibly due to the way the inference engine works this is being incorrectly reported against line 4. If I comment out the linevec.push(e2);, the example works fine, apart from awarning: unused variable: 'e2'.Code
Meta
rustc --version --verbose: I am unable to determine the exact compiler version in the Rust By Example playground. I have run the same example on my Fedora 32 Workstation machine and with the same result. The rustc version details for this machine are as followsError output
Backtrace
Sorry I don't know exactly how to provide this.