Merge pull request #20547 from ChayimFriedman2/highlight-related-unsafe-scope
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run

fix: In highlight_related, when on an unsafe block, don't highlight unsafe operations of other unsafe blocks
This commit is contained in:
Laurențiu Nicola 2025-08-27 19:09:21 +00:00 committed by GitHub
commit 968fc01fa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 10 deletions

View file

@ -119,11 +119,11 @@ pub fn unsafe_operations(
def: DefWithBodyId,
body: &Body,
current: ExprId,
callback: &mut dyn FnMut(InsideUnsafeBlock),
callback: &mut dyn FnMut(ExprOrPatId, InsideUnsafeBlock),
) {
let mut visitor_callback = |diag| {
if let UnsafeDiagnostic::UnsafeOperation { inside_unsafe_block, .. } = diag {
callback(inside_unsafe_block);
if let UnsafeDiagnostic::UnsafeOperation { inside_unsafe_block, node, .. } = diag {
callback(node, inside_unsafe_block);
}
};
let mut visitor = UnsafeVisitor::new(db, infer, body, def, &mut visitor_callback);