Skip to content

Commit 3566948

Browse files
authored
Unrolled build for rust-lang#128284
Rollup merge of rust-lang#128284 - GKFX:stabilize-offset-of-nested, r=dtolnay,jieyouxu Stabilize offset_of_nested Tracking issue rust-lang#120140. Closes rust-lang#120140. As the FCP is now nearing its end I have opened a stabilization PR. I have done this separately to the offset_of_enum feature, since that FCP has not started. `@rustbot` label F-offset_of_nested T-lang T-libs-api
2 parents 612a33f + 23f46e5 commit 3566948

27 files changed

+126
-236
lines changed

compiler/rustc_error_codes/src/error_codes/E0795.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Invalid argument for the `offset_of!` macro.
33
Erroneous code example:
44

55
```compile_fail,E0795
6-
#![feature(offset_of_enum, offset_of_nested)]
6+
#![feature(offset_of_enum)]
77
88
let x = std::mem::offset_of!(Option<u8>, Some);
99
```
@@ -16,7 +16,7 @@ The offset of the contained `u8` in the `Option<u8>` can be found by specifying
1616
the field name `0`:
1717

1818
```
19-
#![feature(offset_of_enum, offset_of_nested)]
19+
#![feature(offset_of_enum)]
2020
2121
let x: usize = std::mem::offset_of!(Option<u8>, Some.0);
2222
```

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ declare_features! (
292292
(accepted, non_exhaustive, "1.40.0", Some(44109)),
293293
/// Allows `foo.rs` as an alternative to `foo/mod.rs`.
294294
(accepted, non_modrs_mods, "1.30.0", Some(44660)),
295+
/// Allows using multiple nested field accesses in offset_of!
296+
(accepted, offset_of_nested, "CURRENT_RUSTC_VERSION", Some(120140)),
295297
/// Allows the use of or-patterns (e.g., `0 | 1`).
296298
(accepted, or_patterns, "1.53.0", Some(54883)),
297299
/// Allows using `+bundle,+whole-archive` link modifiers with native libs.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ declare_features! (
560560
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
561561
/// Allows using enums in offset_of!
562562
(unstable, offset_of_enum, "1.75.0", Some(120141)),
563-
/// Allows using multiple nested field accesses in offset_of!
564-
(unstable, offset_of_nested, "1.77.0", Some(120140)),
565563
/// Allows using fields with slice type in offset_of!
566564
(unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
567565
/// Allows using `#[optimize(X)]`.

compiler/rustc_hir_typeck/src/expr.rs

-12
Original file line numberDiff line numberDiff line change
@@ -3338,18 +3338,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33383338
) -> Ty<'tcx> {
33393339
let container = self.lower_ty(container).normalized;
33403340

3341-
if let Some(ident_2) = fields.get(1)
3342-
&& !self.tcx.features().offset_of_nested
3343-
{
3344-
rustc_session::parse::feature_err(
3345-
&self.tcx.sess,
3346-
sym::offset_of_nested,
3347-
ident_2.span,
3348-
"only a single ident or integer is stable as the field in offset_of",
3349-
)
3350-
.emit();
3351-
}
3352-
33533341
let mut field_indices = Vec::with_capacity(fields.len());
33543342
let mut current_container = container;
33553343
let mut fields = fields.into_iter();

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
//
108108
// Library features:
109109
// tidy-alphabetical-start
110+
#![cfg_attr(bootstrap, feature(offset_of_nested))]
110111
#![feature(array_ptr_get)]
111112
#![feature(asm_experimental_arch)]
112113
#![feature(char_indices_offset)]
@@ -172,7 +173,6 @@
172173
#![feature(isqrt)]
173174
#![feature(link_cfg)]
174175
#![feature(offset_of_enum)]
175-
#![feature(offset_of_nested)]
176176
#![feature(panic_internals)]
177177
#![feature(ptr_alignment_type)]
178178
#![feature(ptr_metadata)]

library/core/src/mem/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,8 @@ impl<T> SizedTypeProperties for T {}
13211321
/// # Examples
13221322
///
13231323
/// ```
1324-
/// #![feature(offset_of_enum, offset_of_nested)]
1324+
/// # #![cfg_attr(bootstrap, feature(offset_of_nested))]
1325+
/// #![feature(offset_of_enum)]
13251326
///
13261327
/// use std::mem;
13271328
/// #[repr(C)]

library/core/tests/lib.rs

+56-54
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
// tidy-alphabetical-start
2+
#![cfg_attr(bootstrap, feature(offset_of_nested))]
3+
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
4+
#![cfg_attr(test, feature(cfg_match))]
15
#![feature(alloc_layout_extra)]
26
#![feature(array_chunks)]
37
#![feature(array_ptr_get)]
8+
#![feature(array_try_from_fn)]
49
#![feature(array_windows)]
510
#![feature(ascii_char)]
611
#![feature(ascii_char_variants)]
@@ -9,112 +14,109 @@
914
#![feature(bigint_helper_methods)]
1015
#![feature(cell_update)]
1116
#![feature(clone_to_uninit)]
12-
#![feature(const_align_offset)]
1317
#![feature(const_align_of_val_raw)]
18+
#![feature(const_align_offset)]
19+
#![feature(const_array_from_ref)]
1420
#![feature(const_black_box)]
1521
#![feature(const_cell_into_inner)]
1622
#![feature(const_hash)]
1723
#![feature(const_heap)]
1824
#![feature(const_intrinsic_copy)]
25+
#![feature(const_ip)]
26+
#![feature(const_ipv4)]
27+
#![feature(const_ipv6)]
28+
#![feature(const_likely)]
1929
#![feature(const_maybe_uninit_as_mut_ptr)]
30+
#![feature(const_mut_refs)]
2031
#![feature(const_nonnull_new)]
32+
#![feature(const_option)]
33+
#![feature(const_option_ext)]
34+
#![feature(const_pin)]
2135
#![feature(const_pointer_is_aligned)]
2236
#![feature(const_ptr_as_ref)]
2337
#![feature(const_ptr_write)]
38+
#![feature(const_result)]
39+
#![feature(const_slice_from_ref)]
2440
#![feature(const_three_way_compare)]
2541
#![feature(const_trait_impl)]
26-
#![feature(const_likely)]
2742
#![feature(core_intrinsics)]
2843
#![feature(core_io_borrowed_buf)]
2944
#![feature(core_private_bignum)]
3045
#![feature(core_private_diy_float)]
3146
#![feature(dec2flt)]
32-
#![feature(duration_consts_float)]
3347
#![feature(duration_constants)]
3448
#![feature(duration_constructors)]
49+
#![feature(duration_consts_float)]
50+
#![feature(error_generic_member_access)]
3551
#![feature(exact_size_is_empty)]
3652
#![feature(extern_types)]
37-
#![feature(freeze)]
53+
#![feature(float_minimum_maximum)]
3854
#![feature(flt2dec)]
3955
#![feature(fmt_internals)]
40-
#![feature(float_minimum_maximum)]
56+
#![feature(freeze)]
4157
#![feature(future_join)]
4258
#![feature(generic_assert_internals)]
43-
#![feature(array_try_from_fn)]
59+
#![feature(get_many_mut)]
4460
#![feature(hasher_prefixfree_extras)]
4561
#![feature(hashmap_internals)]
46-
#![feature(try_find)]
47-
#![feature(layout_for_ptr)]
48-
#![feature(pattern)]
49-
#![feature(slice_take)]
50-
#![feature(slice_from_ptr_range)]
51-
#![feature(slice_split_once)]
52-
#![feature(split_as_slice)]
53-
#![feature(maybe_uninit_fill)]
54-
#![feature(maybe_uninit_write_slice)]
55-
#![feature(maybe_uninit_uninit_array_transpose)]
56-
#![feature(min_specialization)]
57-
#![feature(noop_waker)]
58-
#![feature(numfmt)]
59-
#![feature(num_midpoint)]
60-
#![feature(offset_of_nested)]
61-
#![feature(isqrt)]
62-
#![feature(unsigned_is_multiple_of)]
63-
#![feature(step_trait)]
64-
#![feature(str_internals)]
65-
#![feature(std_internals)]
66-
#![feature(test)]
67-
#![feature(trusted_len)]
68-
#![feature(try_blocks)]
69-
#![feature(try_trait_v2)]
70-
#![feature(slice_internals)]
71-
#![feature(slice_partition_dedup)]
62+
#![feature(int_roundings)]
7263
#![feature(ip)]
64+
#![feature(is_ascii_octdigit)]
65+
#![feature(isqrt)]
7366
#![feature(iter_advance_by)]
7467
#![feature(iter_array_chunks)]
7568
#![feature(iter_chain)]
7669
#![feature(iter_collect_into)]
77-
#![feature(iter_partition_in_place)]
7870
#![feature(iter_intersperse)]
7971
#![feature(iter_is_partitioned)]
72+
#![feature(iter_map_windows)]
8073
#![feature(iter_next_chunk)]
8174
#![feature(iter_order_by)]
75+
#![feature(iter_partition_in_place)]
8276
#![feature(iter_repeat_n)]
8377
#![feature(iterator_try_collect)]
8478
#![feature(iterator_try_reduce)]
85-
#![feature(const_ip)]
86-
#![feature(const_ipv4)]
87-
#![feature(const_ipv6)]
88-
#![feature(const_mut_refs)]
89-
#![feature(const_pin)]
79+
#![feature(layout_for_ptr)]
80+
#![feature(maybe_uninit_fill)]
81+
#![feature(maybe_uninit_uninit_array_transpose)]
82+
#![feature(maybe_uninit_write_slice)]
83+
#![feature(min_specialization)]
9084
#![feature(never_type)]
91-
#![feature(unwrap_infallible)]
85+
#![feature(noop_waker)]
86+
#![feature(num_midpoint)]
87+
#![feature(numfmt)]
88+
#![feature(pattern)]
9289
#![feature(pointer_is_aligned_to)]
9390
#![feature(portable_simd)]
9491
#![feature(ptr_metadata)]
95-
#![feature(unsized_tuple_coercion)]
96-
#![feature(const_option)]
97-
#![feature(const_option_ext)]
98-
#![feature(const_result)]
99-
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
100-
#![cfg_attr(test, feature(cfg_match))]
101-
#![feature(int_roundings)]
92+
#![feature(slice_from_ptr_range)]
93+
#![feature(slice_internals)]
94+
#![feature(slice_partition_dedup)]
95+
#![feature(slice_split_once)]
96+
#![feature(slice_take)]
10297
#![feature(split_array)]
98+
#![feature(split_as_slice)]
99+
#![feature(std_internals)]
100+
#![feature(step_trait)]
101+
#![feature(str_internals)]
103102
#![feature(strict_provenance)]
104103
#![feature(strict_provenance_atomic_ptr)]
104+
#![feature(test)]
105+
#![feature(trait_upcasting)]
106+
#![feature(trusted_len)]
105107
#![feature(trusted_random_access)]
108+
#![feature(try_blocks)]
109+
#![feature(try_find)]
110+
#![feature(try_trait_v2)]
111+
#![feature(unsigned_is_multiple_of)]
106112
#![feature(unsize)]
107-
#![feature(const_array_from_ref)]
108-
#![feature(const_slice_from_ref)]
113+
#![feature(unsized_tuple_coercion)]
114+
#![feature(unwrap_infallible)]
109115
#![feature(waker_getters)]
110-
#![feature(error_generic_member_access)]
111-
#![feature(trait_upcasting)]
112-
#![feature(is_ascii_octdigit)]
113-
#![feature(get_many_mut)]
114-
#![feature(iter_map_windows)]
116+
// tidy-alphabetical-end
115117
#![allow(internal_features)]
116-
#![deny(unsafe_op_in_unsafe_fn)]
117118
#![deny(fuzzy_provenance_casts)]
119+
#![deny(unsafe_op_in_unsafe_fn)]
118120

119121
mod alloc;
120122
mod any;

tests/mir-opt/const_prop/offset_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ test-mir-pass: GVN
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44

5-
#![feature(offset_of_enum, offset_of_nested)]
5+
#![feature(offset_of_enum)]
66

77
use std::marker::PhantomData;
88
use std::mem::offset_of;

tests/mir-opt/dataflow-const-prop/offset_of.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//@ test-mir-pass: DataflowConstProp
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
33

4-
#![feature(offset_of_nested)]
5-
64
use std::marker::PhantomData;
75
use std::mem::offset_of;
86

tests/ui/feature-gates/feature-gate-offset-of-enum.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(offset_of_nested)]
2-
31
use std::mem::offset_of;
42

