rust/compiler/rustc_parse
Chris Denton 8089e317b5
Rollup merge of #139921 - Kivooeo:master, r=WaffleLapkin
improve diagnostic for raw pointer field access with ->

This PR enhances the error messages emitted by the Rust compiler when users attempt to use the `->` operator for field access on raw pointers or when dereferencing is needed. The changes aim to provide clearer guidance, by suggesting the correct use of the `.` operator and explicit dereferencing.

**Before:**
```
help: `xs` is a raw pointer; try dereferencing it
   |
LL |         (*xs)->count += 1;
   |         ++  +
```

**Now:**
```
help: use `.` on a dereferenced raw pointer instead
   |
LL -         xs->count += 1;
LL +         (*xs).count += 1;
   |
```

I added extra clarification in the message. Since this error occurs in the parser, we can't be certain that the type is a raw pointer. That's why the message includes only a small note in brackets. (In contrast, the message above is emitted in HIR, where we *can* check whether it's a raw pointer.)

**Before:**
```
  --> main.rs:11:11
   |
11 |         xs->count += 1;
   |           ^^
   |
   = help: the . operator will dereference the value if needed
```
**After:**
```
--> main.rs:11:11
   |
11 |         xs->count += 1;
   |           ^^
   |
   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
```
2025-04-22 15:24:05 +00:00
..
src Auto merge of #132833 - est31:stabilize_let_chains, r=fee1-dead 2025-04-22 07:54:10 +00:00
Cargo.toml Update rustc-literal-escaper version to 0.0.2 2025-04-04 22:26:10 +02:00
messages.ftl improve diagnostic for raw pointer field access using -> 2025-04-22 00:53:12 +05:00