adambard / adambard/learnxinyminutes-docs

learnrust.rs requires unstable / nightly build

Đang mở
#4,605 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Markdown
Star
12.3k
Fork
3.7k
Merge trung bình
13 giờ 10 phút
Pull request đã merge (30 ngày)
6

Mô tả

(First - apologies - I am new to reporting issues for open source and new to Rust, but otherwise experienced in programming. However, I am probably more likely to hit issues that new learners will hit.)

Lines 298 and 310 of learnrust.rs won't compile for me (without warnings).

$ rustc --version
rustc 1.67.1 (d5a82bbd2 2023-02-07)

Line 298 of learnrust.rs:
ref_var; // no-op, but counts as a use and keeps the borrow active
Line 310 of learnrust.rs:
ref_var2; // no-op, but counts as a use and keeps the borrow active until here

# I set it up like this:

cargo new learnxy
cd learnxy
# copy learnrust.rs here as reference file (won't change)
cd src
cp ../learnrust.rs .
# add "mod learnrust;" to beginning of main.rs
cargo run

~/src/rust/learnxy/src (main)
$ cargo run
Compiling learnxy v0.1.0 (C:\Users\feker\src\rust\learnxy)
warning: path statement with no effect
--> src\learnrust.rs:298:5
|
298 | ref_var; // no-op, but counts as a use and keeps the borrow active
| ^^^^^^^^
|
= note: `#[warn(path_statements)]` on by default

warning: path statement with no effect
--> src\learnrust.rs:310:5
|
310 | ref_var2; // no-op, but counts as a use and keeps the borrow active until here
| ^^^^^^^^^

warning: `learnxy` (bin "learnxy") generated 2 warnings
Finished dev [unoptimized + debuginfo] target(s) in 0.36s
Running `C:\Users\feker\src\rust\learnxy\target\debug\learnxy.exe`
Hello, world!

# I tried #[allow(path_statements)] before 298, which is apparently ignored.

$ cargo run
Compiling learnxy v0.1.0 (C:\Users\feker\src\rust\learnxy)
warning: path statement with no effect
--> src\learnrust.rs:299:5
|
299 | ref_var; // no-op, but counts as a use and keeps the borrow active
| ^^^^^^^^
|
= note: `#[warn(path_statements)]` on by default

# ...

I had also tried #[warn(path_statements)] after that line, to turn the warnings back on, but then got this:

$ cargo run
Compiling learnxy v0.1.0 (C:\Users\feker\src\rust\learnxy)
error[E0658]: attributes on expressions are experimental
--> src\learnrust.rs:300:1
|
300 | #[warn(path_statements)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `learnxy` due to previous error

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.