File tree Expand file tree Collapse file tree 10 files changed +16
-16
lines changed
compiler/rustc_mir/src/transform/check_consts Expand file tree Collapse file tree 10 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -242,8 +242,8 @@ impl NonConstOp for CellBorrow {
242
242
ccx. tcx. sess,
243
243
span,
244
244
E0492 ,
245
- "cannot borrow a constant which may contain \
246
- interior mutability, create a static instead"
245
+ "this borrow to an interior mutable value may end up in the final value of this {}" ,
246
+ ccx . const_kind ( ) ,
247
247
)
248
248
}
249
249
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use std::cell::Cell;
3
3
const FOO : & ( Cell < usize > , bool ) = {
4
4
let mut a = ( Cell :: new ( 0 ) , false ) ;
5
5
a. 1 = true ; // sets `qualif(a)` to `qualif(a) | qualif(true)`
6
- & { a} //~ ERROR cannot borrow a constant which may contain interior mutability
6
+ & { a} //~ ERROR borrow to an interior mutable value may end up in the final value
7
7
} ;
8
8
9
9
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
1
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
2
2
--> $DIR/partial_qualif.rs:6:5
3
3
|
4
4
LL | &{a}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use std::cell::Cell;
7
7
const FOO : & Option < Cell < usize > > = {
8
8
let mut a = Some ( Cell :: new ( 0 ) ) ;
9
9
a = None ; // sets `qualif(a)` to `qualif(a) | qualif(None)`
10
- & { a} //~ ERROR cannot borrow a constant which may contain interior mutability
10
+ & { a} //~ ERROR borrow to an interior mutable value may end up in the final value
11
11
} ;
12
12
13
13
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
1
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
2
2
--> $DIR/qualif_overwrite.rs:10:5
3
3
|
4
4
LL | &{a}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use std::cell::Cell;
5
5
const FOO : & Option < Cell < usize > > = {
6
6
let mut a = ( Some ( Cell :: new ( 0 ) ) , ) ;
7
7
a. 0 = None ; // sets `qualif(a)` to `qualif(a) | qualif(None)`
8
- & { a. 0 } //~ ERROR cannot borrow a constant which may contain interior mutability
8
+ & { a. 0 } //~ ERROR borrow to an interior mutable value may end up in the final value
9
9
} ;
10
10
11
11
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
1
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
2
2
--> $DIR/qualif_overwrite_2.rs:8:5
3
3
|
4
4
LL | &{a.0}
Original file line number Diff line number Diff line change 1
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
1
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
2
2
--> $DIR/E0492.rs:4:33
3
3
|
4
4
LL | const B: &'static AtomicUsize = &A;
5
5
| ^^
6
6
7
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
7
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this static
8
8
--> $DIR/E0492.rs:5:34
9
9
|
10
10
LL | static C: &'static AtomicUsize = &A;
Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ use std::cell::UnsafeCell;
2
2
3
3
const A : UnsafeCell < usize > = UnsafeCell :: new ( 1 ) ;
4
4
const B : & ' static UnsafeCell < usize > = & A ;
5
- //~^ ERROR: may contain interior mutability
5
+ //~^ ERROR: borrow to an interior mutable value
6
6
7
7
struct C { a : UnsafeCell < usize > }
8
8
const D : C = C { a : UnsafeCell :: new ( 1 ) } ;
9
9
const E : & ' static UnsafeCell < usize > = & D . a ;
10
- //~^ ERROR: may contain interior mutability
10
+ //~^ ERROR: borrow to an interior mutable value
11
11
const F : & ' static C = & D ;
12
- //~^ ERROR: may contain interior mutability
12
+ //~^ ERROR: borrow to an interior mutable value
13
13
14
14
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
1
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
2
2
--> $DIR/issue-17718-const-borrow.rs:4:39
3
3
|
4
4
LL | const B: &'static UnsafeCell<usize> = &A;
5
5
| ^^
6
6
7
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
7
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
8
8
--> $DIR/issue-17718-const-borrow.rs:9:39
9
9
|
10
10
LL | const E: &'static UnsafeCell<usize> = &D.a;
11
11
| ^^^^
12
12
13
- error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
13
+ error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
14
14
--> $DIR/issue-17718-const-borrow.rs:11:23
15
15
|
16
16
LL | const F: &'static C = &D;
You can’t perform that action at this time.
0 commit comments