mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Fix panics with #[cfg]
'd-out self
parameter
This commit is contained in:
parent
8765baaf9d
commit
67495b618b
@ -56,6 +56,15 @@ impl FunctionData {
|
||||
if is_varargs {
|
||||
flags.bits |= FnFlags::IS_VARARGS;
|
||||
}
|
||||
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) {
|
||||
flags.bits &= !FnFlags::HAS_SELF_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
let legacy_const_generics_indices = item_tree
|
||||
.attrs(db, krate, ModItem::from(loc.id.value).into())
|
||||
|
@ -1488,3 +1488,20 @@ fn test<T: Crash>() {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cfgd_out_self_param() {
|
||||
cov_mark::check!(cfgd_out_self_param);
|
||||
check_no_mismatches(
|
||||
r#"
|
||||
struct S;
|
||||
impl S {
|
||||
fn f(#[cfg(never)] &self) {}
|
||||
}
|
||||
|
||||
fn f(s: S) {
|
||||
s.f();
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user