Auto merge of #103578 - petrochenkov:nofict, r=nagisa
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
This commit is contained in:
commit
9e09307245
@ -65,14 +65,14 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
|
|||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
if arm.guard.is_none() {
|
if arm.guard.is_none() {
|
||||||
missing_variants.retain(|e| e.ctor_def_id != Some(id));
|
missing_variants.retain(|e| e.ctor_def_id() != Some(id));
|
||||||
}
|
}
|
||||||
path
|
path
|
||||||
},
|
},
|
||||||
PatKind::TupleStruct(path, patterns, ..) => {
|
PatKind::TupleStruct(path, patterns, ..) => {
|
||||||
if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
|
if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
|
||||||
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
|
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
|
||||||
missing_variants.retain(|e| e.ctor_def_id != Some(id));
|
missing_variants.retain(|e| e.ctor_def_id() != Some(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path
|
path
|
||||||
@ -122,11 +122,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
|
|||||||
s
|
s
|
||||||
},
|
},
|
||||||
variant.name,
|
variant.name,
|
||||||
match variant.ctor_kind {
|
match variant.ctor_kind() {
|
||||||
CtorKind::Fn if variant.fields.len() == 1 => "(_)",
|
Some(CtorKind::Fn) if variant.fields.len() == 1 => "(_)",
|
||||||
CtorKind::Fn => "(..)",
|
Some(CtorKind::Fn) => "(..)",
|
||||||
CtorKind::Const => "",
|
Some(CtorKind::Const) => "",
|
||||||
CtorKind::Fictive => "{ .. }",
|
None => "{ .. }",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@ -133,11 +133,11 @@ enum Item {
|
|||||||
let has_ctor = match cx.tcx.def_kind(def_id) {
|
let has_ctor = match cx.tcx.def_kind(def_id) {
|
||||||
DefKind::Struct => {
|
DefKind::Struct => {
|
||||||
let variant = cx.tcx.adt_def(def_id).non_enum_variant();
|
let variant = cx.tcx.adt_def(def_id).non_enum_variant();
|
||||||
variant.ctor_def_id.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
|
variant.ctor.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
|
||||||
},
|
},
|
||||||
DefKind::Variant => {
|
DefKind::Variant => {
|
||||||
let variant = cx.tcx.adt_def(cx.tcx.parent(def_id)).variant_with_id(def_id);
|
let variant = cx.tcx.adt_def(cx.tcx.parent(def_id)).variant_with_id(def_id);
|
||||||
variant.ctor_def_id.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
|
variant.ctor.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user