Update now-more-precise operation with a preciser message
This commit is contained in:
parent
e5330a4f52
commit
a137ff1706
@ -242,8 +242,8 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
E0492,
|
||||
"cannot borrow a constant which may contain \
|
||||
interior mutability, create a static instead"
|
||||
"this borrow to an interior mutable value may end up in the final value of this {}",
|
||||
ccx.const_kind(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
const FOO: &(Cell<usize>, bool) = {
|
||||
let mut a = (Cell::new(0), false);
|
||||
a.1 = true; // sets `qualif(a)` to `qualif(a) | qualif(true)`
|
||||
&{a} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
&{a} //~ ERROR borrow to an interior mutable value may end up in the final value
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/partial_qualif.rs:6:5
|
||||
|
|
||||
LL | &{a}
|
||||
|
@ -7,7 +7,7 @@
|
||||
const FOO: &Option<Cell<usize>> = {
|
||||
let mut a = Some(Cell::new(0));
|
||||
a = None; // sets `qualif(a)` to `qualif(a) | qualif(None)`
|
||||
&{a}//~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
&{a} //~ ERROR borrow to an interior mutable value may end up in the final value
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/qualif_overwrite.rs:10:5
|
||||
|
|
||||
LL | &{a}
|
||||
|
@ -5,7 +5,7 @@
|
||||
const FOO: &Option<Cell<usize>> = {
|
||||
let mut a = (Some(Cell::new(0)),);
|
||||
a.0 = None; // sets `qualif(a)` to `qualif(a) | qualif(None)`
|
||||
&{a.0} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
&{a.0} //~ ERROR borrow to an interior mutable value may end up in the final value
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/qualif_overwrite_2.rs:8:5
|
||||
|
|
||||
LL | &{a.0}
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/E0492.rs:4:33
|
||||
|
|
||||
LL | const B: &'static AtomicUsize = &A;
|
||||
| ^^
|
||||
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this static
|
||||
--> $DIR/E0492.rs:5:34
|
||||
|
|
||||
LL | static C: &'static AtomicUsize = &A;
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
const A: UnsafeCell<usize> = UnsafeCell::new(1);
|
||||
const B: &'static UnsafeCell<usize> = &A;
|
||||
//~^ ERROR: may contain interior mutability
|
||||
//~^ ERROR: borrow to an interior mutable value
|
||||
|
||||
struct C { a: UnsafeCell<usize> }
|
||||
const D: C = C { a: UnsafeCell::new(1) };
|
||||
const E: &'static UnsafeCell<usize> = &D.a;
|
||||
//~^ ERROR: may contain interior mutability
|
||||
//~^ ERROR: borrow to an interior mutable value
|
||||
const F: &'static C = &D;
|
||||
//~^ ERROR: may contain interior mutability
|
||||
//~^ ERROR: borrow to an interior mutable value
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,16 +1,16 @@
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/issue-17718-const-borrow.rs:4:39
|
||||
|
|
||||
LL | const B: &'static UnsafeCell<usize> = &A;
|
||||
| ^^
|
||||
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/issue-17718-const-borrow.rs:9:39
|
||||
|
|
||||
LL | const E: &'static UnsafeCell<usize> = &D.a;
|
||||
| ^^^^
|
||||
|
||||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
error[E0492]: this borrow to an interior mutable value may end up in the final value of this constant
|
||||
--> $DIR/issue-17718-const-borrow.rs:11:23
|
||||
|
|
||||
LL | const F: &'static C = &D;
|
||||
|
Loading…
Reference in New Issue
Block a user