Skip to content

Commit 38900f5

Browse files
committed
fix rustc_nonnull_optimization_guaranteed docs
1 parent c0838c8 commit 38900f5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
234234
// so we implement a type-based check that reflects the guaranteed rules for ABI compatibility.
235235
if self.layout_compat(caller_abi.layout, callee_abi.layout)? {
236236
// Ensure that our checks imply actual ABI compatibility for this concrete call.
237+
// (This can fail e.g. if `#[rustc_nonnull_optimization_guaranteed]` is used incorrectly.)
237238
assert!(caller_abi.eq_abi(callee_abi));
238239
Ok(true)
239240
} else {

compiler/rustc_feature/src/builtin_attrs.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
863863
rustc_attr!(
864864
rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing,
865865
EncodeCrossCrate::Yes,
866-
"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \
867-
niche optimizations in libcore and libstd and will never be stable",
866+
"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document \
867+
guaranteed niche optimizations in libcore and libstd and will never be stable
868+
(note that the compiler does not even check whether the type indeed is being non-null-optimized;
869+
it is your responsibility to ensure that the attribute is only used on types that are optimized)",
868870
),
869871

870872
// ==========================================================================

0 commit comments

Comments
 (0)