From 6356ea24dd026cc386dace23087cdbce7570f369 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 17 Mar 2021 16:31:54 +0100 Subject: Add test for `#[cfg]` on function params --- crates/hir_ty/src/diagnostics/expr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/hir_ty/src/diagnostics/expr.rs') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 50dc40335..9a3258955 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -713,4 +713,17 @@ fn main() { "#, ); } + + #[test] + fn cfgd_out_fn_params() { + check_diagnostics( + r#" +fn foo(#[cfg(NEVER)] x: ()) {} + +fn main() { + foo(); +} + "#, + ) + } } -- cgit v1.2.3 From 9436436d20db4d7b13809844ef3e12563dc6be65 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 17 Mar 2021 18:35:17 +0100 Subject: Improve test --- crates/hir_ty/src/diagnostics/expr.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crates/hir_ty/src/diagnostics/expr.rs') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 9a3258955..3909ad354 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -720,8 +720,29 @@ fn main() { r#" fn foo(#[cfg(NEVER)] x: ()) {} +struct S; + +impl S { + fn method(#[cfg(NEVER)] self) {} + fn method2(#[cfg(NEVER)] self, arg: u8) {} + fn method3(self, #[cfg(NEVER)] arg: u8) {} +} + +extern "C" { + fn fixed(fixed: u8, #[cfg(NEVER)] ...); + fn varargs(#[cfg(not(NEVER))] ...); +} + fn main() { foo(); + S::method(); + S::method2(0); + S::method3(S); + S.method3(); + unsafe { + fixed(0); + varargs(1, 2, 3); + } } "#, ) -- cgit v1.2.3