diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 79253cbc8b43c..3fe600ce0468c 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -10,6 +10,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::FnKind; use rustc_hir::{GenericParamKind, PatKind}; use rustc_middle::ty; +use rustc_session::config::CrateType; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{sym, Ident}; use rustc_span::{BytePos, Span}; @@ -366,7 +367,11 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { }) }; - if let Some(ident) = &crate_ident { + if let Some(ident) = &crate_ident + && cx.tcx.sess.crate_types().iter().all(|&crate_type| { + crate_type != CrateType::Executable + }) + { self.check_snake_case(cx, "crate", ident); } }