Fixed minor issues raised in review.
This commit is contained in:
parent
5656c96c71
commit
616885ec2c
2 changed files with 11 additions and 11 deletions
|
@ -1756,7 +1756,7 @@ bitflags! {
|
||||||
const IS_ENUM = 1 << 0;
|
const IS_ENUM = 1 << 0;
|
||||||
const IS_UNION = 1 << 1;
|
const IS_UNION = 1 << 1;
|
||||||
const IS_STRUCT = 1 << 2;
|
const IS_STRUCT = 1 << 2;
|
||||||
const IS_TUPLE_STRUCT = 1 << 3;
|
const HAS_CTOR = 1 << 3;
|
||||||
const IS_PHANTOM_DATA = 1 << 4;
|
const IS_PHANTOM_DATA = 1 << 4;
|
||||||
const IS_FUNDAMENTAL = 1 << 5;
|
const IS_FUNDAMENTAL = 1 << 5;
|
||||||
const IS_BOX = 1 << 6;
|
const IS_BOX = 1 << 6;
|
||||||
|
@ -2096,7 +2096,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
let variant_def = &variants[VariantIdx::new(0)];
|
let variant_def = &variants[VariantIdx::new(0)];
|
||||||
let def_key = tcx.def_key(variant_def.did);
|
let def_key = tcx.def_key(variant_def.did);
|
||||||
match def_key.disambiguated_data.data {
|
match def_key.disambiguated_data.data {
|
||||||
DefPathData::StructCtor => flags |= AdtFlags::IS_TUPLE_STRUCT,
|
DefPathData::StructCtor => flags |= AdtFlags::HAS_CTOR,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2131,12 +2131,6 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
self.flags.contains(AdtFlags::IS_STRUCT)
|
self.flags.contains(AdtFlags::IS_STRUCT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this function returns `true`, it implies that `is_struct` must return `true`.
|
|
||||||
#[inline]
|
|
||||||
pub fn is_tuple_struct(&self) -> bool {
|
|
||||||
self.flags.contains(AdtFlags::IS_TUPLE_STRUCT)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_union(&self) -> bool {
|
pub fn is_union(&self) -> bool {
|
||||||
self.flags.contains(AdtFlags::IS_UNION)
|
self.flags.contains(AdtFlags::IS_UNION)
|
||||||
|
@ -2181,6 +2175,12 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If this function returns `true`, it implies that `is_struct` must return `true`.
|
||||||
|
#[inline]
|
||||||
|
pub fn has_ctor(&self) -> bool {
|
||||||
|
self.flags.contains(AdtFlags::HAS_CTOR)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns whether this type is `#[fundamental]` for the purposes
|
/// Returns whether this type is `#[fundamental]` for the purposes
|
||||||
/// of coherence checking.
|
/// of coherence checking.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -5163,7 +5163,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let adt_def = ty.ty_adt_def();
|
let adt_def = ty.ty_adt_def();
|
||||||
|
|
||||||
match adt_def {
|
match adt_def {
|
||||||
Some(adt_def) if adt_def.is_tuple_struct() => {
|
Some(adt_def) if adt_def.has_ctor() => {
|
||||||
let variant = adt_def.non_enum_variant();
|
let variant = adt_def.non_enum_variant();
|
||||||
new_def = Def::StructCtor(variant.did, variant.ctor_kind);
|
new_def = Def::StructCtor(variant.did, variant.ctor_kind);
|
||||||
(variant.did, self.tcx.type_of(variant.did))
|
(variant.did, self.tcx.type_of(variant.did))
|
||||||
|
@ -5176,8 +5176,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
AdtKind::Enum => {
|
AdtKind::Enum => {
|
||||||
err.note("did you mean to use one of the enum's variants?");
|
err.note("did you mean to use one of the enum's variants?");
|
||||||
},
|
},
|
||||||
AdtKind::Union => {},
|
AdtKind::Struct |
|
||||||
AdtKind::Struct => {
|
AdtKind::Union => {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
span,
|
span,
|
||||||
format!("did you mean `Self {{ /* fields */ }}`?"),
|
format!("did you mean `Self {{ /* fields */ }}`?"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue