Skip to content

Commit da7b1c9

Browse files
committed
Separate Def::StructCtor/Def::VariantCtor from Def::Struct/Def::Variant
1 parent a5dac7a commit da7b1c9

File tree

20 files changed

+129
-85
lines changed

20 files changed

+129
-85
lines changed

src/librustc/hir/def.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ use util::nodemap::NodeMap;
1313
use syntax::ast;
1414
use hir;
1515

16+
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
17+
pub enum CtorKind {
18+
// Constructor function automatically created by a tuple struct/variant.
19+
Fn,
20+
// Constructor constant automatically created by a unit struct/variant.
21+
Const,
22+
// Unusable name in value namespace created by a struct variant.
23+
Fictive,
24+
}
25+
1626
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1727
pub enum Def {
1828
Fn(DefId),
@@ -23,21 +33,18 @@ pub enum Def {
2333
AssociatedConst(DefId),
2434
Local(DefId),
2535
Variant(DefId),
36+
VariantCtor(DefId, CtorKind),
2637
Enum(DefId),
2738
TyAlias(DefId),
2839
AssociatedTy(DefId),
2940
Trait(DefId),
3041
PrimTy(hir::PrimTy),
3142
TyParam(DefId),
3243
Upvar(DefId, // def id of closed over local
33-
usize, // index in the freevars list of the closure
34-
ast::NodeId), // expr node that creates the closure
35-
36-
// If Def::Struct lives in type namespace it denotes a struct item and its DefId refers
37-
// to NodeId of the struct itself.
38-
// If Def::Struct lives in value namespace (e.g. tuple struct, unit struct expressions)
39-
// it denotes a constructor and its DefId refers to NodeId of the struct's constructor.
40-
Struct(DefId),
44+
usize, // index in the freevars list of the closure
45+
ast::NodeId), // expr node that creates the closure
46+
Struct(DefId), // DefId refers to NodeId of the struct itself
47+
StructCtor(DefId, CtorKind), // DefId refers to NodeId of the struct's constructor
4148
Union(DefId),
4249
Label(ast::NodeId),
4350
Method(DefId),
@@ -97,14 +104,24 @@ pub struct Export {
97104
pub def_id: DefId, // The definition of the target.
98105
}
99106

107+
impl CtorKind {
108+
pub fn from_vdata(vdata: &ast::VariantData) -> CtorKind {
109+
match *vdata {
110+
ast::VariantData::Tuple(..) => CtorKind::Fn,
111+
ast::VariantData::Unit(..) => CtorKind::Const,
112+
ast::VariantData::Struct(..) => CtorKind::Fictive,
113+
}
114+
}
115+
}
116+
100117
impl Def {
101118
pub fn def_id(&self) -> DefId {
102119
match *self {
103120
Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
104-
Def::Variant(id) | Def::Enum(id) | Def::TyAlias(id) | Def::AssociatedTy(id) |
105-
Def::TyParam(id) | Def::Struct(id) | Def::Union(id) | Def::Trait(id) |
106-
Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) |
107-
Def::Local(id) | Def::Upvar(id, ..) => {
121+
Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | Def::TyAlias(id) |
122+
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
123+
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
124+
Def::AssociatedConst(id) | Def::Local(id) | Def::Upvar(id, ..) => {
108125
id
109126
}
110127

@@ -123,10 +140,12 @@ impl Def {
123140
Def::Mod(..) => "module",
124141
Def::Static(..) => "static",
125142
Def::Variant(..) => "variant",
143+
Def::VariantCtor(..) => "variant",
126144
Def::Enum(..) => "enum",
127145
Def::TyAlias(..) => "type",
128146
Def::AssociatedTy(..) => "associated type",
129147
Def::Struct(..) => "struct",
148+
Def::StructCtor(..) => "struct",
130149
Def::Union(..) => "union",
131150
Def::Trait(..) => "trait",
132151
Def::Method(..) => "method",

src/librustc/hir/pat_util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ pub fn necessary_variants(dm: &DefMap, pat: &hir::Pat) -> Vec<DefId> {
174174
PatKind::Path(..) |
175175
PatKind::Struct(..) => {
176176
match dm.get(&p.id) {
177-
Some(&PathResolution { base_def: Def::Variant(id), .. }) => {
177+
Some(&PathResolution { base_def: Def::Variant(id), .. }) |
178+
Some(&PathResolution { base_def: Def::VariantCtor(id, ..), .. }) => {
178179
variants.push(id);
179180
}
180181
_ => ()

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
108108
_ if self.ignore_non_const_paths => (),
109109
Def::PrimTy(_) => (),
110110
Def::SelfTy(..) => (),
111-
Def::Variant(variant_id) => {
111+
Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => {
112112
if let Some(enum_id) = self.tcx.parent_def_id(variant_id) {
113113
self.check_def_id(enum_id);
114114
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
10031003
// the leaves of the pattern tree structure.
10041004
return_if_err!(mc.cat_pattern(cmt_discr, pat, |mc, cmt_pat, pat| {
10051005
match tcx.expect_def_or_none(pat.id) {
1006-
Some(Def::Variant(variant_did)) => {
1006+
Some(Def::Variant(variant_did)) |
1007+
Some(Def::VariantCtor(variant_did, ..)) => {
10071008
let enum_did = tcx.parent_def_id(variant_did).unwrap();
10081009
let downcast_cmt = if tcx.lookup_adt_def(enum_did).is_univariant() {
10091010
cmt_pat
@@ -1015,7 +1016,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
10151016
debug!("variant downcast_cmt={:?} pat={:?}", downcast_cmt, pat);
10161017
delegate.matched_pat(pat, downcast_cmt, match_mode);
10171018
}
1018-
Some(Def::Struct(..)) | Some(Def::Union(..)) |
1019+
Some(Def::Struct(..)) | Some(Def::StructCtor(..)) | Some(Def::Union(..)) |
10191020
Some(Def::TyAlias(..)) | Some(Def::AssociatedTy(..)) => {
10201021
debug!("struct cmt_pat={:?} pat={:?}", cmt_pat, pat);
10211022
delegate.matched_pat(pat, cmt_pat, match_mode);

src/librustc/middle/mem_categorization.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
524524
id, expr_ty, def);
525525

526526
match def {
527-
Def::Struct(..) | Def::Union(..) | Def::Variant(..) | Def::Const(..) |
527+
Def::StructCtor(..) | Def::Union(..) | Def::VariantCtor(..) | Def::Const(..) |
528528
Def::AssociatedConst(..) | Def::Fn(..) | Def::Method(..) => {
529529
Ok(self.cat_rvalue_node(id, span, expr_ty))
530530
}
@@ -533,6 +533,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
533533
Def::Trait(_) | Def::Enum(..) | Def::TyAlias(..) | Def::PrimTy(_) |
534534
Def::TyParam(..) |
535535
Def::Label(_) | Def::SelfTy(..) |
536+
Def::Variant(..) |
537+
Def::Struct(..) |
536538
Def::AssociatedTy(..) => {
537539
span_bug!(span, "Unexpected definition in \
538540
memory categorization: {:?}", def);
@@ -1077,7 +1079,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
10771079
// alone) because PatKind::Struct can also refer to variants.
10781080
let cmt = match self.tcx().expect_def_or_none(pat.id) {
10791081
Some(Def::Err) => return Err(()),
1080-
Some(Def::Variant(variant_did)) => {
1082+
Some(Def::Variant(variant_did)) |
1083+
Some(Def::VariantCtor(variant_did, ..)) => {
10811084
// univariant enums do not need downcasts
10821085
let enum_did = self.tcx().parent_def_id(variant_did).unwrap();
10831086
if !self.tcx().lookup_adt_def(enum_did).is_univariant() {
@@ -1092,11 +1095,11 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
10921095
match pat.node {
10931096
PatKind::TupleStruct(_, ref subpats, ddpos) => {
10941097
let expected_len = match self.tcx().expect_def(pat.id) {
1095-
Def::Variant(def_id) => {
1098+
Def::VariantCtor(def_id, ..) => {
10961099
let enum_def = self.tcx().parent_def_id(def_id).unwrap();
10971100
self.tcx().lookup_adt_def(enum_def).variant_with_id(def_id).fields.len()
10981101
}
1099-
Def::Struct(..) => {
1102+
Def::StructCtor(..) => {
11001103
match self.pat_ty(&pat)?.sty {
11011104
ty::TyAdt(adt_def, _) => {
11021105
adt_def.struct_variant().fields.len()

src/librustc/ty/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub use self::fold::TypeFoldable;
2020
use dep_graph::{self, DepNode};
2121
use hir::map as ast_map;
2222
use middle;
23-
use hir::def::{Def, PathResolution, ExportMap};
23+
use hir::def::{Def, CtorKind, PathResolution, ExportMap};
2424
use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
2525
use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
2626
use middle::region::{CodeExtent, ROOT_CODE_EXTENT};
@@ -1496,6 +1496,13 @@ impl VariantKind {
14961496
hir::VariantData::Unit(..) => VariantKind::Unit,
14971497
}
14981498
}
1499+
pub fn ctor_kind(self) -> CtorKind {
1500+
match self {
1501+
VariantKind::Tuple => CtorKind::Fn,
1502+
VariantKind::Unit => CtorKind::Const,
1503+
VariantKind::Struct => CtorKind::Fictive,
1504+
}
1505+
}
14991506
}
15001507

15011508
impl<'a, 'gcx, 'tcx, 'container> AdtDefData<'gcx, 'container> {
@@ -1673,8 +1680,8 @@ impl<'a, 'gcx, 'tcx, 'container> AdtDefData<'gcx, 'container> {
16731680

16741681
pub fn variant_of_def(&self, def: Def) -> &VariantDefData<'gcx, 'container> {
16751682
match def {
1676-
Def::Variant(vid) => self.variant_with_id(vid),
1677-
Def::Struct(..) | Def::Union(..) |
1683+
Def::Variant(vid) | Def::VariantCtor(vid, ..) => self.variant_with_id(vid),
1684+
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
16781685
Def::TyAlias(..) | Def::AssociatedTy(..) => self.struct_variant(),
16791686
_ => bug!("unexpected def {:?} in variant_of_def", def)
16801687
}
@@ -2332,11 +2339,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23322339
// or variant or their constructors, panics otherwise.
23332340
pub fn expect_variant_def(self, def: Def) -> VariantDef<'tcx> {
23342341
match def {
2335-
Def::Variant(did) => {
2342+
Def::Variant(did) | Def::VariantCtor(did, ..) => {
23362343
let enum_did = self.parent_def_id(did).unwrap();
23372344
self.lookup_adt_def(enum_did).variant_with_id(did)
23382345
}
2339-
Def::Struct(did) | Def::Union(did) => {
2346+
Def::Struct(did) | Def::StructCtor(did, ..) | Def::Union(did) => {
23402347
self.lookup_adt_def(did).struct_variant()
23412348
}
23422349
_ => bug!("expect_variant_def used with unexpected def {:?}", def)

src/librustc_const_eval/check_match.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,8 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
801801
match pat.node {
802802
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..) =>
803803
match cx.tcx.expect_def(pat.id) {
804-
Def::Variant(id) => vec![Variant(id)],
805-
Def::Struct(..) | Def::Union(..) |
804+
Def::Variant(id) | Def::VariantCtor(id, ..) => vec![Variant(id)],
805+
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
806806
Def::TyAlias(..) | Def::AssociatedTy(..) => vec![Single],
807807
Def::Const(..) | Def::AssociatedConst(..) =>
808808
span_bug!(pat.span, "const pattern should've been rewritten"),
@@ -913,8 +913,8 @@ pub fn specialize<'a, 'b, 'tcx>(
913913
Def::Const(..) | Def::AssociatedConst(..) =>
914914
span_bug!(pat_span, "const pattern should've \
915915
been rewritten"),
916-
Def::Variant(id) if *constructor != Variant(id) => None,
917-
Def::Variant(..) | Def::Struct(..) => Some(Vec::new()),
916+
Def::VariantCtor(id, ..) if *constructor != Variant(id) => None,
917+
Def::VariantCtor(..) | Def::StructCtor(..) => Some(Vec::new()),
918918
def => span_bug!(pat_span, "specialize: unexpected \
919919
definition {:?}", def),
920920
}
@@ -925,8 +925,8 @@ pub fn specialize<'a, 'b, 'tcx>(
925925
Def::Const(..) | Def::AssociatedConst(..) =>
926926
span_bug!(pat_span, "const pattern should've \
927927
been rewritten"),
928-
Def::Variant(id) if *constructor != Variant(id) => None,
929-
Def::Variant(..) | Def::Struct(..) => {
928+
Def::VariantCtor(id, ..) if *constructor != Variant(id) => None,
929+
Def::VariantCtor(..) | Def::StructCtor(..) => {
930930
match ddpos {
931931
Some(ddpos) => {
932932
let mut pats: Vec<_> = args[..ddpos].iter().map(|p| {

src/librustc_const_eval/eval.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
287287
entry.insert(PathResolution::new(def));
288288
}
289289
let path = match def {
290-
Def::Struct(def_id) => def_to_path(tcx, def_id),
291-
Def::Variant(variant_did) => def_to_path(tcx, variant_did),
290+
Def::StructCtor(def_id, ..) => def_to_path(tcx, def_id),
291+
Def::VariantCtor(variant_did, ..) => def_to_path(tcx, variant_did),
292292
Def::Fn(..) | Def::Method(..) => return Ok(P(hir::Pat {
293293
id: expr.id,
294294
node: PatKind::Lit(P(expr.clone())),
@@ -326,7 +326,7 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
326326

327327
hir::ExprPath(_, ref path) => {
328328
match tcx.expect_def(expr.id) {
329-
Def::Struct(..) | Def::Variant(..) => PatKind::Path(None, path.clone()),
329+
Def::StructCtor(..) | Def::VariantCtor(..) => PatKind::Path(None, path.clone()),
330330
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
331331
let substs = Some(tcx.node_id_item_substs(expr.id).substs);
332332
let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap();
@@ -807,7 +807,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
807807
signal!(e, NonConstPath);
808808
}
809809
},
810-
Def::Variant(variant_def) => {
810+
Def::VariantCtor(variant_def, ..) => {
811811
if let Some(const_expr) = lookup_variant_by_id(tcx, variant_def) {
812812
match eval_const_expr_partial(tcx, const_expr, ty_hint, None) {
813813
Ok(val) => val,
@@ -820,7 +820,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
820820
signal!(e, UnimplementedConstVal("enum variants"));
821821
}
822822
}
823-
Def::Struct(..) => {
823+
Def::StructCtor(..) => {
824824
ConstVal::Struct(e.id)
825825
}
826826
Def::Local(def_id) => {

src/librustc_incremental/calculate_svh/svh_visitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,13 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
611611
Def::Mod(..) |
612612
Def::Static(..) |
613613
Def::Variant(..) |
614+
Def::VariantCtor(..) |
614615
Def::Enum(..) |
615616
Def::TyAlias(..) |
616617
Def::AssociatedTy(..) |
617618
Def::TyParam(..) |
618619
Def::Struct(..) |
620+
Def::StructCtor(..) |
619621
Def::Union(..) |
620622
Def::Trait(..) |
621623
Def::Method(..) |

src/librustc_mir/hair/cx/expr.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use hair::cx::Cx;
1515
use hair::cx::block;
1616
use hair::cx::to_ref::ToRef;
1717
use rustc::hir::map;
18-
use rustc::hir::def::Def;
18+
use rustc::hir::def::{Def, CtorKind};
1919
use rustc::middle::const_val::ConstVal;
2020
use rustc_const_eval as const_eval;
2121
use rustc::middle::region::CodeExtent;
@@ -271,10 +271,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
271271
// Tuple-like ADTs are represented as ExprCall. We convert them here.
272272
expr_ty.ty_adt_def().and_then(|adt_def|{
273273
match cx.tcx.expect_def(fun.id) {
274-
Def::Variant(variant_id) => {
274+
Def::VariantCtor(variant_id, ..) => {
275275
Some((adt_def, adt_def.variant_index_with_id(variant_id)))
276276
},
277-
Def::Struct(..) => {
277+
Def::StructCtor(..) => {
278278
Some((adt_def, 0))
279279
},
280280
_ => None
@@ -672,10 +672,9 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
672672
let def_id = match def {
673673
// A regular function.
674674
Def::Fn(def_id) | Def::Method(def_id) => def_id,
675-
Def::Struct(def_id) => match cx.tcx.node_id_to_type(expr.id).sty {
676-
// A tuple-struct constructor. Should only be reached if not called in the same
677-
// expression.
678-
ty::TyFnDef(..) => def_id,
675+
Def::StructCtor(def_id, CtorKind::Fn) |
676+
Def::VariantCtor(def_id, CtorKind::Fn) => def_id,
677+
Def::StructCtor(_, CtorKind::Const) => match cx.tcx.node_id_to_type(expr.id).sty {
679678
// A unit struct which is used as a value. We return a completely different ExprKind
680679
// here to account for this special case.
681680
ty::TyAdt(adt_def, substs) => return ExprKind::Adt {
@@ -687,13 +686,10 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
687686
},
688687
ref sty => bug!("unexpected sty: {:?}", sty)
689688
},
690-
Def::Variant(variant_id) => match cx.tcx.node_id_to_type(expr.id).sty {
691-
// A variant constructor. Should only be reached if not called in the same
692-
// expression.
693-
ty::TyFnDef(..) => variant_id,
689+
Def::VariantCtor(def_id, CtorKind::Const) => match cx.tcx.node_id_to_type(expr.id).sty {
694690
// A unit variant, similar special case to the struct case above.
695691
ty::TyAdt(adt_def, substs) => {
696-
let index = adt_def.variant_index_with_id(variant_id);
692+
let index = adt_def.variant_index_with_id(def_id);
697693
return ExprKind::Adt {
698694
adt_def: adt_def,
699695
substs: substs,

src/librustc_mir/hair/cx/pattern.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<'patcx, 'cx, 'gcx, 'tcx> PatCx<'patcx, 'cx, 'gcx, 'tcx> {
301301
subpatterns: Vec<FieldPattern<'tcx>>)
302302
-> PatternKind<'tcx> {
303303
match self.cx.tcx.expect_def(pat.id) {
304-
Def::Variant(variant_id) => {
304+
Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => {
305305
let enum_id = self.cx.tcx.parent_def_id(variant_id).unwrap();
306306
let adt_def = self.cx.tcx.lookup_adt_def(enum_id);
307307
if adt_def.variants.len() > 1 {
@@ -315,7 +315,7 @@ impl<'patcx, 'cx, 'gcx, 'tcx> PatCx<'patcx, 'cx, 'gcx, 'tcx> {
315315
}
316316
}
317317

318-
Def::Struct(..) | Def::Union(..) |
318+
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
319319
Def::TyAlias(..) | Def::AssociatedTy(..) => {
320320
PatternKind::Leaf { subpatterns: subpatterns }
321321
}

src/librustc_passes/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,11 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
489489
}
490490
hir::ExprPath(..) => {
491491
match v.tcx.expect_def(e.id) {
492-
Def::Variant(..) => {
492+
Def::VariantCtor(..) => {
493493
// Count the discriminator or function pointer.
494494
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
495495
}
496-
Def::Struct(..) => {
496+
Def::StructCtor(..) => {
497497
if let ty::TyFnDef(..) = node_ty.sty {
498498
// Count the function pointer.
499499
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
@@ -539,8 +539,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
539539
}
540540
// The callee is an arbitrary expression, it doesn't necessarily have a definition.
541541
let is_const = match v.tcx.expect_def_or_none(callee.id) {
542-
Some(Def::Struct(..)) => true,
543-
Some(Def::Variant(..)) => {
542+
Some(Def::StructCtor(..)) => true,
543+
Some(Def::VariantCtor(..)) => {
544544
// Count the discriminator.
545545
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
546546
true

0 commit comments

Comments
 (0)