kill the code path for E0388
This was specific to the old special-case handling of statics in borrowck.
This commit is contained in:
parent
d79ad36cf5
commit
2b5c0267b4
2 changed files with 8 additions and 26 deletions
|
@ -801,11 +801,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
mc::AliasableStatic |
|
mc::AliasableStatic |
|
||||||
mc::AliasableStaticMut => {
|
mc::AliasableStaticMut => {
|
||||||
let mut err = struct_span_err!(
|
// This path cannot occur. It happens when we have an
|
||||||
self.tcx.sess, span, E0388,
|
// `&mut` or assignment to a static. But in the case
|
||||||
"{} in a static location", prefix);
|
// of `static X`, we get a mutability violation first,
|
||||||
err.span_label(span, &format!("cannot write data in a static definition"));
|
// and never get here. In the case of `static mut X`,
|
||||||
err
|
// that is unsafe and hence the aliasability error is
|
||||||
|
// ignored.
|
||||||
|
span_bug!(span, "aliasability violation for static `{}`", prefix)
|
||||||
}
|
}
|
||||||
mc::AliasableBorrowed => {
|
mc::AliasableBorrowed => {
|
||||||
let mut e = struct_span_err!(
|
let mut e = struct_span_err!(
|
||||||
|
|
|
@ -287,27 +287,7 @@ https://doc.rust-lang.org/std/cell/
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0388: r##"
|
E0388: r##"
|
||||||
A mutable borrow was attempted in a static location.
|
E0388 was removed and is no longer issued.
|
||||||
|
|
||||||
Erroneous code example:
|
|
||||||
|
|
||||||
```compile_fail,E0388
|
|
||||||
static X: i32 = 1;
|
|
||||||
|
|
||||||
static STATIC_REF: &'static mut i32 = &mut X;
|
|
||||||
// error: cannot borrow data mutably in a static location
|
|
||||||
|
|
||||||
const CONST_REF: &'static mut i32 = &mut X;
|
|
||||||
// error: cannot borrow data mutably in a static location
|
|
||||||
```
|
|
||||||
|
|
||||||
To fix this error, you have to use constant borrow:
|
|
||||||
|
|
||||||
```
|
|
||||||
static X: i32 = 1;
|
|
||||||
|
|
||||||
static STATIC_REF: &'static i32 = &X;
|
|
||||||
```
|
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0389: r##"
|
E0389: r##"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue