mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Unreserve braced enum variants in value namespace
This commit is contained in:
parent
3597ed5a09
commit
ae8f75c6a3
@ -65,14 +65,14 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
|
||||
_ => return,
|
||||
};
|
||||
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
|
||||
},
|
||||
PatKind::TupleStruct(path, patterns, ..) => {
|
||||
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)) {
|
||||
missing_variants.retain(|e| e.ctor_def_id != Some(id));
|
||||
missing_variants.retain(|e| e.ctor_def_id() != Some(id));
|
||||
}
|
||||
}
|
||||
path
|
||||
@ -122,11 +122,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
|
||||
s
|
||||
},
|
||||
variant.name,
|
||||
match variant.ctor_kind {
|
||||
CtorKind::Fn if variant.fields.len() == 1 => "(_)",
|
||||
CtorKind::Fn => "(..)",
|
||||
CtorKind::Const => "",
|
||||
CtorKind::Fictive => "{ .. }",
|
||||
match variant.ctor_kind() {
|
||||
Some(CtorKind::Fn) if variant.fields.len() == 1 => "(_)",
|
||||
Some(CtorKind::Fn) => "(..)",
|
||||
Some(CtorKind::Const) => "",
|
||||
None => "{ .. }",
|
||||
}
|
||||
)
|
||||
};
|
||||
|
@ -133,11 +133,11 @@ impl UnnecessaryDefPath {
|
||||
let has_ctor = match cx.tcx.def_kind(def_id) {
|
||||
DefKind::Struct => {
|
||||
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 => {
|
||||
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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user