Skip to content

Commit 16d0f72

Browse files
author
Jonas Schievink
committed
use stdx::never
1 parent 67495b6 commit 16d0f72

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/hir_def/src/data.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,17 @@ impl FunctionData {
5858
}
5959
if flags.bits & FnFlags::HAS_SELF_PARAM != 0 {
6060
// 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) {
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);
6572
flags.bits &= !FnFlags::HAS_SELF_PARAM;
6673
}
6774
}

0 commit comments

Comments
 (0)