clarify 'no fields'
This commit is contained in:
parent
29a19f84c2
commit
781432e355
2 changed files with 3 additions and 3 deletions
|
|
@ -814,7 +814,7 @@ fn get_nullable_type<'tcx>(
|
|||
|
||||
/// A type is niche-optimization candidate iff:
|
||||
/// - Is a zero-sized type with alignment 1 (a “1-ZST”).
|
||||
/// - Has no fields.
|
||||
/// - Is either a struct/tuple with no fields, or an enum with no variants.
|
||||
/// - Does not have the `#[non_exhaustive]` attribute.
|
||||
fn is_niche_optimization_candidate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
|
@ -828,7 +828,7 @@ fn is_niche_optimization_candidate<'tcx>(
|
|||
match ty.kind() {
|
||||
ty::Adt(ty_def, _) => {
|
||||
let non_exhaustive = ty_def.is_variant_list_non_exhaustive();
|
||||
let empty = (ty_def.is_struct() && ty_def.all_fields().next().is_none())
|
||||
let empty = (ty_def.is_struct() && ty_def.non_enum_variant().fields.is_empty())
|
||||
|| (ty_def.is_enum() && ty_def.variants().is_empty());
|
||||
|
||||
!non_exhaustive && empty
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@
|
|||
//! [representation guarantees][opt-rep] (let's call that type `I`), and the *other* type must meet
|
||||
//! all of the following conditions:
|
||||
//! * Is a zero-sized type with alignment 1 (a "1-ZST").
|
||||
//! * Has no fields.
|
||||
//! * Is either a struct/tuple with no fields, or an enum with no variants.
|
||||
//! * Does not have the `#[non_exhaustive]` attribute.
|
||||
//!
|
||||
//! If that is the case, then `Result<T, E>` has the same size, alignment, and [function call ABI]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue