Skip to content

Commit ce0fa4b

Browse files
committed
stabilize raw_ref_op
1 parent 44fb857 commit ce0fa4b

File tree

49 files changed

+28
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+28
-154
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
524524
}
525525
}
526526
gate_all!(gen_blocks, "gen blocks are experimental");
527-
gate_all!(raw_ref_op, "raw address of syntax is experimental");
528527
gate_all!(const_trait_impl, "const trait impls are experimental");
529528
gate_all!(
530529
half_open_range_patterns_in_slices,

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
extern_types,
77
naked_functions,
88
thread_local,
9-
repr_simd,
10-
raw_ref_op
9+
repr_simd
1110
)]
1211
#![no_core]
1312
#![allow(dead_code, non_camel_case_types, internal_features)]

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

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

33
#![feature(
44
no_core, unboxed_closures, start, lang_items, never_type, linkage,
5-
extern_types, thread_local, raw_ref_op
5+
extern_types, thread_local
66
)]
77
#![no_core]
88
#![allow(dead_code, internal_features, non_camel_case_types)]

compiler/rustc_error_codes/src/error_codes/E0745.md

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ The address of temporary value was taken.
33
Erroneous code example:
44

55
```compile_fail,E0745
6-
# #![feature(raw_ref_op)]
76
fn temp_address() {
87
let ptr = &raw const 2; // error!
98
}
@@ -15,7 +14,6 @@ In this example, `2` is destroyed right after the assignment, which means that
1514
To avoid this error, first bind the temporary to a named local variable:
1615

1716
```
18-
# #![feature(raw_ref_op)]
1917
fn temp_address() {
2018
let val = 2;
2119
let ptr = &raw const val; // ok!

compiler/rustc_feature/src/accepted.rs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ declare_features! (
4242
// feature-group-start: accepted features
4343
// -------------------------------------------------------------------------
4444

45+
// Note that the version indicates when it got *stabilized*.
46+
// When moving an unstable feature here, set the version number to
47+
// `CURRENT-RUSTC-VERSION` with `-` replaced by `_`.
48+
4549
/// Allows `#[target_feature(...)]` on aarch64 platforms
4650
(accepted, aarch64_target_feature, "1.61.0", Some(44839)),
4751
/// Allows using the `efiapi` ABI.
@@ -310,6 +314,8 @@ declare_features! (
310314
(accepted, raw_dylib, "1.71.0", Some(58713)),
311315
/// Allows keywords to be escaped for use as identifiers.
312316
(accepted, raw_identifiers, "1.30.0", Some(48589)),
317+
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
318+
(accepted, raw_ref_op, "CURRENT_RUSTC_VERSION", Some(64490)),
313319
/// Allows relaxing the coherence rules such that
314320
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
315321
(accepted, re_rebalance_coherence, "1.41.0", Some(55437)),

compiler/rustc_feature/src/removed.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ declare_features! (
3232
// feature-group-start: removed features
3333
// -------------------------------------------------------------------------
3434

35+
// Note that the version indicates when it got *removed*.
36+
// When moving an unstable feature here, set the version number to
37+
// `CURRENT-RUSTC-VERSION` with `-` replaced by `_`.
38+
3539
/// Allows using the `amdgpu-kernel` ABI.
3640
(removed, abi_amdgpu_kernel, "1.77.0", Some(51575), None),
3741
(removed, advanced_slice_patterns, "1.0.0", Some(62254),

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,6 @@ declare_features! (
571571
(unstable, precise_capturing, "1.79.0", Some(123432)),
572572
/// Allows macro attributes on expressions, statements and non-inline modules.
573573
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
574-
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
575-
(unstable, raw_ref_op, "1.41.0", Some(64490)),
576574
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024.
577575
(incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)),
578576
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant

compiler/rustc_parse/src/parser/expr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ impl<'a> Parser<'a> {
846846
self.expect_and()?;
847847
let has_lifetime = self.token.is_lifetime() && self.look_ahead(1, |t| t != &token::Colon);
848848
let lifetime = has_lifetime.then(|| self.expect_lifetime()); // For recovery, see below.
849-
let (borrow_kind, mutbl) = self.parse_borrow_modifiers(lo);
849+
let (borrow_kind, mutbl) = self.parse_borrow_modifiers();
850850
let attrs = self.parse_outer_attributes()?;
851851
let expr = if self.token.is_range_separator() {
852852
self.parse_expr_prefix_range(attrs)
@@ -866,13 +866,12 @@ impl<'a> Parser<'a> {
866866
}
867867

868868
/// Parse `mut?` or `raw [ const | mut ]`.
869-
fn parse_borrow_modifiers(&mut self, lo: Span) -> (ast::BorrowKind, ast::Mutability) {
869+
fn parse_borrow_modifiers(&mut self) -> (ast::BorrowKind, ast::Mutability) {
870870
if self.check_keyword(kw::Raw) && self.look_ahead(1, Token::is_mutability) {
871871
// `raw [ const | mut ]`.
872872
let found_raw = self.eat_keyword(kw::Raw);
873873
assert!(found_raw);
874874
let mutability = self.parse_const_or_mut().unwrap();
875-
self.psess.gated_spans.gate(sym::raw_ref_op, lo.to(self.prev_token.span));
876875
(ast::BorrowKind::Raw, mutability)
877876
} else {
878877
// `mut?`

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@revisions: stack tree none
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
//@[none]compile-flags: -Zmiri-disable-stacked-borrows
4-
#![feature(raw_ref_op)]
54
#![feature(core_intrinsics)]
65
#![feature(custom_mir)]
76

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This does need an aliasing model.
22
//@revisions: stack tree
33
//@[tree]compile-flags: -Zmiri-tree-borrows
4-
#![feature(raw_ref_op)]
54
#![feature(core_intrinsics)]
65
#![feature(custom_mir)]
76

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Doesn't need an aliasing model.
22
//@compile-flags: -Zmiri-disable-stacked-borrows
3-
#![feature(raw_ref_op)]
43
#![feature(core_intrinsics)]
54
#![feature(custom_mir)]
65

src/tools/miri/tests/pass/function_calls/return_place_on_heap.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(raw_ref_op)]
21
#![feature(core_intrinsics)]
32
#![feature(custom_mir)]
43

tests/mir-opt/const_prop/indirect_mutation.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ test-mir-pass: GVN
22
// Check that we do not propagate past an indirect mutation.
3-
#![feature(raw_ref_op)]
43

54
// EMIT_MIR indirect_mutation.foo.GVN.diff
65
fn foo() {

tests/mir-opt/copy-prop/reborrow.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Check that CopyProp considers reborrows as not mutating the pointer.
44
//@ test-mir-pass: CopyProp
55

6-
#![feature(raw_ref_op)]
7-
86
#[inline(never)]
97
fn opaque(_: impl Sized) {}
108

tests/mir-opt/gvn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44
//@ only-64bit
55

6-
#![feature(raw_ref_op)]
76
#![feature(rustc_attrs)]
87
#![feature(custom_mir)]
98
#![feature(core_intrinsics)]

tests/mir-opt/instsimplify/ref_of_deref.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ test-mir-pass: InstSimplify
22
#![crate_type = "lib"]
3-
#![feature(raw_ref_op)]
43

54
// For each of these, only 2 of the 6 should simplify,
65
// as the others have the wrong types.

tests/mir-opt/reference_prop.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ test-mir-pass: ReferencePropagation
33
//@ needs-unwind
44

5-
#![feature(raw_ref_op)]
65
#![feature(core_intrinsics, custom_mir)]
76

87
#[inline(never)]

tests/pretty/raw-address-of.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ pp-exact
2-
#![feature(raw_ref_op)]
32

43
const C_PTR: () = { let a = 1; &raw const a; };
54
static S_PTR: () = { let b = false; &raw const b; };

tests/ui/borrowck/borrow-raw-address-of-borrowed.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(raw_ref_op)]
2-
31
fn address_of_shared() {
42
let mut x = 0;
53
let y = &x;

tests/ui/borrowck/borrow-raw-address-of-borrowed.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
2-
--> $DIR/borrow-raw-address-of-borrowed.rs:7:13
2+
--> $DIR/borrow-raw-address-of-borrowed.rs:5:13
33
|
44
LL | let y = &x;
55
| -- immutable borrow occurs here
@@ -11,7 +11,7 @@ LL | drop(y);
1111
| - immutable borrow later used here
1212

1313
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
14-
--> $DIR/borrow-raw-address-of-borrowed.rs:16:13
14+
--> $DIR/borrow-raw-address-of-borrowed.rs:14:13
1515
|
1616
LL | let y = &mut x;
1717
| ------ mutable borrow occurs here
@@ -23,7 +23,7 @@ LL | drop(y);
2323
| - mutable borrow later used here
2424

2525
error[E0499]: cannot borrow `x` as mutable more than once at a time
26-
--> $DIR/borrow-raw-address-of-borrowed.rs:17:13
26+
--> $DIR/borrow-raw-address-of-borrowed.rs:15:13
2727
|
2828
LL | let y = &mut x;
2929
| ------ first mutable borrow occurs here

tests/ui/borrowck/borrow-raw-address-of-deref-mutability-ok.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(raw_ref_op)]
4-
53
fn raw_reborrow() {
64
let x = &0;
75
let y = &mut 0;

tests/ui/borrowck/borrow-raw-address-of-deref-mutability.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Check that `&raw mut` cannot be used to turn a `&T` into a `*mut T`.
22

3-
#![feature(raw_ref_op)]
4-
53
fn raw_reborrow() {
64
let x = &0;
75

tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
2-
--> $DIR/borrow-raw-address-of-deref-mutability.rs:8:13
2+
--> $DIR/borrow-raw-address-of-deref-mutability.rs:6:13
33
|
44
LL | let q = &raw mut *x;
55
| ^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
@@ -10,7 +10,7 @@ LL | let x = &mut 0;
1010
| +++
1111

1212
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
13-
--> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13
13+
--> $DIR/borrow-raw-address-of-deref-mutability.rs:12:13
1414
|
1515
LL | let q = &raw mut *x;
1616
| ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable

tests/ui/borrowck/borrow-raw-address-of-mutability-ok.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(raw_ref_op)]
4-
53
fn mutable_address_of() {
64
let mut x = 0;
75
let y = &raw mut x;

tests/ui/borrowck/borrow-raw-address-of-mutability.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(raw_ref_op)]
2-
31
fn mutable_address_of() {
42
let x = 0;
53
let y = &raw mut x; //~ ERROR cannot borrow

tests/ui/borrowck/borrow-raw-address-of-mutability.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2-
--> $DIR/borrow-raw-address-of-mutability.rs:5:13
2+
--> $DIR/borrow-raw-address-of-mutability.rs:3:13
33
|
44
LL | let y = &raw mut x;
55
| ^^^^^^^^^^ cannot borrow as mutable
@@ -10,7 +10,7 @@ LL | let mut x = 0;
1010
| +++
1111

1212
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
13-
--> $DIR/borrow-raw-address-of-mutability.rs:11:17
13+
--> $DIR/borrow-raw-address-of-mutability.rs:9:17
1414
|
1515
LL | let y = &raw mut x;
1616
| ^^^^^^^^^^ cannot borrow as mutable
@@ -21,7 +21,7 @@ LL | let mut x = 0;
2121
| +++
2222

2323
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
24-
--> $DIR/borrow-raw-address-of-mutability.rs:21:5
24+
--> $DIR/borrow-raw-address-of-mutability.rs:19:5
2525
|
2626
LL | let y = &raw mut x;
2727
| - calling `f` requires mutable binding due to mutable borrow of `x`
@@ -35,7 +35,7 @@ LL | let mut f = || {
3535
| +++
3636

3737
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
38-
--> $DIR/borrow-raw-address-of-mutability.rs:29:17
38+
--> $DIR/borrow-raw-address-of-mutability.rs:27:17
3939
|
4040
LL | fn make_fn<F: Fn()>(f: F) -> F { f }
4141
| - change this to accept `FnMut` instead of `Fn`
@@ -48,7 +48,7 @@ LL | let y = &raw mut x;
4848
| ^^^^^^^^^^ cannot borrow as mutable
4949

5050
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
51-
--> $DIR/borrow-raw-address-of-mutability.rs:37:17
51+
--> $DIR/borrow-raw-address-of-mutability.rs:35:17
5252
|
5353
LL | fn make_fn<F: Fn()>(f: F) -> F { f }
5454
| - change this to accept `FnMut` instead of `Fn`

tests/ui/consts/const-address-of-interior-mut.rs

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

53
const A: () = { let x = Cell::new(2); &raw const x; }; //~ ERROR interior mutability

tests/ui/consts/const-address-of-mut.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(raw_ref_op)]
2-
31
const A: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer
42

53
static B: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer

tests/ui/consts/const-address-of.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(raw_ref_op)]
4-
53
const A: *const i32 = &raw const *&2;
64
static B: () = { &raw const *&2; };
75
static mut C: *const i32 = &raw const *&2;

tests/ui/consts/const-mut-refs/const_mut_address_of.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ check-pass
22
#![feature(const_mut_refs)]
3-
#![feature(raw_ref_op)]
43

54
struct Foo {
65
x: usize

tests/ui/consts/const-mut-refs/mut_ref_in_final.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(const_mut_refs)]
2-
#![feature(raw_ref_op)]
32

43
const NULL: *mut i32 = std::ptr::null_mut();
54
const A: *const i32 = &4;

tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ normalize-stderr-test: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP"
33
//@ normalize-stderr-test: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
44
#![feature(const_mut_refs, const_refs_to_static)]
5-
#![feature(raw_ref_op)]
65

76
use std::sync::Mutex;
87

tests/ui/consts/min_const_fn/address_of.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(raw_ref_op)]
2-
31
const fn mutable_address_of_in_const() {
42
let mut a = 0;
53
let b = &raw mut a; //~ ERROR mutable pointer

tests/ui/consts/min_const_fn/address_of_const.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(raw_ref_op)]
4-
53
const fn const_address_of_in_const() {
64
let mut a = 0;
75
let b = &raw const a;

tests/ui/consts/qualif-indirect-mutation-fail.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(const_mut_refs)]
33
#![feature(const_precise_live_drops)]
44
#![feature(const_swap)]
5-
#![feature(raw_ref_op)]
65

76
// Mutable borrow of a field with drop impl.
87
pub const fn f() {

tests/ui/lint/unused/lint-unused-mut-variables.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Exercise the unused_mut attribute in some positive and negative cases
44

55
#![warn(unused_mut)]
6-
#![feature(async_closure, raw_ref_op)]
6+
#![feature(async_closure)]
77

88
async fn baz_async(
99
mut a: i32,

tests/ui/macros/stringify.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(let_chains)]
1515
#![feature(more_qualified_paths)]
1616
#![feature(never_patterns)]
17-
#![feature(raw_ref_op)]
1817
#![feature(trait_alias)]
1918
#![feature(try_blocks)]
2019
#![feature(type_ascription)]

tests/ui/mir/mir_raw_fat_ptr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// check raw fat pointer ops in mir
33
// FIXME: please improve this when we get monomorphization support
44

5-
#![feature(raw_ref_op)]
65
#![allow(ambiguous_wide_pointer_comparisons)]
76

87
use std::mem;

tests/ui/mir/mir_raw_fat_ptr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: method `foo` is never used
2-
--> $DIR/mir_raw_fat_ptr.rs:101:16
2+
--> $DIR/mir_raw_fat_ptr.rs:100:16
33
|
44
LL | trait Foo { fn foo(&self) -> usize; }
55
| --- ^^^

0 commit comments

Comments
 (0)