-
Couldn't load subscription status.
- Fork 13.9k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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
extern crate reqwest; // 0.10.9
fn main() {
let s = String::from("http://example.com");
const response = reqwest::get(&s);
}error[E0435]: attempt to use a non-constant value in a constant
--> src/main.rs:5:36
|
5 | const response = reqwest::get(&s);
| ^ non-constant value
I had
const response = self.request(...)when I should have hadlet response = self.request(...)... too much Javascript.
I don't think I equated "a constant" with const foo = ... in my head, because I'm used to doing const foo = bar(...) in Javascript all the time
It would be nice for the error to point to response as the constant:
5 | const response = reqwest::get(&s);
| ^^^^^^^^ constant ^ non-constant value
camelid
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.