Repository navigation
const_err spans not rendered when rust-src not installed #97699
Description
Activity
Cc @rust-lang/wg-diagnostics : IMO it is a bug in the rustc diagnostic printing that it entirely omits information attached to spans where the source is missing. Is there anything we can do about that?
We could emit the information as a
noteinstead of a label, but the wording would likely refer to "this blah", making it seem like it's referring to whatever is being pointed at in the main window. That might cause things to be misinterpreted. Another option would be to emit a note whenrustc-srcisn't present asking the user to install it when we encounter cases like this one.- addedA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
on Jun 6, 2022 Has this been resolved by #103970 ?
The error message is
error[E0080]: evaluation of constant value failed | ::: src\main.rs:14:9 | 14 | / ptr::swap_nonoverlapping( 15 | | &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, 16 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, 17 | | mem::size_of::<&i32>(), 18 | | ); | |_________- inside `X` at src\main.rs:14:9 | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supportedwithout
rust-srcinstalled, anderror[E0080]: evaluation of constant value failed --> $HOME\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ptr\mod.rs:1139:9 | 929 | unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } | ----------------------------------------------- inside `swap_nonoverlapping::<MaybeUninit<u8>>` at $HOME\.rustup\toolchains\nightly-x86948 | mem::swap_simple::<MaybeUninit<T>>(x, y); | ---------------------------------------- inside `ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>` at $HOME\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ptr\mod.rs:948:9 ... 1139 | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unable to copy parts of a pointer from memory at alloc6+0x1 | inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` at $HOME\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\ptr\mod.rs:1139:9 | ::: $HOME\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\mem\mod.rs:776:17 | 776 | let a = ptr::read(x); | ------------ inside `mem::swap_simple::<MaybeUninit<MaybeUninit<u8>>>` at $HOME\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\mem\mod.rs:776:17 | ::: src\main.rs:14:9 | 14 | / ptr::swap_nonoverlapping( 15 | | &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, 16 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, 17 | | mem::size_of::<&i32>(), 18 | | ); | |_________- inside `X` at src\main.rs:14:9 | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supportedwith the
rust-srccomponent installed withrustc 1.67.0-nightly (6284998a2 2022-11-12)onx86_64-pc-windows-msvcSo it does not seem entirely resolved -- the 'unable to copy parts of a pointer from memory at alloc6+0x1' is still missing completely when rust-src is not installed.
ugh... I'm slowly wondering if we should enable
-Z simulate-remapped-rust-src-base=/rustc/xyz -Z translate-remapped-path-to-local-path=nofor all ui tests just to actually see the way diagnostics are shown to users normallyYeah if that is possible that would probably be good.
Well... either way, I found a way to fix this specific diagnostic, so once that is landed I'll experiment with unconditionally setting that flag on all ui tests.
- added a commit that references this issue
on Jan 6, 2023
This code causes a const_err somewhere in the standard library:
When the
rust-srcpackage is not installed, the error is pretty unreadable:This is missing the key information of what goes wrong! With
rust-src, the following is added, making it much clearer:If the sources are missing, we should probably still show the error, even if we cannot attach it to any code.
Cc @rust-lang/wg-const-eval