Diagnostics differ between regular execution and ui tests
Open
Nobody has claimed this yet.
A-compiletest
A-diagnostics
D-diagnostic-infra
T-bootstrap
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Consider this example:
fn main() {
let val = 2;
let ptr = std::ptr::addr_of!(val);
unsafe { *ptr = 3; }
}
On the playground and when I run it locally, this produces:
error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
--> src/main.rs:6:14
|
6 | unsafe { *ptr = 3; }
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
|
help: consider changing this to be a mutable pointer
--> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:2207:6
|
22| &mut raw const $place
| +++
However, when I make this a ui test, I get different output:
error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
--> /home/r/src/rust/rustc.2/tests/ui/mytest.rs:5:14
|
LL | unsafe { *ptr = 3; }
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
|
help: consider specifying this binding's type
|
LL | let ptr: *mut i32 = std::ptr::addr_of!(val);
| ++++++++++
That's... not great? We're supposed to test what users see, and something seems to be going wrong.
Cc @rust-lang/wg-diagnostics
Contributor guide
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 reproducer in tests/ui/mytest.rs and compare its UI-test output with the diagnostic from regular execution or the playground. Trace how the UI test harness selects and renders the help suggestion. Done means the UI test reports the same relevant suggestion and source location as regular execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100