fix decorator lookup next to the span itself

This commit is contained in:
PgBiel 2024-06-13 22:40:55 -03:00
parent 26ae1d3c27
commit e69c58a234

View File

@ -261,12 +261,14 @@ fn check_warning_suppressed(
// The source must exist if a warning occurred in the file, // The source must exist if a warning occurred in the file,
// or has a tracepoint in the file. // or has a tracepoint in the file.
let source = world.source(file).unwrap(); let source = world.source(file).unwrap();
// The span must point to this source file, so we unwrap.
let mut node = &source.find(span).unwrap();
// Walk the parent nodes to check for a warning suppression. let search_root = source.find(span);
while let Some(parent) = node.parent() { let mut searched_node = search_root.as_ref();
if let Some(sibling) = parent.prev_attached_comment() {
// Walk the parent nodes to check for a warning suppression in the
// previous line.
while let Some(node) = searched_node {
if let Some(sibling) = node.prev_attached_comment() {
if let Some(comment) = sibling.cast::<ast::LineComment>() { if let Some(comment) = sibling.cast::<ast::LineComment>() {
if matches!(parse_warning_suppression(comment.content()), Some(suppressed) if identifier.name() == suppressed) if matches!(parse_warning_suppression(comment.content()), Some(suppressed) if identifier.name() == suppressed)
{ {
@ -274,7 +276,7 @@ fn check_warning_suppressed(
} }
} }
} }
node = parent; searched_node = node.parent();
} }
false false