@@ -491,7 +491,7 @@ pub fn semantic_diagnostics(
491
491
492
492
// The edition isn't accurate (each diagnostics may have its own edition due to macros),
493
493
// but it's okay as it's only being used for error recovery.
494
- handle_lint_attributes (
494
+ handle_lints (
495
495
& ctx. sema ,
496
496
& mut FxHashMap :: default ( ) ,
497
497
& mut lints,
@@ -551,14 +551,27 @@ fn build_group_dict(
551
551
map_with_prefixes. into_iter ( ) . map ( |( k, v) | ( k. strip_prefix ( prefix) . unwrap ( ) , v) ) . collect ( )
552
552
}
553
553
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 (
555
560
sema : & Semantics < ' _ , RootDatabase > ,
556
561
cache : & mut FxHashMap < HirFileId , FxHashMap < SmolStr , SeverityAttr > > ,
557
562
diagnostics : & mut [ ( InFile < SyntaxNode > , & mut Diagnostic ) ] ,
558
563
cache_stack : & mut Vec < HirFileId > ,
559
564
edition : Edition ,
560
565
) {
561
566
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
+
562
575
let mut diag_severity = fill_lint_attrs ( sema, node, cache, cache_stack, diag, edition) ;
563
576
564
577
if let outline_diag_severity @ Some ( _) =
0 commit comments