generalize the message about the creation of layout restricted types

This commit is contained in:
Oliver Scherer 2018-11-04 12:48:51 +01:00
parent c4a850078c
commit 081c49783f
2 changed files with 3 additions and 3 deletions

View file

@ -144,8 +144,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
(Bound::Unbounded, Bound::Unbounded) => {},
_ => self.require_unsafe(
"initializing type with `rustc_layout_scalar_valid_range` attr",
"initializing `NonZero` with a `0` violates layout constraints \
and is undefined behavior",
"initializing a layout restricted type's field with a value outside \
the valid range is undefined behavior",
UnsafetyViolationKind::MinConstFn,
),
}

View file

@ -4,7 +4,7 @@ error[E0133]: initializing type with `rustc_layout_scalar_valid_range` attr is u
LL | let _x = NonZero(0); //~ ERROR initializing type with `rustc_layout_scalar_valid_range` attr
| ^^^^^^^^^^ initializing type with `rustc_layout_scalar_valid_range` attr
|
= note: initializing `NonZero` with a `0` violates layout constraints and is undefined behavior
= note: initializing a layout restricted type's field with a value outside the valid range is undefined behavior
error: aborting due to previous error