@@ -5,7 +5,7 @@ use rustc::ty::{self, Ty};
5
5
use rustc:: hir:: def_id:: DefId ;
6
6
use syntax_pos:: DUMMY_SP ;
7
7
8
- use super :: { ConstKind , Item as ConstCx } ;
8
+ use super :: Item as ConstCx ;
9
9
10
10
pub fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> ConstQualifs {
11
11
ConstQualifs {
@@ -33,9 +33,10 @@ pub trait Qualif {
33
33
/// of the type.
34
34
fn in_any_value_of_ty ( _cx : & ConstCx < ' _ , ' tcx > , _ty : Ty < ' tcx > ) -> bool ;
35
35
36
- fn in_static ( _cx : & ConstCx < ' _ , ' tcx > , _def_id : DefId ) -> bool {
37
- // FIXME(eddyb) should we do anything here for value properties?
38
- false
36
+ fn in_static ( cx : & ConstCx < ' _ , ' tcx > , def_id : DefId ) -> bool {
37
+ // `mir_const_qualif` does return the qualifs in the final value of a `static`, so we could
38
+ // use value-based qualification here, but we shouldn't do this without a good reason.
39
+ Self :: in_any_value_of_ty ( cx, cx. tcx . type_of ( def_id) )
39
40
}
40
41
41
42
fn in_projection_structurally (
@@ -217,34 +218,6 @@ impl Qualif for HasMutInterior {
217
218
rvalue : & Rvalue < ' tcx > ,
218
219
) -> bool {
219
220
match * rvalue {
220
- // Returning `true` for `Rvalue::Ref` indicates the borrow isn't
221
- // allowed in constants (and the `Checker` will error), and/or it
222
- // won't be promoted, due to `&mut ...` or interior mutability.
223
- Rvalue :: Ref ( _, kind, ref place) => {
224
- let ty = place. ty ( cx. body , cx. tcx ) . ty ;
225
-
226
- if let BorrowKind :: Mut { .. } = kind {
227
- // In theory, any zero-sized value could be borrowed
228
- // mutably without consequences.
229
- match ty. kind {
230
- // Inside a `static mut`, &mut [...] is also allowed.
231
- | ty:: Array ( ..)
232
- | ty:: Slice ( _)
233
- if cx. const_kind == Some ( ConstKind :: StaticMut )
234
- => { } ,
235
-
236
- // FIXME(eddyb): We only return false for `&mut []` outside a const
237
- // context which seems unnecessary given that this is merely a ZST.
238
- | ty:: Array ( _, len)
239
- if len. try_eval_usize ( cx. tcx , cx. param_env ) == Some ( 0 )
240
- && cx. const_kind == None
241
- => { } ,
242
-
243
- _ => return true ,
244
- }
245
- }
246
- }
247
-
248
221
Rvalue :: Aggregate ( ref kind, _) => {
249
222
if let AggregateKind :: Adt ( def, ..) = * * kind {
250
223
if Some ( def. did ) == cx. tcx . lang_items ( ) . unsafe_cell_type ( ) {
0 commit comments