Skip to content

Commit d620d88

Browse files
author
Alexander Regueiro
committed
Fixed minor issues raised in review.
1 parent bf5c5e3 commit d620d88

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/librustc/ty/mod.rs

Lines changed: 8 additions & 8 deletions
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5162,7 +5162,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51625162
let adt_def = ty.ty_adt_def();
51635163

51645164
match adt_def {
5165-
Some(adt_def) if adt_def.is_tuple_struct() => {
5165+
Some(adt_def) if adt_def.has_ctor() => {
51665166
let variant = adt_def.non_enum_variant();
51675167
new_def = Def::StructCtor(variant.did, variant.ctor_kind);
51685168
(variant.did, self.tcx.type_of(variant.did))
@@ -5175,8 +5175,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51755175
AdtKind::Enum => {
51765176
err.note("did you mean to use one of the enum's variants?");
51775177
},
5178-
AdtKind::Union => {},
5179-
AdtKind::Struct => {
5178+
AdtKind::Struct |
5179+
AdtKind::Union => {
51805180
err.span_label(
51815181
span,
51825182
format!("did you mean `Self {{ /* fields */ }}`?"),

0 commit comments

Comments
 (0)