Skip to content

Commit 6df4070

Browse files
committed
stabilize offset_of_slice
1 parent 81d8c74 commit 6df4070

File tree

6 files changed

+4
-53
lines changed

6 files changed

+4
-53
lines changed

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ declare_features! (
318318
(accepted, non_modrs_mods, "1.30.0", Some(44660)),
319319
/// Allows using multiple nested field accesses in offset_of!
320320
(accepted, offset_of_nested, "1.82.0", Some(120140)),
321+
/// Allows using fields with slice type in offset_of!
322+
(accepted, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
321323
/// Allows the use of or-patterns (e.g., `0 | 1`).
322324
(accepted, or_patterns, "1.53.0", Some(54883)),
323325
/// 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
@@ -589,8 +589,6 @@ declare_features! (
589589
(incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
590590
/// Allows using enums in offset_of!
591591
(unstable, offset_of_enum, "1.75.0", Some(120141)),
592-
/// Allows using fields with slice type in offset_of!
593-
(unstable, offset_of_slice, "1.81.0", Some(126151)),
594592
/// Allows using `#[optimize(X)]`.
595593
(unstable, optimize_attribute, "1.34.0", Some(54882)),
596594
/// Allows specifying nop padding on functions for dynamic patching.

compiler/rustc_hir_typeck/src/expr.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -3946,15 +3946,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
39463946
{
39473947
let field_ty = self.field_ty(expr.span, field, args);
39483948

3949-
if self.tcx.features().offset_of_slice() {
3950-
self.require_type_has_static_alignment(field_ty, expr.span);
3951-
} else {
3952-
self.require_type_is_sized(
3953-
field_ty,
3954-
expr.span,
3955-
ObligationCauseCode::Misc,
3956-
);
3957-
}
3949+
self.require_type_has_static_alignment(field_ty, expr.span);
39583950

39593951
if field.vis.is_accessible_from(def_scope, self.tcx) {
39603952
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
@@ -3975,15 +3967,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
39753967
&& field.name == sym::integer(index)
39763968
{
39773969
if let Some(&field_ty) = tys.get(index) {
3978-
if self.tcx.features().offset_of_slice() {
3979-
self.require_type_has_static_alignment(field_ty, expr.span);
3980-
} else {
3981-
self.require_type_is_sized(
3982-
field_ty,
3983-
expr.span,
3984-
ObligationCauseCode::Misc,
3985-
);
3986-
}
3970+
self.require_type_has_static_alignment(field_ty, expr.span);
39873971

39883972
field_indices.push((FIRST_VARIANT, index.into()));
39893973
current_container = field_ty;

src/doc/unstable-book/src/language-features/offset-of-slice.md

-30
This file was deleted.

tests/ui/offset-of/offset-of-slice-normalized.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//@[next] compile-flags: -Znext-solver
44
//@ run-pass
55

6-
#![feature(offset_of_slice)]
7-
86
use std::mem::offset_of;
97

108
trait Mirror {

tests/ui/offset-of/offset-of-slice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@run-pass
2-
#![feature(offset_of_slice)]
32

43
use std::mem::offset_of;
54

0 commit comments

Comments
 (0)