Error i8::MAX – 常量 `MAX` 是私有的 [E0603]

huangapple go评论57阅读模式
英文:

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:

  1. The MAX on i8::MAX is indicated with an error that, Constant MAX is private [E0603]. That seems wrong.
  2. 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:

  1. The MAX on i8::MAX is indicated with an error that, Constant MAX is private [E0603]. That seems wrong.
  2. 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.

huangapple
  • 本文由 发表于 2023年5月22日 06:41:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76302213.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定