Skip to content

Commit 4ae36d9

Browse files
committed
Auto merge of #130689 - RalfJung:rustc_nonnull_optimization_guaranteed, r=jieyouxu
fix rustc_nonnull_optimization_guaranteed docs As far as I can tell, even back when this was [added](#60300) it never *enabled* any optimizations. It just indicates that the FFI compat lint should accept those types for NPO.
2 parents 80aa6fa + 8103505 commit 4ae36d9

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Diff for: 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 {

Diff for: compiler/rustc_feature/src/builtin_attrs.rs

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

866868
// ==========================================================================

Diff for: tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
44
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
5-
#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable
5+
#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
66

77
fn main() {}

Diff for: tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ LL | #[rustc_error]
1616
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
1717
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1818

19-
error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable
19+
error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
20+
(note that the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized)
2021
--> $DIR/feature-gate-rustc-attrs-1.rs:5:1
2122
|
2223
LL | #[rustc_nonnull_optimization_guaranteed]

0 commit comments

Comments
 (0)