Skip to content

Commit 9e09307

Browse files
committed
Auto merge of rust-lang#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 - rust-lang#103578 (comment).
2 parents e6c33e0 + ae8f75c commit 9e09307

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clippy_lints/src/matches/match_wild_enum.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
6565
_ => return,
6666
};
6767
if arm.guard.is_none() {
68-
missing_variants.retain(|e| e.ctor_def_id != Some(id));
68+
missing_variants.retain(|e| e.ctor_def_id() != Some(id));
6969
}
7070
path
7171
},
7272
PatKind::TupleStruct(path, patterns, ..) => {
7373
if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
7474
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
75-
missing_variants.retain(|e| e.ctor_def_id != Some(id));
75+
missing_variants.retain(|e| e.ctor_def_id() != Some(id));
7676
}
7777
}
7878
path
@@ -122,11 +122,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
122122
s
123123
},
124124
variant.name,
125-
match variant.ctor_kind {
126-
CtorKind::Fn if variant.fields.len() == 1 => "(_)",
127-
CtorKind::Fn => "(..)",
128-
CtorKind::Const => "",
129-
CtorKind::Fictive => "{ .. }",
125+
match variant.ctor_kind() {
126+
Some(CtorKind::Fn) if variant.fields.len() == 1 => "(_)",
127+
Some(CtorKind::Fn) => "(..)",
128+
Some(CtorKind::Const) => "",
129+
None => "{ .. }",
130130
}
131131
)
132132
};

clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ impl UnnecessaryDefPath {
133133
let has_ctor = match cx.tcx.def_kind(def_id) {
134134
DefKind::Struct => {
135135
let variant = cx.tcx.adt_def(def_id).non_enum_variant();
136-
variant.ctor_def_id.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
136+
variant.ctor.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
137137
},
138138
DefKind::Variant => {
139139
let variant = cx.tcx.adt_def(cx.tcx.parent(def_id)).variant_with_id(def_id);
140-
variant.ctor_def_id.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
140+
variant.ctor.is_some() && variant.fields.iter().all(|f| f.vis.is_public())
141141
},
142142
_ => false,
143143
};

0 commit comments

Comments
 (0)