Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

learnrust.rs requires unstable / nightly build #4605

Open
fekerr opened this issue Feb 25, 2023 · 0 comments
Open

learnrust.rs requires unstable / nightly build #4605

fekerr opened this issue Feb 25, 2023 · 0 comments

Comments

@fekerr
Copy link

fekerr commented Feb 25, 2023

(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 rust-lang/rust#15701 for more information

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant