Skip to content

Commit

Permalink
diagnostics descriptor for atoms_exhaustion
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: robertoaloi

Differential Revision: D55699495

fbshipit-source-id: e291d3b2f847421384692f2c291be4e4d3cc0c7f
  • Loading branch information
alanz authored and facebook-github-bot committed Apr 4, 2024
1 parent 78c6dea commit 120016a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 1 addition & 2 deletions crates/ide/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ pub fn native_diagnostics(
}

pub fn diagnostics_descriptors<'a>() -> Vec<&'a DiagnosticDescriptor<'a>> {
vec![&cross_node_eval::DESCRIPTOR]
vec![&cross_node_eval::DESCRIPTOR, &atoms_exhaustion::DESCRIPTOR]
}

pub fn diagnostics_from_descriptors(
Expand Down Expand Up @@ -664,7 +664,6 @@ pub fn semantic_diagnostics(
undefined_function::undefined_function(res, sema, file_id);
head_mismatch::head_mismatch_semantic(res, sema, file_id);
missing_separator::missing_separator_semantic(res, sema, file_id);
atoms_exhaustion::atoms_exhaustion(res, sema, file_id);
}
}

Expand Down
21 changes: 15 additions & 6 deletions crates/ide/src/diagnostics/atoms_exhaustion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use hir::FunctionDef;
use hir::Semantic;
use text_edit::TextRange;

use super::DiagnosticConditions;
use super::DiagnosticDescriptor;
use crate::codemod_helpers::find_call_in_function;
use crate::codemod_helpers::CheckCallCtx;
use crate::codemod_helpers::MakeDiagCtx;
Expand All @@ -21,11 +23,18 @@ use crate::diagnostics::DiagnosticCode;
use crate::diagnostics::Severity;
use crate::FunctionMatch;

pub(crate) fn atoms_exhaustion(
diagnostics: &mut Vec<Diagnostic>,
sema: &Semantic,
file_id: FileId,
) {
pub(crate) static DESCRIPTOR: DiagnosticDescriptor = DiagnosticDescriptor {
conditions: DiagnosticConditions {
experimental: false,
include_generated: true,
include_tests: false,
},
checker: &|diags, sema, file_id, _ext| {
atoms_exhaustion(diags, sema, file_id);
},
};

fn atoms_exhaustion(diagnostics: &mut Vec<Diagnostic>, sema: &Semantic, file_id: FileId) {
if Some(true) == sema.db.is_test_suite_or_test_helper(file_id) {
return;
}
Expand Down Expand Up @@ -58,7 +67,7 @@ pub(crate) fn atoms_exhaustion(
});
}

pub(crate) fn check_function(
fn check_function(
diags: &mut Vec<Diagnostic>,
sema: &Semantic,
def: &FunctionDef,
Expand Down

0 comments on commit 120016a

Please sign in to comment.