英文:
Error i8::MAX - Constant `MAX` is private [E0603]
问题
I'm following a beginner's tutorial on Rust. At one point the lecturer printed out std::i8::MAX. I followed suit and noticed that IntelliJ was flagging std::i8::MAX as deprecated.
Following the link to, https://doc.rust-lang.org/core/i8/constant.MAX.html
It shows:
// intended way
let max = i8::MAX;
So I've updated this simple code to follow the recommendation:
fn main() {
let x:i8 = i8::MAX;
println!("i8::MAX = {}",x);
}
However, now there are 2 interesting issues:
- The MAX on i8::MAX is indicated with an error that, Constant
MAX
is private [E0603]. That seems wrong. - The code actually executes, even with the Rust compiler error. If the constant MAX is private, shouldn't I not have access to it? Why does it even run, let alone provide the correct following output:
i8::MAX = 127
I'm running the latest version of IntelliJ with the Rust plugin. I've installed Rust for the first time on this Win 11 PC. Running...
rustc --version
returns
rustc 1.69.0 (84c898d65 2023-04-16)
英文:
I'm following a beginner's tutorial on Rust. At one point the lecturer printed out std::i8::MAX. I followed suit and noticed that IntelliJ was flagging std::i8::MAX as deprecated.
Following the link to, https://doc.rust-lang.org/core/i8/constant.MAX.html
It shows:
// intended way
let max = i8::MAX;
So I've updated this simple code to follow the recommendation:
fn main() {
let x:i8 = i8::MAX;
println!("i8::MAX = {}",x);
}
However, now there are 2 interesting issues:
- The MAX on i8::MAX is indicated with an error that, Constant
MAX
is private [E0603]. That seems wrong. - The code actually executes, even with the Rust compiler error. If the constant MAX is private, shouldn't I not have access to it? Why does it even run, let alone provide the correct following output:
i8::MAX = 127
I'm running the latest version of IntelliJ with the Rust pluggin. I've installed Rust for the first time on this Win 11 PC. Running...
rustc --version
returns
rustc 1.69.0 (84c898d65 2023-04-16)
答案1
得分: 1
这是IntelliJ中的一个错误:https://github.com/intellij-rust/intellij-rust/issues/10483。
英文:
Apparently this is a bug in IntelliJ: https://github.com/intellij-rust/intellij-rust/issues/10483.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论