Skip to content

Commit a137ff1

Browse files
committed
Update now-more-precise operation with a preciser message
1 parent e5330a4 commit a137ff1

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ impl NonConstOp for CellBorrow {
242242
ccx.tcx.sess,
243243
span,
244244
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(),
247247
)
248248
}
249249
}

src/test/ui/consts/partial_qualif.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::cell::Cell;
33
const FOO: &(Cell<usize>, bool) = {
44
let mut a = (Cell::new(0), false);
55
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
77
};
88

99
fn main() {}

src/test/ui/consts/partial_qualif.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22
--> $DIR/partial_qualif.rs:6:5
33
|
44
LL | &{a}

src/test/ui/consts/qualif_overwrite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::cell::Cell;
77
const FOO: &Option<Cell<usize>> = {
88
let mut a = Some(Cell::new(0));
99
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
1111
};
1212

1313
fn main() {}

src/test/ui/consts/qualif_overwrite.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22
--> $DIR/qualif_overwrite.rs:10:5
33
|
44
LL | &{a}

src/test/ui/consts/qualif_overwrite_2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::cell::Cell;
55
const FOO: &Option<Cell<usize>> = {
66
let mut a = (Some(Cell::new(0)),);
77
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
99
};
1010

1111
fn main() {}

src/test/ui/consts/qualif_overwrite_2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22
--> $DIR/qualif_overwrite_2.rs:8:5
33
|
44
LL | &{a.0}

src/test/ui/error-codes/E0492.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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
22
--> $DIR/E0492.rs:4:33
33
|
44
LL | const B: &'static AtomicUsize = &A;
55
| ^^
66

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
88
--> $DIR/E0492.rs:5:34
99
|
1010
LL | static C: &'static AtomicUsize = &A;

src/test/ui/issues/issue-17718-const-borrow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::cell::UnsafeCell;
22

33
const A: UnsafeCell<usize> = UnsafeCell::new(1);
44
const B: &'static UnsafeCell<usize> = &A;
5-
//~^ ERROR: may contain interior mutability
5+
//~^ ERROR: borrow to an interior mutable value
66

77
struct C { a: UnsafeCell<usize> }
88
const D: C = C { a: UnsafeCell::new(1) };
99
const E: &'static UnsafeCell<usize> = &D.a;
10-
//~^ ERROR: may contain interior mutability
10+
//~^ ERROR: borrow to an interior mutable value
1111
const F: &'static C = &D;
12-
//~^ ERROR: may contain interior mutability
12+
//~^ ERROR: borrow to an interior mutable value
1313

1414
fn main() {}

src/test/ui/issues/issue-17718-const-borrow.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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
22
--> $DIR/issue-17718-const-borrow.rs:4:39
33
|
44
LL | const B: &'static UnsafeCell<usize> = &A;
55
| ^^
66

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
88
--> $DIR/issue-17718-const-borrow.rs:9:39
99
|
1010
LL | const E: &'static UnsafeCell<usize> = &D.a;
1111
| ^^^^
1212

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
1414
--> $DIR/issue-17718-const-borrow.rs:11:23
1515
|
1616
LL | const F: &'static C = &D;

0 commit comments

Comments
 (0)