Skip to content

Report text_direction_codepoint_in_literal when parsing #141004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented May 14, 2025

The lint is now reported in code that gets removed/modified/duplicated by macro expansion, and spans are more accurate so we don't get ICEs from trying to split a span in the middle of a character.

This removes support for lint level attributes for text_direction_codepoint_in_literal except at the crate level, I don't think that there's an easy way around this when the lint can be reported on code that's removed by cfg or that is only in the input of a macro.

Fixes #140281

@rustbot
Copy link
Collaborator

rustbot commented May 14, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 May 14, 2025
@rust-log-analyzer

This comment has been minimized.

- The lint is now reported in code that gets removed/modified/duplicated
  by macro expansion.
- Spans are more accurate
- Fixes rust-lang#140281
@matthewjasper matthewjasper force-pushed the unicode-before-expansion branch from f5d463a to 92445ef Compare May 14, 2025 13:59
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented May 14, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rust-log-analyzer

This comment has been minimized.

@matthewjasper matthewjasper force-pushed the unicode-before-expansion branch from 2f169d6 to c5f6a06 Compare May 15, 2025 12:41
@rust-log-analyzer

This comment has been minimized.

@matthewjasper matthewjasper force-pushed the unicode-before-expansion branch from c5f6a06 to 8e2a331 Compare May 15, 2025 15:23
@@ -3793,7 +3793,7 @@ declare_lint! {
/// ```rust,compile_fail
/// #![deny(text_direction_codepoint_in_comment)]
/// fn main() {
/// println!("{:?}"); // '');
#[doc = " println!(\"{:?}\"); // '\u{202E}');"]
Copy link
Contributor

Choose a reason for hiding this comment

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

why should we use #[doc = "..."] as the example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The example isn't changed here. The attribute is used so that the RLO can be escaped. This is to avoid having to set #![allow(text_direction_codepoint_in_literal)] on the whole crate because the allow attribute no longer works at the item level.

@mu001999
Copy link
Contributor

I think we can find the text in the source of the given span, and then use new span to calculate and collect spans for forbidden chars.

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
5 participants