Rollup merge of #128284 - GKFX:stabilize-offset-of-nested, r=dtolnay,jieyouxu

Stabilize offset_of_nested

Tracking issue #120140. Closes #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
This commit is contained in:
Matthias Krüger 2024-07-29 21:26:13 +02:00 committed by GitHub
commit a73a025190
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 128 additions and 238 deletions

View File

@ -3,7 +3,7 @@ Invalid argument for the `offset_of!` macro.
Erroneous code example: Erroneous code example:
```compile_fail,E0795 ```compile_fail,E0795
#![feature(offset_of_enum, offset_of_nested)] #![feature(offset_of_enum)]
let x = std::mem::offset_of!(Option<u8>, Some); let x = std::mem::offset_of!(Option<u8>, Some);
``` ```
@ -16,7 +16,7 @@ The offset of the contained `u8` in the `Option<u8>` can be found by specifying
the field name `0`: the field name `0`:
``` ```
#![feature(offset_of_enum, offset_of_nested)] #![feature(offset_of_enum)]
let x: usize = std::mem::offset_of!(Option<u8>, Some.0); let x: usize = std::mem::offset_of!(Option<u8>, Some.0);
``` ```

View File

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

View File

@ -560,8 +560,6 @@ declare_features! (
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)), (unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
/// Allows using enums in offset_of! /// Allows using enums in offset_of!
(unstable, offset_of_enum, "1.75.0", Some(120141)), (unstable, offset_of_enum, "1.75.0", Some(120141)),
/// Allows using multiple nested field accesses in offset_of!
(unstable, offset_of_nested, "1.77.0", Some(120140)),
/// Allows using fields with slice type in offset_of! /// Allows using fields with slice type in offset_of!
(unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)), (unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
/// Allows using `#[optimize(X)]`. /// Allows using `#[optimize(X)]`.

View File

@ -3338,18 +3338,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Ty<'tcx> { ) -> Ty<'tcx> {
let container = self.lower_ty(container).normalized; let container = self.lower_ty(container).normalized;
if let Some(ident_2) = fields.get(1)
&& !self.tcx.features().offset_of_nested
{
rustc_session::parse::feature_err(
&self.tcx.sess,
sym::offset_of_nested,
ident_2.span,
"only a single ident or integer is stable as the field in offset_of",
)
.emit();
}
let mut field_indices = Vec::with_capacity(fields.len()); let mut field_indices = Vec::with_capacity(fields.len());
let mut current_container = container; let mut current_container = container;
let mut fields = fields.into_iter(); let mut fields = fields.into_iter();

View File

@ -107,6 +107,7 @@
// //
// Library features: // Library features:
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(offset_of_nested))]
#![feature(array_ptr_get)] #![feature(array_ptr_get)]
#![feature(asm_experimental_arch)] #![feature(asm_experimental_arch)]
#![feature(char_indices_offset)] #![feature(char_indices_offset)]
@ -172,7 +173,6 @@
#![feature(isqrt)] #![feature(isqrt)]
#![feature(link_cfg)] #![feature(link_cfg)]
#![feature(offset_of_enum)] #![feature(offset_of_enum)]
#![feature(offset_of_nested)]
#![feature(panic_internals)] #![feature(panic_internals)]
#![feature(ptr_alignment_type)] #![feature(ptr_alignment_type)]
#![feature(ptr_metadata)] #![feature(ptr_metadata)]

View File

@ -1321,7 +1321,8 @@ impl<T> SizedTypeProperties for T {}
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(offset_of_enum, offset_of_nested)] /// # #![cfg_attr(bootstrap, feature(offset_of_nested))]
/// #![feature(offset_of_enum)]
/// ///
/// use std::mem; /// use std::mem;
/// #[repr(C)] /// #[repr(C)]

View File

@ -1,6 +1,11 @@
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(offset_of_nested))]
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![cfg_attr(test, feature(cfg_match))]
#![feature(alloc_layout_extra)] #![feature(alloc_layout_extra)]
#![feature(array_chunks)] #![feature(array_chunks)]
#![feature(array_ptr_get)] #![feature(array_ptr_get)]
#![feature(array_try_from_fn)]
#![feature(array_windows)] #![feature(array_windows)]
#![feature(ascii_char)] #![feature(ascii_char)]
#![feature(ascii_char_variants)] #![feature(ascii_char_variants)]
@ -9,112 +14,109 @@
#![feature(bigint_helper_methods)] #![feature(bigint_helper_methods)]
#![feature(cell_update)] #![feature(cell_update)]
#![feature(clone_to_uninit)] #![feature(clone_to_uninit)]
#![feature(const_align_offset)]
#![feature(const_align_of_val_raw)] #![feature(const_align_of_val_raw)]
#![feature(const_align_offset)]
#![feature(const_array_from_ref)]
#![feature(const_black_box)] #![feature(const_black_box)]
#![feature(const_cell_into_inner)] #![feature(const_cell_into_inner)]
#![feature(const_hash)] #![feature(const_hash)]
#![feature(const_heap)] #![feature(const_heap)]
#![feature(const_intrinsic_copy)] #![feature(const_intrinsic_copy)]
#![feature(const_ip)]
#![feature(const_ipv4)]
#![feature(const_ipv6)]
#![feature(const_likely)]
#![feature(const_maybe_uninit_as_mut_ptr)] #![feature(const_maybe_uninit_as_mut_ptr)]
#![feature(const_mut_refs)]
#![feature(const_nonnull_new)] #![feature(const_nonnull_new)]
#![feature(const_option)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pointer_is_aligned)] #![feature(const_pointer_is_aligned)]
#![feature(const_ptr_as_ref)] #![feature(const_ptr_as_ref)]
#![feature(const_ptr_write)] #![feature(const_ptr_write)]
#![feature(const_result)]
#![feature(const_slice_from_ref)]
#![feature(const_three_way_compare)] #![feature(const_three_way_compare)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_likely)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(core_io_borrowed_buf)] #![feature(core_io_borrowed_buf)]
#![feature(core_private_bignum)] #![feature(core_private_bignum)]
#![feature(core_private_diy_float)] #![feature(core_private_diy_float)]
#![feature(dec2flt)] #![feature(dec2flt)]
#![feature(duration_consts_float)]
#![feature(duration_constants)] #![feature(duration_constants)]
#![feature(duration_constructors)] #![feature(duration_constructors)]
#![feature(duration_consts_float)]
#![feature(error_generic_member_access)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(freeze)] #![feature(float_minimum_maximum)]
#![feature(flt2dec)] #![feature(flt2dec)]
#![feature(fmt_internals)] #![feature(fmt_internals)]
#![feature(float_minimum_maximum)] #![feature(freeze)]
#![feature(future_join)] #![feature(future_join)]
#![feature(generic_assert_internals)] #![feature(generic_assert_internals)]
#![feature(array_try_from_fn)] #![feature(get_many_mut)]
#![feature(hasher_prefixfree_extras)] #![feature(hasher_prefixfree_extras)]
#![feature(hashmap_internals)] #![feature(hashmap_internals)]
#![feature(try_find)] #![feature(int_roundings)]
#![feature(layout_for_ptr)]
#![feature(pattern)]
#![feature(slice_take)]
#![feature(slice_from_ptr_range)]
#![feature(slice_split_once)]
#![feature(split_as_slice)]
#![feature(maybe_uninit_fill)]
#![feature(maybe_uninit_write_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(min_specialization)]
#![feature(noop_waker)]
#![feature(numfmt)]
#![feature(num_midpoint)]
#![feature(offset_of_nested)]
#![feature(isqrt)]
#![feature(unsigned_is_multiple_of)]
#![feature(step_trait)]
#![feature(str_internals)]
#![feature(std_internals)]
#![feature(test)]
#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(try_trait_v2)]
#![feature(slice_internals)]
#![feature(slice_partition_dedup)]
#![feature(ip)] #![feature(ip)]
#![feature(is_ascii_octdigit)]
#![feature(isqrt)]
#![feature(iter_advance_by)] #![feature(iter_advance_by)]
#![feature(iter_array_chunks)] #![feature(iter_array_chunks)]
#![feature(iter_chain)] #![feature(iter_chain)]
#![feature(iter_collect_into)] #![feature(iter_collect_into)]
#![feature(iter_partition_in_place)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(iter_is_partitioned)] #![feature(iter_is_partitioned)]
#![feature(iter_map_windows)]
#![feature(iter_next_chunk)] #![feature(iter_next_chunk)]
#![feature(iter_order_by)] #![feature(iter_order_by)]
#![feature(iter_partition_in_place)]
#![feature(iter_repeat_n)] #![feature(iter_repeat_n)]
#![feature(iterator_try_collect)] #![feature(iterator_try_collect)]
#![feature(iterator_try_reduce)] #![feature(iterator_try_reduce)]
#![feature(const_ip)] #![feature(layout_for_ptr)]
#![feature(const_ipv4)] #![feature(maybe_uninit_fill)]
#![feature(const_ipv6)] #![feature(maybe_uninit_uninit_array_transpose)]
#![feature(const_mut_refs)] #![feature(maybe_uninit_write_slice)]
#![feature(const_pin)] #![feature(min_specialization)]
#![feature(never_type)] #![feature(never_type)]
#![feature(unwrap_infallible)] #![feature(noop_waker)]
#![feature(num_midpoint)]
#![feature(numfmt)]
#![feature(pattern)]
#![feature(pointer_is_aligned_to)] #![feature(pointer_is_aligned_to)]
#![feature(portable_simd)] #![feature(portable_simd)]
#![feature(ptr_metadata)] #![feature(ptr_metadata)]
#![feature(unsized_tuple_coercion)] #![feature(slice_from_ptr_range)]
#![feature(const_option)] #![feature(slice_internals)]
#![feature(const_option_ext)] #![feature(slice_partition_dedup)]
#![feature(const_result)] #![feature(slice_split_once)]
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] #![feature(slice_take)]
#![cfg_attr(test, feature(cfg_match))]
#![feature(int_roundings)]
#![feature(split_array)] #![feature(split_array)]
#![feature(split_as_slice)]
#![feature(std_internals)]
#![feature(step_trait)]
#![feature(str_internals)]
#![feature(strict_provenance)] #![feature(strict_provenance)]
#![feature(strict_provenance_atomic_ptr)] #![feature(strict_provenance_atomic_ptr)]
#![feature(trusted_random_access)] #![feature(test)]
#![feature(unsize)]
#![feature(const_array_from_ref)]
#![feature(const_slice_from_ref)]
#![feature(waker_getters)]
#![feature(error_generic_member_access)]
#![feature(trait_upcasting)] #![feature(trait_upcasting)]
#![feature(is_ascii_octdigit)] #![feature(trusted_len)]
#![feature(get_many_mut)] #![feature(trusted_random_access)]
#![feature(iter_map_windows)] #![feature(try_blocks)]
#![feature(try_find)]
#![feature(try_trait_v2)]
#![feature(unsigned_is_multiple_of)]
#![feature(unsize)]
#![feature(unsized_tuple_coercion)]
#![feature(unwrap_infallible)]
#![feature(waker_getters)]
// tidy-alphabetical-end
#![allow(internal_features)] #![allow(internal_features)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(fuzzy_provenance_casts)] #![deny(fuzzy_provenance_casts)]
#![deny(unsafe_op_in_unsafe_fn)]
mod alloc; mod alloc;
mod any; mod any;

