Closed
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
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.