diff --git a/Cargo.toml b/Cargo.toml
index 0babf1a2aae..10c68420976 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,3 +17,4 @@ exclude = [
 rust_2018_idioms = "warn"
 unused_qualifications = "warn"
 missing_docs = "warn"
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(windows_raw_dylib, windows_debugger_visualizer)'] }
diff --git a/crates/libs/core/src/lib.rs b/crates/libs/core/src/lib.rs
index 70d97d9c520..756c3637a1f 100644
--- a/crates/libs/core/src/lib.rs
+++ b/crates/libs/core/src/lib.rs
@@ -3,7 +3,7 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
 */
 
 #![doc(html_no_source)]
-#![allow(non_snake_case, unexpected_cfgs)]
+#![allow(non_snake_case)]
 #![cfg_attr(windows_debugger_visualizer, debugger_visualizer(natvis_file = "../.natvis"))]
 #![cfg_attr(all(not(test), not(feature = "std")), no_std)]
 
diff --git a/crates/libs/result/src/lib.rs b/crates/libs/result/src/lib.rs
index 8f987506225..7e6601a2f3a 100644
--- a/crates/libs/result/src/lib.rs
+++ b/crates/libs/result/src/lib.rs
@@ -2,7 +2,6 @@
 Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs>
 */
 
-#![allow(unexpected_cfgs)]
 #![cfg_attr(
     windows_debugger_visualizer,
     debugger_visualizer(natvis_file = "../.natvis")
diff --git a/crates/libs/targets/src/lib.rs b/crates/libs/targets/src/lib.rs
index 205cc94ce9d..e4751989f1a 100644
--- a/crates/libs/targets/src/lib.rs
+++ b/crates/libs/targets/src/lib.rs
@@ -3,7 +3,6 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
 */
 
 #![no_std]
-#![allow(unexpected_cfgs)]
 
 /// Defines an external function to import.
 #[cfg(all(windows_raw_dylib, target_arch = "x86"))]
diff --git a/crates/tests/calling_convention/Cargo.toml b/crates/tests/calling_convention/Cargo.toml
index 875d6ac4cf3..fa4dfde73e1 100644
--- a/crates/tests/calling_convention/Cargo.toml
+++ b/crates/tests/calling_convention/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.0.0"
 edition = "2021"
 publish = false
 
+[lints.rust]
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(windows_raw_dylib)'] }
+
 [dependencies.windows]
 path = "../../libs/windows"
 features = [
diff --git a/crates/tests/calling_convention/tests/sys.rs b/crates/tests/calling_convention/tests/sys.rs
index 3f2a92b29a0..bfdb6628b85 100644
--- a/crates/tests/calling_convention/tests/sys.rs
+++ b/crates/tests/calling_convention/tests/sys.rs
@@ -1,5 +1,3 @@
-#![allow(unexpected_cfgs)]
-
 use windows_sys::{
     core::*, Win32::Foundation::*, Win32::Networking::Ldap::*, Win32::System::SystemInformation::*,
     Win32::UI::WindowsAndMessaging::*,
diff --git a/crates/tests/calling_convention/tests/win.rs b/crates/tests/calling_convention/tests/win.rs
index 4e8d33e35f7..eae2d52ca54 100644
--- a/crates/tests/calling_convention/tests/win.rs
+++ b/crates/tests/calling_convention/tests/win.rs
@@ -1,5 +1,3 @@
-#![allow(unexpected_cfgs)]
-
 use windows::{
     Win32::Foundation::*, Win32::Networking::Ldap::*, Win32::System::SystemInformation::*,
 };
diff --git a/crates/tests/debugger_visualizer/Cargo.toml b/crates/tests/debugger_visualizer/Cargo.toml
index 25d173cb361..c5b7f64d5a7 100644
--- a/crates/tests/debugger_visualizer/Cargo.toml
+++ b/crates/tests/debugger_visualizer/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.0.0"
 edition = "2021"
 publish = false
 
+[lints.rust]
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(windows_debugger_visualizer)'] }
+
 [dependencies.windows]
 path = "../../libs/windows"
 features = [
diff --git a/crates/tests/debugger_visualizer/tests/test.rs b/crates/tests/debugger_visualizer/tests/test.rs
index 97ececf852a..4f264112ad3 100644
--- a/crates/tests/debugger_visualizer/tests/test.rs
+++ b/crates/tests/debugger_visualizer/tests/test.rs
@@ -1,4 +1,3 @@
-#![allow(unexpected_cfgs)]
 #![cfg(windows_debugger_visualizer)]
 
 use debugger_test::*;