Skip to content

Commit 33417ae

Browse files
Alexander Regueiropietroalbini
Alexander Regueiro
authored andcommitted
Fixed minor issues raised in review.
1 parent 48d930c commit 33417ae

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/librustc/ty/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ bitflags! {
17561756
const IS_ENUM = 1 << 0;
17571757
const IS_UNION = 1 << 1;
17581758
const IS_STRUCT = 1 << 2;
1759-
const IS_TUPLE_STRUCT = 1 << 3;
1759+
const HAS_CTOR = 1 << 3;
17601760
const IS_PHANTOM_DATA = 1 << 4;
17611761
const IS_FUNDAMENTAL = 1 << 5;
17621762
const IS_BOX = 1 << 6;
@@ -2096,7 +2096,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
20962096
let variant_def = &variants[VariantIdx::new(0)];
20972097
let def_key = tcx.def_key(variant_def.did);
20982098
match def_key.disambiguated_data.data {
2099-
DefPathData::StructCtor => flags |= AdtFlags::IS_TUPLE_STRUCT,
2099+
DefPathData::StructCtor => flags |= AdtFlags::HAS_CTOR,
21002100
_ => (),
21012101
}
21022102
}
@@ -2131,12 +2131,6 @@ impl<'a, 'gcx, 'tcx> AdtDef {
21312131
self.flags.contains(AdtFlags::IS_STRUCT)
21322132
}
21332133

2134-
/// If this function returns `true`, it implies that `is_struct` must return `true`.
2135-
#[inline]
2136-
pub fn is_tuple_struct(&self) -> bool {
2137-
self.flags.contains(AdtFlags::IS_TUPLE_STRUCT)
2138-
}
2139-
21402134
#[inline]
21412135
pub fn is_union(&self) -> bool {
21422136
self.flags.contains(AdtFlags::IS_UNION)
@@ -2181,6 +2175,12 @@ impl<'a, 'gcx, 'tcx> AdtDef {
21812175
}
21822176
}
21832177

2178+
/// If this function returns `true`, it implies that `is_struct` must return `true`.
2179+
#[inline]
2180+
pub fn has_ctor(&self) -> bool {
2181+
self.flags.contains(AdtFlags::HAS_CTOR)
2182+
}
2183+
21842184
/// Returns whether this type is `#[fundamental]` for the purposes
21852185
/// of coherence checking.
21862186
#[inline]

src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5168,7 +5168,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51685168
let adt_def = ty.ty_adt_def();
51695169

51705170
match adt_def {
5171-
Some(adt_def) if adt_def.is_tuple_struct() => {
5171+
Some(adt_def) if adt_def.has_ctor() => {
51725172
let variant = adt_def.non_enum_variant();
51735173
new_def = Def::StructCtor(variant.did, variant.ctor_kind);
51745174
(variant.did, self.tcx.type_of(variant.did))
@@ -5181,8 +5181,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51815181
AdtKind::Enum => {
51825182
err.note("did you mean to use one of the enum's variants?");
51835183
},
5184-
AdtKind::Union => {},
5185-
AdtKind::Struct => {
5184+
AdtKind::Struct |
5185+
AdtKind::Union => {
51865186
err.span_label(
51875187
span,
51885188
format!("did you mean `Self {{ /* fields */ }}`?"),

0 commit comments

Comments
 (0)