adambard / adambard/learnxinyminutes-docs

learnrust.rs requires unstable / nightly build

Open
#4,605 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Markdown
Stars
12.3k
Forks
3.7k
Avg merge
13h 10m
Merged PRs (30d)
6

Description

(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

Contributor guide

Open the contributing guide

Research direction

Open learnrust.rs and inspect lines 298 and 310, including the surrounding borrow-checking example. Compile it with the stable Rust toolchain described in the issue and confirm the reported warnings or errors. Done means the example works on stable Rust without requiring nightly features or producing the reported warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.