diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 05f3de32ea..e423cd7efe 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -514,7 +514,6 @@ pub fn native_diagnostics( config .lints_from_config .get_diagnostics(&mut res, &sema, file_id); - semantic_diagnostics(&mut res, &sema, file_id, file_kind, config); // @fb-only: meta_only::diagnostics(&mut res, &sema, file_id); syntax_diagnostics(&sema, &parse, &mut res, file_id); diagnostics_from_descriptors( @@ -564,6 +563,7 @@ pub fn diagnostics_descriptors<'a>() -> Vec<&'a DiagnosticDescriptor<'a>> { vec![ &unused_function_args::DESCRIPTOR, &trivial_match::DESCRIPTOR, + &redundant_assignment::DESCRIPTOR, &unused_macro::DESCRIPTOR, &unused_record_field::DESCRIPTOR, &mutable_variable::DESCRIPTOR, @@ -655,21 +655,6 @@ fn widen_range(range: TextRange) -> TextRange { } } -pub fn semantic_diagnostics( - res: &mut Vec, - sema: &Semantic, - file_id: FileId, - _file_kind: FileKind, - config: &DiagnosticsConfig, -) { - if config.include_generated || !sema.db.is_generated(file_id) { - // TODO: disable this check when T151727890 and T151605845 are resolved - if config.experimental { - redundant_assignment::redundant_assignment(res, sema, file_id); - } - } -} - pub fn syntax_diagnostics( sema: &Semantic, parse: &Parse, diff --git a/crates/ide/src/diagnostics/redundant_assignment.rs b/crates/ide/src/diagnostics/redundant_assignment.rs index d4d32e600e..717523d414 100644 --- a/crates/ide/src/diagnostics/redundant_assignment.rs +++ b/crates/ide/src/diagnostics/redundant_assignment.rs @@ -29,6 +29,8 @@ use hir::Semantic; use hir::Strategy; use super::Diagnostic; +use super::DiagnosticConditions; +use super::DiagnosticDescriptor; use super::Severity; use crate::codemod_helpers::check_is_only_place_where_var_is_defined_ast; use crate::codemod_helpers::check_var_has_references; @@ -36,7 +38,19 @@ use crate::diagnostics::Category; use crate::diagnostics::DiagnosticCode; use crate::fix; -pub(crate) fn redundant_assignment(diags: &mut Vec, sema: &Semantic, file_id: FileId) { +pub(crate) static DESCRIPTOR: DiagnosticDescriptor = DiagnosticDescriptor { + conditions: DiagnosticConditions { + // TODO: disable this check when T151727890 and T151605845 are resolved + experimental: true, + include_generated: false, + include_tests: true, + }, + checker: &|diags, sema, file_id, _ext| { + redundant_assignment(diags, sema, file_id); + }, +}; + +fn redundant_assignment(diags: &mut Vec, sema: &Semantic, file_id: FileId) { if sema.db.is_generated(file_id) { // No point asking for changes to generated files return;