Skip to content

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Nov 22, 2025

Fixes #148917

seems add two notes seems better.

r? @scottmcm

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2025
@scottmcm
Copy link
Member

The two-notes approach looks reasonable to me in the same error, but I really don't know anything about this part of the compiler so I'm going to reroll, sorry.
r? diagnostics

@rustbot rustbot assigned davidtwco and unassigned scottmcm Nov 22, 2025
@Kivooeo Kivooeo assigned Kivooeo and unassigned davidtwco Nov 22, 2025
@Kivooeo
Copy link
Member

Kivooeo commented Nov 23, 2025

I'm not 100% sure about note here, it feels to me that help would be better, because we are trying to help user to fix their incorrect code but I can be wrong about when to use each so correct me here

@chenyukang
Copy link
Member Author

I'm not 100% sure about note here, it feels to me that help would be better, because we are trying to help user to fix their incorrect code but I can be wrong about when to use each so correct me here

I'm neutral for note or help in this case, anyway, I changed it into help.

Comment on lines 64 to 69
error: out of range hex escape
--> $DIR/out-of-range-hex-escape-suggestions-148917.rs:18:11
|
LL | dbg!("\xFFFFF");
| ^^^^ must be a character in the range [\x00-\x7f]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last one question and we are good to go: is this intended to have span like this for a string with len more than 4?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, i think it's better to point to the span of full literal, fixed it.

Copy link
Member

@Kivooeo Kivooeo Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like supporting strings is a bit painful, like for example

error: out of range hex escape
 --> /home/gh-Kivooeo/test_/src/main.rs:2:11
  |
2 |      dbg!(" this is some kind of string \xa7");
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ must be a character in the range [\x00-\x7f]

error: aborting due to 1 previous error

which is not 100% correct, while I understand that calculating a precise span would be a challenging, would it be reasonable to remove string support for now and make it char only, it also will make implementation easier from what I see

upd: the current nightly already shows correct span

error: out of range hex escape
 --> src/main.rs:2:40
  |
2 |     dbg!(" this is some kind of string \xa7");
  |                                        ^^^^ must be a character in the range [\x00-\x7f]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see, we can't actually remove string support, I originally thought that we can because of this line, but it actually means not much matches!(mode, Mode::Char | Mode::Str)

so... idk, any ideas on this? Maybe we could somehow extend original err_span

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Out-of-range \x escapes should suggest alternatives

5 participants