File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ 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
+ cov_mark:: hit!( cfgd_out_self_param) ;
62
+ let param =
63
+ func. params . clone ( ) . next ( ) . expect ( "fn HAS_SELF_PARAM but no parameters allocated" ) ;
64
+ if !item_tree. attrs ( db, krate, param. into ( ) ) . is_cfg_enabled ( cfg_options) {
65
+ flags. bits &= !FnFlags :: HAS_SELF_PARAM ;
66
+ }
67
+ }
59
68
60
69
let legacy_const_generics_indices = item_tree
61
70
. 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