Unnamed repository; edit this file 'description' to name the repository.
use stdx::never
| -rw-r--r-- | crates/hir_def/src/data.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index 6571b2a927..5140a9d4ca 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -58,10 +58,17 @@ impl FunctionData { } if flags.bits & FnFlags::HAS_SELF_PARAM != 0 { // If there's a self param in the syntax, but it is cfg'd out, remove the flag. - cov_mark::hit!(cfgd_out_self_param); - let param = - func.params.clone().next().expect("fn HAS_SELF_PARAM but no parameters allocated"); - if !item_tree.attrs(db, krate, param.into()).is_cfg_enabled(cfg_options) { + let is_cfgd_out = match func.params.clone().next() { + Some(param) => { + !item_tree.attrs(db, krate, param.into()).is_cfg_enabled(cfg_options) + } + None => { + stdx::never!("fn HAS_SELF_PARAM but no parameters allocated"); + true + } + }; + if is_cfgd_out { + cov_mark::hit!(cfgd_out_self_param); flags.bits &= !FnFlags::HAS_SELF_PARAM; } } |