Skip to content

Commit 79503dd

Browse files
committed
stabilize raw_ref_op
1 parent f04f6ca commit 79503dd

File tree

63 files changed

+106
-246
lines changed

Some content is hidden

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

63 files changed

+106
-246
lines changed

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
539539
}
540540
}
541541
gate_all!(gen_blocks, "gen blocks are experimental");
542-
gate_all!(raw_ref_op, "raw address of syntax is experimental");
543542
gate_all!(const_trait_impl, "const trait impls are experimental");
544543
gate_all!(
545544
half_open_range_patterns_in_slices,

Diff for: 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)]

Diff for: 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)]

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

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

+2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ declare_features! (
321321
(accepted, raw_dylib, "1.71.0", Some(58713)),
322322
/// Allows keywords to be escaped for use as identifiers.
323323
(accepted, raw_identifiers, "1.30.0", Some(48589)),
324+
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
325+
(accepted, raw_ref_op, "CURRENT_RUSTC_VERSION", Some(64490)),
324326
/// Allows relaxing the coherence rules such that
325327
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
326328
(accepted, re_rebalance_coherence, "1.41.0", Some(55437)),

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

-2
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,6 @@ declare_features! (
565565
(unstable, precise_capturing, "1.79.0", Some(123432)),
566566
/// Allows macro attributes on expressions, statements and non-inline modules.
567567
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
568-
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
569-
(unstable, raw_ref_op, "1.41.0", Some(64490)),
570568
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024.
571569
(incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)),
572570
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant

Diff for: compiler/rustc_parse/src/parser/expr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ impl<'a> Parser<'a> {
851851
self.expect_and()?;
852852
let has_lifetime = self.token.is_lifetime() && self.look_ahead(1, |t| t != &token::Colon);
853853
let lifetime = has_lifetime.then(|| self.expect_lifetime()); // For recovery, see below.
854-
let (borrow_kind, mutbl) = self.parse_borrow_modifiers(lo);
854+
let (borrow_kind, mutbl) = self.parse_borrow_modifiers();
855855
let attrs = self.parse_outer_attributes()?;
856856
let expr = if self.token.is_range_separator() {
857857
self.parse_expr_prefix_range(attrs)
@@ -871,13 +871,12 @@ impl<'a> Parser<'a> {
871871
}
872872

873873
/// Parse `mut?` or `raw [ const | mut ]`.
874-
fn parse_borrow_modifiers(&mut self, lo: Span) -> (ast::BorrowKind, ast::Mutability) {
874+
fn parse_borrow_modifiers(&mut self) -> (ast::BorrowKind, ast::Mutability) {
875875
if self.check_keyword(kw::Raw) && self.look_ahead(1, Token::is_mutability) {
876876
// `raw [ const | mut ]`.
877877
let found_raw = self.eat_keyword(kw::Raw);
878878
assert!(found_raw);
879879
let mutability = self.parse_const_or_mut().unwrap();
880-
self.psess.gated_spans.gate(sym::raw_ref_op, lo.to(self.prev_token.span));
881880
(ast::BorrowKind::Raw, mutability)
882881
} else {
883882
// `mut?`

Diff for: src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(raw_ref_op)]
21
#![feature(strict_provenance)]
32
use std::ptr;
43

Diff for: src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.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

Diff for: src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This does need an aliasing model and protectors.
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

Diff for: src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This does need an aliasing model and protectors.
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
#![feature(explicit_tail_calls)]

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

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

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

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

Diff for: tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
let mut _3: fn(u8) -> u8;
99
let _5: ();
1010
let mut _6: fn(u8) -> u8;
11-
let mut _9: {closure@$DIR/gvn.rs:615:19: 615:21};
11+
let mut _9: {closure@$DIR/gvn.rs:614:19: 614:21};
1212
let _10: ();
1313
let mut _11: fn();
14-
let mut _13: {closure@$DIR/gvn.rs:615:19: 615:21};
14+
let mut _13: {closure@$DIR/gvn.rs:614:19: 614:21};
1515
let _14: ();
1616
let mut _15: fn();
1717
scope 1 {
1818
debug f => _1;
1919
let _4: fn(u8) -> u8;
2020
scope 2 {
2121
debug g => _4;
22-
let _7: {closure@$DIR/gvn.rs:615:19: 615:21};
22+
let _7: {closure@$DIR/gvn.rs:614:19: 614:21};
2323
scope 3 {
2424
debug closure => _7;
2525
let _8: fn();
@@ -62,16 +62,16 @@
6262
StorageDead(_6);
6363
StorageDead(_5);
6464
- StorageLive(_7);
65-
- _7 = {closure@$DIR/gvn.rs:615:19: 615:21};
65+
- _7 = {closure@$DIR/gvn.rs:614:19: 614:21};
6666
- StorageLive(_8);
6767
+ nop;
68-
+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
68+
+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
6969
+ nop;
7070
StorageLive(_9);
7171
- _9 = _7;
7272
- _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe)));
73-
+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
74-
+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
73+
+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
74+
+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
7575
StorageDead(_9);
7676
StorageLive(_10);
7777
StorageLive(_11);
@@ -88,8 +88,8 @@
8888
StorageLive(_13);
8989
- _13 = _7;
9090
- _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe)));
91-
+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
92-
+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
91+
+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
92+
+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
9393
StorageDead(_13);
9494
StorageLive(_14);
9595
StorageLive(_15);

Diff for: tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
let mut _3: fn(u8) -> u8;
99
let _5: ();
1010
let mut _6: fn(u8) -> u8;
11-
let mut _9: {closure@$DIR/gvn.rs:615:19: 615:21};
11+
let mut _9: {closure@$DIR/gvn.rs:614:19: 614:21};
1212
let _10: ();
1313
let mut _11: fn();
14-
let mut _13: {closure@$DIR/gvn.rs:615:19: 615:21};
14+
let mut _13: {closure@$DIR/gvn.rs:614:19: 614:21};
1515
let _14: ();
1616
let mut _15: fn();
1717
scope 1 {
1818
debug f => _1;
1919
let _4: fn(u8) -> u8;
2020
scope 2 {
2121
debug g => _4;
22-
let _7: {closure@$DIR/gvn.rs:615:19: 615:21};
22+
let _7: {closure@$DIR/gvn.rs:614:19: 614:21};
2323
scope 3 {
2424
debug closure => _7;
2525
let _8: fn();
@@ -62,16 +62,16 @@
6262
StorageDead(_6);
6363
StorageDead(_5);
6464
- StorageLive(_7);
65-
- _7 = {closure@$DIR/gvn.rs:615:19: 615:21};
65+
- _7 = {closure@$DIR/gvn.rs:614:19: 614:21};
6666
- StorageLive(_8);
6767
+ nop;
68-
+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
68+
+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
6969
+ nop;
7070
StorageLive(_9);
7171
- _9 = _7;
7272
- _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe)));
73-
+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
74-
+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
73+
+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
74+
+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
7575
StorageDead(_9);
7676
StorageLive(_10);
7777
StorageLive(_11);
@@ -88,8 +88,8 @@
8888
StorageLive(_13);
8989
- _13 = _7;
9090
- _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe)));
91-
+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21};
92-
+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:615:19: 615:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
91+
+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21};
92+
+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe)));
9393
StorageDead(_13);
9494
StorageLive(_14);
9595
StorageLive(_15);

Diff for: 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)]

Diff for: 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-after-simplifycfg
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.

Diff for: 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)]

Diff for: 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; };

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)