rust-lang / rust-lang/rust-playground
Error spans into the standard library are missing because rust-src is not installed
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 267
- Avg merge
- 3h 2m
- Merged PRs (30d)
- 6
Description
Consider this code:
#![feature(const_swap)]
#![feature(const_mut_refs)]
use std::{
mem::{self, MaybeUninit},
ptr,
};
const X: () = {
let mut ptr1 = &1;
let mut ptr2 = &2;
// Swap them, bytewise.
unsafe {
ptr::swap_nonoverlapping(
&mut ptr1 as *mut _ as *mut MaybeUninit<u8>,
&mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
mem::size_of::<&i32>(),
);
}
};
Locally, this renders an error like this:
error: any use of this value will cause an error
--> /home/r/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1151:9
|
1151 | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unable to turn pointer into raw bytes
| inside `std::ptr::read::<MaybeUninit<u8>>` at /home/r/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1151:9
| inside `mem::swap_simple::<MaybeUninit<u8>>` at /home/r/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:768:17
| inside `ptr::swap_nonoverlapping_simple::<MaybeUninit<u8>>` at /home/r/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:968:9
| inside `swap_nonoverlapping::<MaybeUninit<u8>>` at /home/r/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:949:14
| inside `X` at test.rs:14:9
|
::: test.rs:8:1
|
8 | / const X: () = {
9 | | let mut ptr1 = &1;
10 | | let mut ptr2 = &2;
11 | |
... |
19 | | }
20 | | };
| |__-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
However, on the playground, it looks like this:
error: any use of this value will cause an error
|
::: src/lib.rs:8:1
|
8 | / const X: () = {
9 | | let mut ptr1 = &1;
10 | | let mut ptr2 = &2;
11 | |
... |
19 | | }
20 | | };
| |__-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, [see issue #71800 <https://github.com/rust-lang/rust/issues/71800>](https://github.com/rust-lang/rust/issues/71800)
In particular, the actual message of what went wrong ("unable to turn pointer into raw bytes") and the span of where that happened are missing!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust Playground toolchain setup and how it provides rust-src to compiler runs. Reproduce the issue with the Rust code in the report, then compare local and Playground diagnostics; done means the Playground includes the underlying error message and source span.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100