Hoist only-executables check above producing crate ident

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-03-01 19:16:02 +00:00
parent bf8756d2dd
commit d363db71f8
No known key found for this signature in database
GPG Key ID: 95DDEBD74A1DC2C0

View File

@ -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 {
@ -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);
}
}