Skip to content

Commit

Permalink
BE: make application_env BAD_MATCH completely static
Browse files Browse the repository at this point in the history
Summary: Rather than having a lazy_static! structure that we preprocess every time we check for the diagnostic, process it in another static too.

Reviewed By: robertoaloi

Differential Revision: D56628462

fbshipit-source-id: 216cf20d3d87b9bea4de2f351ac56a826cbcdcc3
  • Loading branch information
alanz authored and facebook-github-bot committed Apr 29, 2024
1 parent 320ff4b commit bf8e8bf
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions crates/ide/src/diagnostics/application_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,35 @@ pub(crate) enum BadEnvCallAction {

fn check_function(diags: &mut Vec<Diagnostic>, sema: &Semantic, def: &FunctionDef) {
lazy_static! {
static ref BAD_MATCHES: Vec<BadEnvCall> = vec![BadEnvCall::new(
"application",
"get_env",
vec![2, 3],
BadEnvCallAction::AppArg(0)),
static ref BAD_MATCHES: Vec<BadEnvCall> = vec![
BadEnvCall::new(
"application",
"get_env",
vec![2, 3],
BadEnvCallAction::AppArg(0),
),
// @fb-only: diagnostics::meta_only::application_env_bad_matches(),
]
.into_iter()
.flatten()
.collect::<Vec<_>>();

static ref BAD_MATCH_MFAS: Vec<(&'static FunctionMatch, &'static BadEnvCallAction)> =
BAD_MATCHES
.iter()
.map(|b| (&b.mfa, &b.action))
.collect::<Vec<_>>();
}

process_badmatches(diags, sema, def, &BAD_MATCHES);
process_badmatches(diags, sema, def, &BAD_MATCH_MFAS);
}

fn process_badmatches(
diags: &mut Vec<Diagnostic>,
sema: &Semantic,
def: &FunctionDef,
bad: &[BadEnvCall],
mfas: &[(&FunctionMatch, &BadEnvCallAction)],
) {
let mfas = bad.iter().map(|b| (&b.mfa, &b.action)).collect::<Vec<_>>();
find_call_in_function(
diags,
sema,
Expand Down

0 comments on commit bf8e8bf

Please sign in to comment.