Skip to content

Commit 538556d

Browse files
committed
kill the code path for E0388
This was specific to the old special-case handling of statics in borrowck.
1 parent deb53a3 commit 538556d

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
801801
}
802802
mc::AliasableStatic |
803803
mc::AliasableStaticMut => {
804-
let mut err = struct_span_err!(
805-
self.tcx.sess, span, E0388,
806-
"{} in a static location", prefix);
807-
err.span_label(span, &format!("cannot write data in a static definition"));
808-
err
804+
// This path cannot occur. It happens when we have an
805+
// `&mut` or assignment to a static. But in the case
806+
// of `static X`, we get a mutability violation first,
807+
// and never get here. In the case of `static mut X`,
808+
// that is unsafe and hence the aliasability error is
809+
// ignored.
810+
span_bug!(span, "aliasability violation for static `{}`", prefix)
809811
}
810812
mc::AliasableBorrowed => {
811813
let mut e = struct_span_err!(

src/librustc_borrowck/diagnostics.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -287,27 +287,7 @@ https://doc.rust-lang.org/std/cell/
287287
"##,
288288

289289
E0388: r##"
290-
A mutable borrow was attempted in a static location.
291-
292-
Erroneous code example:
293-
294-
```compile_fail,E0388
295-
static X: i32 = 1;
296-
297-
static STATIC_REF: &'static mut i32 = &mut X;
298-
// error: cannot borrow data mutably in a static location
299-
300-
const CONST_REF: &'static mut i32 = &mut X;
301-
// error: cannot borrow data mutably in a static location
302-
```
303-
304-
To fix this error, you have to use constant borrow:
305-
306-
```
307-
static X: i32 = 1;
308-
309-
static STATIC_REF: &'static i32 = &X;
310-
```
290+
E0388 was removed and is no longer issued.
311291
"##,
312292

313293
E0389: r##"

0 commit comments

Comments
 (0)