Skip to content
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

Highlighting references feature should highlight unsafe ops #19467

Open
Veykril opened this issue Mar 28, 2025 · 2 comments
Open

Highlighting references feature should highlight unsafe ops #19467

Veykril opened this issue Mar 28, 2025 · 2 comments
Assignees
Labels
A-ide general IDE features C-feature Category: feature request

Comments

@Veykril
Copy link
Member

Veykril commented Mar 28, 2025

When the cursor is on an the unsafe token of an unsafe block we should highlight all the unsafe operations within that unsafe block, similar to how we highlighting await points for asnyc blocks, loop control pointer for loops etc.

@Veykril Veykril added the C-feature Category: feature request label Mar 28, 2025
@Veykril
Copy link
Member Author

Veykril commented Mar 28, 2025

So we want a new branch here

match token.kind() {
T![?] if config.exit_points && token.parent().and_then(ast::TryExpr::cast).is_some() => {
highlight_exit_points(sema, token).remove(&file_id)
}
T![fn] | T![return] | T![->] if config.exit_points => {
highlight_exit_points(sema, token).remove(&file_id)
}
T![await] | T![async] if config.yield_points => {
highlight_yield_points(sema, token).remove(&file_id)
}
T![for] if config.break_points && token.parent().and_then(ast::ForExpr::cast).is_some() => {
highlight_break_points(sema, token).remove(&file_id)
}
T![break] | T![loop] | T![while] | T![continue] if config.break_points => {
highlight_break_points(sema, token).remove(&file_id)
}
T![|] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
T![move] if config.closure_captures => highlight_closure_captures(sema, token, file_id),
_ if config.references => {
highlight_references(sema, token, FilePosition { file_id, offset })
}
_ => None,
}
, leveraging this
pub fn get_unsafe_ops(&self, def: DefWithBody) -> FxHashSet<ExprOrPatSource> {
to get all relevant unsafe operations

@Veykril Veykril added the A-ide general IDE features label Mar 28, 2025
@gohome001
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

2 participants