Skip to content

Highlighting references feature should highlight unsafe ops #19467

Closed
@Veykril

Description

@Veykril
Member

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.

Activity

Veykril

Veykril commented on Mar 28, 2025

@Veykril
MemberAuthor

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

gohome001

gohome001 commented on Mar 28, 2025

@gohome001
Contributor

@rustbot claim

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

Metadata

Metadata

Assignees

Labels

A-idegeneral IDE featuresC-featureCategory: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @Veykril@gohome001

    Issue actions

      Highlighting references feature should highlight unsafe ops · Issue #19467 · rust-lang/rust-analyzer