diff options
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 71b2cade0..3909ad354 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -690,4 +690,61 @@ fn main() { | |||
690 | "#, | 690 | "#, |
691 | ) | 691 | ) |
692 | } | 692 | } |
693 | |||
694 | #[test] | ||
695 | fn cfgd_out_call_arguments() { | ||
696 | check_diagnostics( | ||
697 | r#" | ||
698 | struct C(#[cfg(FALSE)] ()); | ||
699 | impl C { | ||
700 | fn new() -> Self { | ||
701 | Self( | ||
702 | #[cfg(FALSE)] | ||
703 | (), | ||
704 | ) | ||
705 | } | ||
706 | |||
707 | fn method(&self) {} | ||
708 | } | ||
709 | |||
710 | fn main() { | ||
711 | C::new().method(#[cfg(FALSE)] 0); | ||
712 | } | ||
713 | "#, | ||
714 | ); | ||
715 | } | ||
716 | |||
717 | #[test] | ||
718 | fn cfgd_out_fn_params() { | ||
719 | check_diagnostics( | ||
720 | r#" | ||
721 | fn foo(#[cfg(NEVER)] x: ()) {} | ||
722 | |||
723 | struct S; | ||
724 | |||
725 | impl S { | ||
726 | fn method(#[cfg(NEVER)] self) {} | ||
727 | fn method2(#[cfg(NEVER)] self, arg: u8) {} | ||
728 | fn method3(self, #[cfg(NEVER)] arg: u8) {} | ||
729 | } | ||
730 | |||
731 | extern "C" { | ||
732 | fn fixed(fixed: u8, #[cfg(NEVER)] ...); | ||
733 | fn varargs(#[cfg(not(NEVER))] ...); | ||
734 | } | ||
735 | |||
736 | fn main() { | ||
737 | foo(); | ||
738 | S::method(); | ||
739 | S::method2(0); | ||
740 | S::method3(S); | ||
741 | S.method3(); | ||
742 | unsafe { | ||
743 | fixed(0); | ||
744 | varargs(1, 2, 3); | ||
745 | } | ||
746 | } | ||
747 | "#, | ||
748 | ) | ||
749 | } | ||
693 | } | 750 | } |