Skip to content

Commit 01732b6

Browse files
committed
Add some comments to transmute_undefined_repr
1 parent c02dff7 commit 01732b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ enum ReducedTys<'tcx> {
189189
Other { from_ty: Ty<'tcx>, to_ty: Ty<'tcx> },
190190
}
191191

192+
/// Remove references so long as both types are references.
192193
fn reduce_refs<'tcx>(
193194
cx: &LateContext<'tcx>,
194195
span: Span,
@@ -227,13 +228,21 @@ fn reduce_refs<'tcx>(
227228
}
228229

229230
enum ReducedTy<'tcx> {
231+
/// The type is a struct containing either zero sized fields, or multiple sized fields with a
232+
/// defined order.
230233
OrderedFields(Ty<'tcx>),
234+
/// The type is a struct containing multiple non-zero sized fields with no defined order.
231235
UnorderedFields(Ty<'tcx>),
236+
/// The type is a reference to the contained type.
232237
Ref(Ty<'tcx>),
233-
Other(Ty<'tcx>),
238+
/// The type is an array of a primitive integer type. These can be used as storage for a value
239+
/// of another type.
234240
IntArray,
241+
/// Any other type.
242+
Other(Ty<'tcx>),
235243
}
236244

245+
/// Reduce structs containing a single non-zero sized field to it's contained type.
237246
fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> {
238247
loop {
239248
ty = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty).unwrap_or(ty);

0 commit comments

Comments
 (0)