File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,22 @@ impl FunctionData {
56
56
if is_varargs {
57
57
flags. bits |= FnFlags :: IS_VARARGS ;
58
58
}
59
+ if flags. bits & FnFlags :: HAS_SELF_PARAM != 0 {
60
+ // If there's a self param in the syntax, but it is cfg'd out, remove the flag.
61
+ let is_cfgd_out = match func. params . clone ( ) . next ( ) {
62
+ Some ( param) => {
63
+ !item_tree. attrs ( db, krate, param. into ( ) ) . is_cfg_enabled ( cfg_options)
64
+ }
65
+ None => {
66
+ stdx:: never!( "fn HAS_SELF_PARAM but no parameters allocated" ) ;
67
+ true
68
+ }
69
+ } ;
70
+ if is_cfgd_out {
71
+ cov_mark:: hit!( cfgd_out_self_param) ;
72
+ flags. bits &= !FnFlags :: HAS_SELF_PARAM ;
73
+ }
74
+ }
59
75
60
76
let legacy_const_generics_indices = item_tree
61
77
. attrs ( db, krate, ModItem :: from ( loc. id . value ) . into ( ) )
Original file line number Diff line number Diff line change @@ -1488,3 +1488,20 @@ fn test<T: Crash>() {
1488
1488
"# ,
1489
1489
) ;
1490
1490
}
1491
+
1492
+ #[ test]
1493
+ fn cfgd_out_self_param ( ) {
1494
+ cov_mark:: check!( cfgd_out_self_param) ;
1495
+ check_no_mismatches (
1496
+ r#"
1497
+ struct S;
1498
+ impl S {
1499
+ fn f(#[cfg(never)] &self) {}
1500
+ }
1501
+
1502
+ fn f(s: S) {
1503
+ s.f();
1504
+ }
1505
+ "# ,
1506
+ ) ;
1507
+ }
You can’t perform that action at this time.
0 commit comments