Skip to content

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Jan 8, 2026

Example

with config strings: false

fn main() {
    format_args!("foo\nbar\invalid");
}

Before this PR

fn main() {
    format_args!("foo\nbar\invalid");
                  // ^^ EscapeSequence
                       // ^^ InvalidEscapeSequence
}

After this PR

fn main() {
    format_args!("foo\nbar\invalid");
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2026
let mut hl = highlights::Highlights::new(root.text_range());
let krate = sema.scope(&root).map(|it| it.krate());
traverse(&mut hl, &sema, config, InRealFile::new(file_id, &root), krate, range_to_highlight);
hl.retain_mut(|hl_range| filter_by_config(&mut hl_range.highlight, config));
Copy link
Member Author

Choose a reason for hiding this comment

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

Is it better to filter the entire tree here, or is it better to pass config to each add?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it's better to filter on the spot, not the entire tree. This is faster, and the tree can be large.

self.root.add(hl_range);
}

pub(crate) fn retain_mut(&mut self, mut f: impl FnMut(&mut HlRange) -> bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can call this just retain(), the reason Vec::retain_mut() is named this way is due to a past mistake and it's IMO not a good name. Ditto for below.

let mut hl = highlights::Highlights::new(root.text_range());
let krate = sema.scope(&root).map(|it| it.krate());
traverse(&mut hl, &sema, config, InRealFile::new(file_id, &root), krate, range_to_highlight);
hl.retain_mut(|hl_range| filter_by_config(&mut hl_range.highlight, config));
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it's better to filter on the spot, not the entire tree. This is faster, and the tree can be large.

Example
---
with config `strings: false`

```rust
fn main() {
    format_args!("foo\nbar\invalid");
}
```

**Before this PR**

```rust
fn main() {
    format_args!("foo\nbar\invalid");
                  // ^^ EscapeSequence
                       // ^^ InvalidEscapeSequence
}
```

**After this PR**

```rust
fn main() {
    format_args!("foo\nbar\invalid");
}
```
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

Thanks!

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Jan 9, 2026
Merged via the queue into rust-lang:master with commit 4ff04e5 Jan 9, 2026
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 9, 2026
@A4-Tacks A4-Tacks deleted the disable-string-hl branch January 9, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants