Hello,
I entered following lines of code in the https://play.rust-lang.org/, but the output vs. my native compiler on the Debian:
fn main() {
let x = ["a"];
#[warn(unconditional_panic)]
let _y = x[1];
print!("End");
}
I can't see warning: this operation will panic at runtime in the output of the native compiler. Instead, it showed me warning: unknown lint: unconditional_panic.
Compiling playground v0.0.1 (/playground)
warning: this operation will panic at runtime
--> src/main.rs:4:14
|
4 | let _y = x[1];
| ^^^^ index out of bounds: the length is 1 but the index is 1
|
note: the lint level is defined here
--> src/main.rs:3:12
|
3 | #[warn(unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: `playground` (bin "playground") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.71s
Running `target/debug/playground`
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:4:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Hello,
Thank you so much for your reply.
The complete output is:
warning: unknown lint: `unconditional_panic`
--> example.rs:3:12
|
3 | #[warn(unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unknown_lints)]` on by default
error: index out of bounds: the len is 1 but the index is 1
--> example.rs:4:14
|
4 | let _y = x[1];
| ^^^^
|
= note: `#[deny(const_err)]` on by default
error: aborting due to previous error
Like I said, I can't reproduce it. Could you please share a link to your playground? You can create links for sharing your playground code and the exact settings when you click the share button in the upper left hand corner. Then copy the "Permalink to the playground" and insert it here.
Or is the output you just posted from your native system? In which case I misunderstood your question assuming you get the warning: unknown lint: unconditional_panic on the playground.
No, because of the version of Rust that is shipped inside the package for your Debian distribution that you installed. Here's a post about why you shouldn't use the package:
Try installing the newest version of Rust via Rustup (after removing the package, probably by executing apt-get remove rustc or something similar).
Inertia. Distros are generally lagging behind in packaging. I don't know if it's a lack of resources, laziness, or it's not a priority, but it's a general phenomenon.
Distros have different priorities and are largely based around long term support in a traditional dynamic linking environment for various reasons (including defensible ones IMO, but not everyone agrees).
That really depends on the distro. Various rolling-release distros like Void, Arch, Tumbleweed and Rawhide all have 1.70. Arch, Void and Tumbleweed also offer rustup.
Debian is just one of the more slow-moving distros. Which is ok for servers where you don't want stuff to change frequently. But there you shouldn't be running rustc. So the package only serves to build other packages.
If you want to develop software under an up-to-date environment then you have to choose a distro that provides that.
If Debian includes a package for any program in their system they will also package the tools required to build it from source.
If they build that program package with version X of the tools used to build it then they package version X of the tools.
Now, if the tools are upgraded to version Y Debian cannot use ship a new package of the tools at version Y. Because if they do they risk something breaking. Perhaps version Y no longer builds that program. They would have to rebuild and ship new tools and new program ignorer to provide a stable system. That is a lot of work in testing and packaging etc.
Imagine they shipped a new version of the GCC compiler, that would risk breaking a huge amount of programs in the system. Breaking as in the compiler can no longer build everything reliably.
Presumably there are packages available in Debian that are built with Rust. So you get whatever old version of Rust they used to do that. With anew Debian release no doubt Rust will be updated and all those Rust packages rebuilt, retested etc.
It's all about stability. Not stability as in bug free and not crashing exactly, but stability of being able to build a working system. All parts work together.
For this reason one should never use the Debian package version of Rust for ones own development, it's there only to build Debian itself, it will likely be old. This also applies to other languages like Javascript (node.s) it even applies to the C++ compilers if you want the latest C++ standard features.