diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2022-02-15 11:39:19 -0500 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2022-02-18 15:01:58 -0500 |
| commit | 01732b60192ed7f99571090b5b87f61ab8c98e75 (patch) | |
| tree | b00477551fa514720640ffc672c2f51898bdd592 | |
| parent | c02dff716785721c4c992d03ee816d764fb43402 (diff) | |
| download | rust-01732b60192ed7f99571090b5b87f61ab8c98e75.tar.gz rust-01732b60192ed7f99571090b5b87f61ab8c98e75.zip | |
Add some comments to `transmute_undefined_repr`
| -rw-r--r-- | clippy_lints/src/transmute/transmute_undefined_repr.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clippy_lints/src/transmute/transmute_undefined_repr.rs b/clippy_lints/src/transmute/transmute_undefined_repr.rs index 74ea7a3b893..5b08ad5840a 100644 --- a/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -189,6 +189,7 @@ enum ReducedTys<'tcx> { Other { from_ty: Ty<'tcx>, to_ty: Ty<'tcx> }, } +/// Remove references so long as both types are references. fn reduce_refs<'tcx>( cx: &LateContext<'tcx>, span: Span, @@ -227,13 +228,21 @@ fn reduce_refs<'tcx>( } enum ReducedTy<'tcx> { + /// The type is a struct containing either zero sized fields, or multiple sized fields with a + /// defined order. OrderedFields(Ty<'tcx>), + /// The type is a struct containing multiple non-zero sized fields with no defined order. UnorderedFields(Ty<'tcx>), + /// The type is a reference to the contained type. Ref(Ty<'tcx>), - Other(Ty<'tcx>), + /// The type is an array of a primitive integer type. These can be used as storage for a value + /// of another type. IntArray, + /// Any other type. + Other(Ty<'tcx>), } +/// Reduce structs containing a single non-zero sized field to it's contained type. fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> { loop { ty = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty).unwrap_or(ty); |