53
enum Alpha {

tests/ui/feature-gates/feature-gate-offset-of-enum.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0573]: expected type, found variant `Alpha::One`
2-
--> $DIR/feature-gate-offset-of-enum.rs:11:16
2+
--> $DIR/feature-gate-offset-of-enum.rs:9:16
33
|
44
LL | offset_of!(Alpha::One, 0);
55
| ^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | offset_of!(Alpha::One, 0);
88
| help: try using the variant's enum: `Alpha`
99

1010
error[E0658]: using enums in offset_of is experimental
11-
--> $DIR/feature-gate-offset-of-enum.rs:12:23
11+
--> $DIR/feature-gate-offset-of-enum.rs:10:23
1212
|
1313
LL | offset_of!(Alpha, One);
1414
| ^^^
@@ -18,13 +18,13 @@ LL | offset_of!(Alpha, One);
1818
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1919

2020
error[E0795]: `One` is an enum variant; expected field at end of `offset_of`
21-
--> $DIR/feature-gate-offset-of-enum.rs:12:23
21+
--> $DIR/feature-gate-offset-of-enum.rs:10:23
2222
|
2323
LL | offset_of!(Alpha, One);
2424
| ^^^ enum variant
2525

2626
error[E0658]: using enums in offset_of is experimental
27-
--> $DIR/feature-gate-offset-of-enum.rs:14:23
27+
--> $DIR/feature-gate-offset-of-enum.rs:12:23
2828
|
2929
LL | offset_of!(Alpha, Two.0);
3030
| ^^^

tests/ui/feature-gates/feature-gate-offset-of-nested.rs

-28
This file was deleted.

0 commit comments

Comments
 (0)