@@ -491,7 +491,7 @@ pub fn semantic_diagnostics(
491491
492492 // The edition isn't accurate (each diagnostics may have its own edition due to macros),
493493 // but it's okay as it's only being used for error recovery.
494- handle_lint_attributes (
494+ handle_lints (
495495 & ctx. sema ,
496496 & mut FxHashMap :: default ( ) ,
497497 & mut lints,
@@ -551,14 +551,27 @@ fn build_group_dict(
551551 map_with_prefixes. into_iter ( ) . map ( |( k, v) | ( k. strip_prefix ( prefix) . unwrap ( ) , v) ) . collect ( )
552552}
553553
554- fn handle_lint_attributes (
554+ /// Thd default severity for lints that are not warn by default.
555+ // FIXME: Autogenerate this instead of write manually.
556+ static LINTS_DEFAULT_SEVERITY : LazyLock < FxHashMap < & str , Severity > > =
557+ LazyLock :: new ( || FxHashMap :: from_iter ( [ ( "unsafe_op_in_unsafe_fn" , Severity :: Allow ) ] ) ) ;
558+
559+ fn handle_lints (
555560 sema : & Semantics < ' _ , RootDatabase > ,
556561 cache : & mut FxHashMap < HirFileId , FxHashMap < SmolStr , SeverityAttr > > ,
557562 diagnostics : & mut [ ( InFile < SyntaxNode > , & mut Diagnostic ) ] ,
558563 cache_stack : & mut Vec < HirFileId > ,
559564 edition : Edition ,
560565) {
561566 for ( node, diag) in diagnostics {
567+ let lint = match diag. code {
568+ DiagnosticCode :: RustcLint ( lint) | DiagnosticCode :: Clippy ( lint) => lint,
569+ _ => panic ! ( "non-lint passed to `handle_lints()`" ) ,
570+ } ;
571+ if let Some ( & default_severity) = LINTS_DEFAULT_SEVERITY . get ( lint) {
572+ diag. severity = default_severity;
573+ }
574+
562575 let mut diag_severity = fill_lint_attrs ( sema, node, cache, cache_stack, diag, edition) ;
563576
564577 if let outline_diag_severity @ Some ( _) =
0 commit comments