diff options
| author | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-03-01 19:16:02 +0000 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-03-01 19:16:02 +0000 |
| commit | d363db71f83711b392f2f2667aa2c15247e9e21d (patch) | |
| tree | 7ffcdf6f7aab9affb86cc7e2228701d27eea80da | |
| parent | bf8756d2dd820c560cf8172b43dedfcba00d7d88 (diff) | |
Hoist only-executables check above producing crate ident
| -rw-r--r-- | compiler/rustc_lint/src/nonstandard_style.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index d77bc743ca9..ee863672017 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -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); } } |
