diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index 349ba9ab6..596caf18b 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -359,9 +359,10 @@ impl Lexer<'_> { if ident == "allow" { SyntaxKind::AnnotationName } else { - let error = self.error(eco_format!("invalid annotation name")); + self.error(eco_format!("invalid annotation name")); self.hint("must be 'allow'"); - error + + SyntaxKind::Error } } diff --git a/crates/typst/src/diag.rs b/crates/typst/src/diag.rs index 2e4437c7b..cae6ccac4 100644 --- a/crates/typst/src/diag.rs +++ b/crates/typst/src/diag.rs @@ -537,17 +537,8 @@ fn check_annotation_suppresses_warning( annotation: ast::Annotation, warning: &str, ) -> bool { - if annotation.name().as_str() != "allow" { - return false; - } - - for argument in annotation.arguments() { - if warning == argument.get() { - return true; - } - } - - false + annotation.name().as_str() == "allow" + && annotation.arguments().any(|arg| arg.get() == warning) } /// A result type with a file-related error.