View File

@ -2,7 +2,7 @@
//@ test-mir-pass: GVN //@ test-mir-pass: GVN
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![feature(offset_of_enum, offset_of_nested)] #![feature(offset_of_enum)]
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,8 +1,6 @@
//@ test-mir-pass: DataflowConstProp //@ test-mir-pass: DataflowConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![feature(offset_of_nested)]
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,5 +1,3 @@
#![feature(offset_of_nested)]
use std::mem::offset_of; use std::mem::offset_of;
enum Alpha { enum Alpha {

View File

@ -1,5 +1,5 @@
error[E0573]: expected type, found variant `Alpha::One` error[E0573]: expected type, found variant `Alpha::One`
--> $DIR/feature-gate-offset-of-enum.rs:11:16 --> $DIR/feature-gate-offset-of-enum.rs:9:16
| |
LL | offset_of!(Alpha::One, 0); LL | offset_of!(Alpha::One, 0);
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -8,7 +8,7 @@ LL | offset_of!(Alpha::One, 0);
| help: try using the variant's enum: `Alpha` | help: try using the variant's enum: `Alpha`
error[E0658]: using enums in offset_of is experimental error[E0658]: using enums in offset_of is experimental
--> $DIR/feature-gate-offset-of-enum.rs:12:23 --> $DIR/feature-gate-offset-of-enum.rs:10:23
| |
LL | offset_of!(Alpha, One); LL | offset_of!(Alpha, One);
| ^^^ | ^^^
@ -18,13 +18,13 @@ LL | offset_of!(Alpha, One);
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0795]: `One` is an enum variant; expected field at end of `offset_of` error[E0795]: `One` is an enum variant; expected field at end of `offset_of`
--> $DIR/feature-gate-offset-of-enum.rs:12:23 --> $DIR/feature-gate-offset-of-enum.rs:10:23
| |
LL | offset_of!(Alpha, One); LL | offset_of!(Alpha, One);
| ^^^ enum variant | ^^^ enum variant
error[E0658]: using enums in offset_of is experimental error[E0658]: using enums in offset_of is experimental
--> $DIR/feature-gate-offset-of-enum.rs:14:23 --> $DIR/feature-gate-offset-of-enum.rs:12:23
| |
LL | offset_of!(Alpha, Two.0); LL | offset_of!(Alpha, Two.0);
| ^^^ | ^^^

View File

@ -1,28 +0,0 @@
#![feature(offset_of_enum)]
use std::mem::offset_of;
struct S {
a: u8,
b: (u8, u8),
c: T,
}
struct T {
t: &'static str,
}
enum Alpha {
One(u8),
Two(u8),
}
fn main() {
offset_of!(Alpha, Two.0); //~ ERROR only a single ident or integer is stable as the field in offset_of
offset_of!(S, a);
offset_of!((u8, S), 1);
offset_of!((u32, (S, T)), 1.1); //~ ERROR only a single ident or integer is stable as the field in offset_of
offset_of!(S, b.0); //~ ERROR only a single ident or integer is stable as the field in offset_of
offset_of!((S, ()), 0.c); //~ ERROR only a single ident or integer is stable as the field in offset_of
offset_of!(S, c.t); //~ ERROR only a single ident or integer is stable as the field in offset_of
}

View File

@ -1,60 +0,0 @@
error[E0658]: only a single ident or integer is stable as the field in offset_of
--> $DIR/feature-gate-offset-of-nested.rs:21:27
|
LL | offset_of!(Alpha, Two.0);
| ^
|
= note: see issue #120140 <https://github.com/rust-lang/rust/issues/120140> for more information
= help: add `#![feature(offset_of_nested)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: only a single ident or integer is stable as the field in offset_of
--> $DIR/feature-gate-offset-of-nested.rs:24:33
|
LL | offset_of!((u32, (S, T)), 1.1);
| _____----------------------------^-
| | |
| | in this macro invocation
LL | | offset_of!(S, b.0);
LL | | offset_of!((S, ()), 0.c);
LL | | offset_of!(S, c.t);
... |
|
= note: see issue #120140 <https://github.com/rust-lang/rust/issues/120140> for more information
= help: add `#![feature(offset_of_nested)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: only a single ident or integer is stable as the field in offset_of
--> $DIR/feature-gate-offset-of-nested.rs:25:21
|
LL | offset_of!(S, b.0);
| ^
|
= note: see issue #120140 <https://github.com/rust-lang/rust/issues/120140> for more information
= help: add `#![feature(offset_of_nested)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: only a single ident or integer is stable as the field in offset_of
--> $DIR/feature-gate-offset-of-nested.rs:26:27
|
LL | offset_of!((S, ()), 0.c);
| ^
|
= note: see issue #120140 <https://github.com/rust-lang/rust/issues/120140> for more information
= help: add `#![feature(offset_of_nested)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: only a single ident or integer is stable as the field in offset_of
--> $DIR/feature-gate-offset-of-nested.rs:27:21
|
LL | offset_of!(S, c.t);
| ^
|
= note: see issue #120140 <https://github.com/rust-lang/rust/issues/120140> for more information
= help: add `#![feature(offset_of_nested)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,6 +1,5 @@
//@ check-pass //@ check-pass
#![feature(offset_of_nested)]
#![deny(dead_code)] #![deny(dead_code)]
// This struct contains a projection that can only be normalized after getting the field type. // This struct contains a projection that can only be normalized after getting the field type.

View File

@ -1,4 +1,3 @@
#![feature(offset_of_nested)]
#![deny(dead_code)] #![deny(dead_code)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,5 +1,5 @@
error: field `b` is never read error: field `b` is never read
--> $DIR/offset-of.rs:8:5 --> $DIR/offset-of.rs:7:5
| |
LL | struct Alpha { LL | struct Alpha {
| ----- field in this struct | ----- field in this struct
@ -8,13 +8,13 @@ LL | b: (),
| ^ | ^
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/offset-of.rs:2:9 --> $DIR/offset-of.rs:1:9
| |
LL | #![deny(dead_code)] LL | #![deny(dead_code)]
| ^^^^^^^^^ | ^^^^^^^^^
error: field `a` is never read error: field `a` is never read
--> $DIR/offset-of.rs:13:5 --> $DIR/offset-of.rs:12:5
| |
LL | struct Beta { LL | struct Beta {
| ---- field in this struct | ---- field in this struct
@ -22,7 +22,7 @@ LL | a: (),
| ^ | ^
error: field `a` is never read error: field `a` is never read
--> $DIR/offset-of.rs:18:5 --> $DIR/offset-of.rs:17:5
| |
LL | struct Gamma { LL | struct Gamma {
| ----- field in this struct | ----- field in this struct
@ -30,7 +30,7 @@ LL | a: (),
| ^ | ^
error: field `b` is never read error: field `b` is never read
--> $DIR/offset-of.rs:24:5 --> $DIR/offset-of.rs:23:5
| |
LL | struct Delta { LL | struct Delta {
| ----- field in this struct | ----- field in this struct
@ -39,7 +39,7 @@ LL | b: (),
| ^ | ^
error: field `a` is never read error: field `a` is never read
--> $DIR/offset-of.rs:35:5 --> $DIR/offset-of.rs:34:5
| |
LL | struct Project<T: Trait> { LL | struct Project<T: Trait> {
| ------- field in this struct | ------- field in this struct

View File

@ -1,4 +1,4 @@
#![feature(offset_of_enum, offset_of_nested)] #![feature(offset_of_enum)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,4 +1,4 @@
#![feature(offset_of_enum, offset_of_nested)] #![feature(offset_of_enum)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,5 +1,3 @@
#![feature(offset_of_nested)]
use std::mem::offset_of; use std::mem::offset_of;
struct C<T> { struct C<T> {

View File

@ -1,11 +1,11 @@
error: offset_of expects dot-separated field and variant names error: offset_of expects dot-separated field and variant names
--> $DIR/offset-of-self.rs:20:26 --> $DIR/offset-of-self.rs:18:26
| |
LL | offset_of!(Self, Self::v); LL | offset_of!(Self, Self::v);
| ^^^^^^^ | ^^^^^^^
error[E0412]: cannot find type `S` in module `self` error[E0412]: cannot find type `S` in module `self`
--> $DIR/offset-of-self.rs:34:26 --> $DIR/offset-of-self.rs:32:26
| |
LL | offset_of!(self::S, v); LL | offset_of!(self::S, v);
| ^ not found in `self` | ^ not found in `self`
@ -21,7 +21,7 @@ LL + offset_of!(S, v);
| |
error[E0411]: cannot find type `Self` in this scope error[E0411]: cannot find type `Self` in this scope
--> $DIR/offset-of-self.rs:51:16 --> $DIR/offset-of-self.rs:49:16
| |
LL | fn main() { LL | fn main() {
| ---- `Self` not allowed in a function | ---- `Self` not allowed in a function
@ -30,7 +30,7 @@ LL | offset_of!(Self, v);
| ^^^^ `Self` is only available in impls, traits, and type definitions | ^^^^ `Self` is only available in impls, traits, and type definitions
error[E0609]: no field `Self` on type `S` error[E0609]: no field `Self` on type `S`
--> $DIR/offset-of-self.rs:21:23 --> $DIR/offset-of-self.rs:19:23
| |
LL | offset_of!(S, Self); LL | offset_of!(S, Self);
| ^^^^ | ^^^^
@ -38,13 +38,13 @@ LL | offset_of!(S, Self);
= note: available fields are: `v`, `w` = note: available fields are: `v`, `w`
error[E0616]: field `v` of struct `T` is private error[E0616]: field `v` of struct `T` is private
--> $DIR/offset-of-self.rs:40:30 --> $DIR/offset-of-self.rs:38:30
| |
LL | offset_of!(Self, v) LL | offset_of!(Self, v)
| ^ private field | ^ private field
error[E0609]: no field `self` on type `S` error[E0609]: no field `self` on type `S`
--> $DIR/offset-of-self.rs:53:19 --> $DIR/offset-of-self.rs:51:19
| |
LL | offset_of!(S, self); LL | offset_of!(S, self);
| ^^^^ | ^^^^
@ -52,7 +52,7 @@ LL | offset_of!(S, self);
= note: available fields are: `v`, `w` = note: available fields are: `v`, `w`
error[E0609]: no field `self` on type `u8` error[E0609]: no field `self` on type `u8`
--> $DIR/offset-of-self.rs:54:21 --> $DIR/offset-of-self.rs:52:21
| |
LL | offset_of!(S, v.self); LL | offset_of!(S, v.self);
| ^^^^ | ^^^^

View File

@ -1,5 +1,5 @@
//@run-pass //@run-pass
#![feature(offset_of_slice, offset_of_nested)] #![feature(offset_of_slice)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -2,8 +2,6 @@
// Test for issue #112204 -- make sure this goes through the entire compilation pipeline, // Test for issue #112204 -- make sure this goes through the entire compilation pipeline,
// similar to why `offset-of-unsized.rs` is also build-pass // similar to why `offset-of-unsized.rs` is also build-pass
#![feature(offset_of_nested)]
use std::mem::offset_of; use std::mem::offset_of;
type ComplexTup = ((u8, (u8, (u8, u16), u8)), (u8, u32, u16)); type ComplexTup = ((u8, (u8, (u8, u16), u8)), (u8, u32, u16));

View File

@ -1,4 +1,3 @@
#![feature(offset_of_nested)]
#![feature(builtin_syntax)] #![feature(builtin_syntax)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,11 +1,11 @@
error: suffixes on a tuple index are invalid error: suffixes on a tuple index are invalid
--> $DIR/offset-of-tuple.rs:19:35 --> $DIR/offset-of-tuple.rs:18:35
| |
LL | builtin # offset_of((u8, u8), 1_u8); LL | builtin # offset_of((u8, u8), 1_u8);
| ^^^^ invalid suffix `u8` | ^^^^ invalid suffix `u8`
error: leading `+` is not supported error: leading `+` is not supported
--> $DIR/offset-of-tuple.rs:23:37 --> $DIR/offset-of-tuple.rs:22:37
| |
LL | { builtin # offset_of((u8, u8), +1) }; LL | { builtin # offset_of((u8, u8), +1) };
| ^ unexpected `+` | ^ unexpected `+`
@ -17,67 +17,67 @@ LL + { builtin # offset_of((u8, u8), 1) };
| |
error: offset_of expects dot-separated field and variant names error: offset_of expects dot-separated field and variant names
--> $DIR/offset-of-tuple.rs:24:38 --> $DIR/offset-of-tuple.rs:23:38
| |
LL | { builtin # offset_of((u8, u8), 1.) }; LL | { builtin # offset_of((u8, u8), 1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:25:40 --> $DIR/offset-of-tuple.rs:24:40
| |
LL | { builtin # offset_of((u8, u8), 1 .) }; LL | { builtin # offset_of((u8, u8), 1 .) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:47:45 --> $DIR/offset-of-tuple.rs:46:45
| |
LL | { builtin # offset_of(ComplexTup, 0.0.1.) }; LL | { builtin # offset_of(ComplexTup, 0.0.1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:48:46 --> $DIR/offset-of-tuple.rs:47:46
| |
LL | { builtin # offset_of(ComplexTup, 0 .0.1.) }; LL | { builtin # offset_of(ComplexTup, 0 .0.1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:49:47 --> $DIR/offset-of-tuple.rs:48:47
| |
LL | { builtin # offset_of(ComplexTup, 0 . 0.1.) }; LL | { builtin # offset_of(ComplexTup, 0 . 0.1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:50:46 --> $DIR/offset-of-tuple.rs:49:46
| |
LL | { builtin # offset_of(ComplexTup, 0. 0.1.) }; LL | { builtin # offset_of(ComplexTup, 0. 0.1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:51:46 --> $DIR/offset-of-tuple.rs:50:46
| |
LL | { builtin # offset_of(ComplexTup, 0.0 .1.) }; LL | { builtin # offset_of(ComplexTup, 0.0 .1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:52:47 --> $DIR/offset-of-tuple.rs:51:47
| |
LL | { builtin # offset_of(ComplexTup, 0.0 . 1.) }; LL | { builtin # offset_of(ComplexTup, 0.0 . 1.) };
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:53:46 --> $DIR/offset-of-tuple.rs:52:46
| |
LL | { builtin # offset_of(ComplexTup, 0.0. 1.) }; LL | { builtin # offset_of(ComplexTup, 0.0. 1.) };
| ^ | ^
error: suffixes on a tuple index are invalid error: suffixes on a tuple index are invalid
--> $DIR/offset-of-tuple.rs:10:26 --> $DIR/offset-of-tuple.rs:9:26
| |
LL | offset_of!((u8, u8), 1_u8); LL | offset_of!((u8, u8), 1_u8);
| ^^^^ invalid suffix `u8` | ^^^^ invalid suffix `u8`
error: no rules expected the token `+` error: no rules expected the token `+`
--> $DIR/offset-of-tuple.rs:12:26 --> $DIR/offset-of-tuple.rs:11:26
| |
LL | offset_of!((u8, u8), +1); LL | offset_of!((u8, u8), +1);
| ^ no rules expected this token in macro call | ^ no rules expected this token in macro call
@ -86,115 +86,115 @@ note: while trying to match meta-variable `$fields:expr`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
error: offset_of expects dot-separated field and variant names error: offset_of expects dot-separated field and variant names
--> $DIR/offset-of-tuple.rs:13:26 --> $DIR/offset-of-tuple.rs:12:26
| |
LL | offset_of!((u8, u8), -1); LL | offset_of!((u8, u8), -1);
| ^^ | ^^
error: offset_of expects dot-separated field and variant names error: offset_of expects dot-separated field and variant names
--> $DIR/offset-of-tuple.rs:14:27 --> $DIR/offset-of-tuple.rs:13:27
| |
LL | offset_of!((u8, u8), 1.); LL | offset_of!((u8, u8), 1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:15:29 --> $DIR/offset-of-tuple.rs:14:29
| |
LL | offset_of!((u8, u8), 1 .); LL | offset_of!((u8, u8), 1 .);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:36:34 --> $DIR/offset-of-tuple.rs:35:34
| |
LL | offset_of!(ComplexTup, 0.0.1.); LL | offset_of!(ComplexTup, 0.0.1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:37:35 --> $DIR/offset-of-tuple.rs:36:35
| |
LL | offset_of!(ComplexTup, 0 .0.1.); LL | offset_of!(ComplexTup, 0 .0.1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:38:36 --> $DIR/offset-of-tuple.rs:37:36
| |
LL | offset_of!(ComplexTup, 0 . 0.1.); LL | offset_of!(ComplexTup, 0 . 0.1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:39:35 --> $DIR/offset-of-tuple.rs:38:35
| |
LL | offset_of!(ComplexTup, 0. 0.1.); LL | offset_of!(ComplexTup, 0. 0.1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:40:35 --> $DIR/offset-of-tuple.rs:39:35
| |
LL | offset_of!(ComplexTup, 0.0 .1.); LL | offset_of!(ComplexTup, 0.0 .1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:41:36 --> $DIR/offset-of-tuple.rs:40:36
| |
LL | offset_of!(ComplexTup, 0.0 . 1.); LL | offset_of!(ComplexTup, 0.0 . 1.);
| ^ | ^
error: unexpected token: `)` error: unexpected token: `)`
--> $DIR/offset-of-tuple.rs:42:35 --> $DIR/offset-of-tuple.rs:41:35
| |
LL | offset_of!(ComplexTup, 0.0. 1.); LL | offset_of!(ComplexTup, 0.0. 1.);
| ^ | ^
error[E0609]: no field `_0` on type `(u8, u8)` error[E0609]: no field `_0` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:7:26 --> $DIR/offset-of-tuple.rs:6:26
| |
LL | offset_of!((u8, u8), _0); LL | offset_of!((u8, u8), _0);
| ^^ | ^^
error[E0609]: no field `01` on type `(u8, u8)` error[E0609]: no field `01` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:8:26 --> $DIR/offset-of-tuple.rs:7:26
| |
LL | offset_of!((u8, u8), 01); LL | offset_of!((u8, u8), 01);
| ^^ | ^^
error[E0609]: no field `1e2` on type `(u8, u8)` error[E0609]: no field `1e2` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:9:26 --> $DIR/offset-of-tuple.rs:8:26
| |
LL | offset_of!((u8, u8), 1e2); LL | offset_of!((u8, u8), 1e2);
| ^^^ | ^^^
error[E0609]: no field `1_` on type `(u8, u8)` error[E0609]: no field `1_` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:10:26 --> $DIR/offset-of-tuple.rs:9:26
| |
LL | offset_of!((u8, u8), 1_u8); LL | offset_of!((u8, u8), 1_u8);
| ^^^^ | ^^^^
error[E0609]: no field `1e2` on type `(u8, u8)` error[E0609]: no field `1e2` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:16:35 --> $DIR/offset-of-tuple.rs:15:35
| |
LL | builtin # offset_of((u8, u8), 1e2); LL | builtin # offset_of((u8, u8), 1e2);
| ^^^ | ^^^
error[E0609]: no field `_0` on type `(u8, u8)` error[E0609]: no field `_0` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:17:35 --> $DIR/offset-of-tuple.rs:16:35
| |
LL | builtin # offset_of((u8, u8), _0); LL | builtin # offset_of((u8, u8), _0);
| ^^ | ^^
error[E0609]: no field `01` on type `(u8, u8)` error[E0609]: no field `01` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:18:35 --> $DIR/offset-of-tuple.rs:17:35
| |
LL | builtin # offset_of((u8, u8), 01); LL | builtin # offset_of((u8, u8), 01);
| ^^ | ^^
error[E0609]: no field `1_` on type `(u8, u8)` error[E0609]: no field `1_` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:19:35 --> $DIR/offset-of-tuple.rs:18:35
| |
LL | builtin # offset_of((u8, u8), 1_u8); LL | builtin # offset_of((u8, u8), 1_u8);
| ^^^^ | ^^^^
error[E0609]: no field `2` on type `(u8, u16)` error[E0609]: no field `2` on type `(u8, u16)`
--> $DIR/offset-of-tuple.rs:31:47 --> $DIR/offset-of-tuple.rs:30:47
| |
LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2); LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2);
| _____------------------------------------------^- | _____------------------------------------------^-
@ -207,7 +207,7 @@ LL | | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0);
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0609]: no field `0` on type `u8` error[E0609]: no field `0` on type `u8`
--> $DIR/offset-of-tuple.rs:33:49 --> $DIR/offset-of-tuple.rs:32:49
| |
LL | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0); LL | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0);
| ^ | ^

View File

@ -1,7 +1,7 @@
//@ check-pass //@ check-pass
//@ aux-build:offset-of-staged-api.rs //@ aux-build:offset-of-staged-api.rs
#![feature(offset_of_nested, unstable_test_feature)] #![feature(unstable_test_feature)]
use std::mem::offset_of; use std::mem::offset_of;

View File

@ -1,7 +1,5 @@
//@ aux-build:offset-of-staged-api.rs //@ aux-build:offset-of-staged-api.rs
#![feature(offset_of_nested)]
use std::mem::offset_of; use std::mem::offset_of;
extern crate offset_of_staged_api; extern crate offset_of_staged_api;

View File

@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:14:9 --> $DIR/offset-of-unstable.rs:12:9
| |
LL | Unstable, LL | Unstable,
| ^^^^^^^^ | ^^^^^^^^
@ -8,7 +8,7 @@ LL | Unstable,
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:23:9 --> $DIR/offset-of-unstable.rs:21:9
| |
LL | UnstableWithStableFieldType, LL | UnstableWithStableFieldType,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL | UnstableWithStableFieldType,
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:28:9 --> $DIR/offset-of-unstable.rs:26:9
| |
LL | UnstableWithStableFieldType, LL | UnstableWithStableFieldType,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -26,7 +26,7 @@ LL | UnstableWithStableFieldType,
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:12:5 --> $DIR/offset-of-unstable.rs:10:5
| |
LL | / offset_of!( LL | / offset_of!(
LL | | LL | |
@ -40,7 +40,7 @@ LL | | );
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:18:5 --> $DIR/offset-of-unstable.rs:16:5
| |
LL | offset_of!(StableWithUnstableField, unstable); LL | offset_of!(StableWithUnstableField, unstable);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,7 +50,7 @@ LL | offset_of!(StableWithUnstableField, unstable);
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:20:5 --> $DIR/offset-of-unstable.rs:18:5
| |
LL | offset_of!(StableWithUnstableFieldType, stable.unstable); LL | offset_of!(StableWithUnstableFieldType, stable.unstable);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -60,7 +60,7 @@ LL | offset_of!(StableWithUnstableFieldType, stable.unstable);
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:21:5 --> $DIR/offset-of-unstable.rs:19:5
| |
LL | / offset_of!( LL | / offset_of!(
LL | | LL | |
@ -74,7 +74,7 @@ LL | | );
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: use of unstable library feature 'unstable_test_feature' error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/offset-of-unstable.rs:26:5 --> $DIR/offset-of-unstable.rs:24:5
| |
LL | / offset_of!( LL | / offset_of!(
LL | | LL | |