Skip to content

Commit

Permalink
Hoist only-executables check above producing crate ident
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Mar 1, 2024
1 parent bf8756d commit d363db7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
return;
}

if cx.tcx.crate_types().iter().all(|&crate_type| crate_type == CrateType::Executable) {
return;
}

let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
Some(Ident::from_str(name))
} else {
Expand Down Expand Up @@ -367,9 +371,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
})
};

if let Some(ident) = &crate_ident
&& cx.tcx.crate_types().iter().all(|&crate_type| crate_type != CrateType::Executable)
{
if let Some(ident) = &crate_ident {
self.check_snake_case(cx, "crate", ident);
}
}
Expand Down

0 comments on commit d363db7

Please sign in to comment.