Skip to content

Commit 1dff10c

Browse files
committed
clarify comments and names in check_validity_requirement
1 parent 327cf31 commit 1dff10c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

compiler/rustc_const_eval/src/util/check_validity_requirement.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ pub fn check_validity_requirement<'tcx>(
3232

3333
let layout_cx = LayoutCx { tcx, param_env: param_env_and_ty.param_env };
3434
if kind == ValidityRequirement::Uninit || tcx.sess.opts.unstable_opts.strict_init_checks {
35-
might_permit_raw_init_strict(layout, &layout_cx, kind)
35+
check_validity_requirement_strict(layout, &layout_cx, kind)
3636
} else {
37-
might_permit_raw_init_lax(layout, &layout_cx, kind)
37+
check_validity_requirement_lax(layout, &layout_cx, kind)
3838
}
3939
}
4040

41-
/// Implements the 'strict' version of the `might_permit_raw_init` checks; see that function for
41+
/// Implements the 'strict' version of the `check_validity_requirement` checks; see that function for
4242
/// details.
43-
fn might_permit_raw_init_strict<'tcx>(
43+
fn check_validity_requirement_strict<'tcx>(
4444
ty: TyAndLayout<'tcx>,
4545
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
4646
kind: ValidityRequirement,
@@ -65,6 +65,8 @@ fn might_permit_raw_init_strict<'tcx>(
6565
// This does *not* actually check that references are dereferenceable, but since all types that
6666
// require dereferenceability also require non-null, we don't actually get any false negatives
6767
// due to this.
68+
// The value we are validating is temporary and discarded at the end of this function, so
69+
// there is no point in reseting provenance and padding.
6870
Ok(cx
6971
.validate_operand(
7072
&allocated.into(),
@@ -74,9 +76,9 @@ fn might_permit_raw_init_strict<'tcx>(
7476
.is_ok())
7577
}
7678

77-
/// Implements the 'lax' (default) version of the `might_permit_raw_init` checks; see that function for
79+
/// Implements the 'lax' (default) version of the `check_validity_requirement` checks; see that function for
7880
/// details.
79-
fn might_permit_raw_init_lax<'tcx>(
81+
fn check_validity_requirement_lax<'tcx>(
8082
this: TyAndLayout<'tcx>,
8183
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
8284
init_kind: ValidityRequirement,
@@ -141,7 +143,7 @@ fn might_permit_raw_init_lax<'tcx>(
141143
}
142144
FieldsShape::Arbitrary { offsets, .. } => {
143145
for idx in 0..offsets.len() {
144-
if !might_permit_raw_init_lax(this.field(cx, idx), cx, init_kind)? {
146+
if !check_validity_requirement_lax(this.field(cx, idx), cx, init_kind)? {
145147
// We found a field that is unhappy with this kind of initialization.
146148
return Ok(false);
147149
}

0 commit comments

Comments
 (0)