Skip to content

Commit 5accd53

Browse files
committed
---
yaml --- r: 180202 b: refs/heads/tmp c: 35ff6c59676269dd6c0fa9f8048e47ccb1cfde0f h: refs/heads/master v: v3
1 parent 44bec46 commit 5accd53

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 17e054bbca1e696e564d5e71044b9746288aca92
37+
refs/heads/tmp: 35ff6c59676269dd6c0fa9f8048e47ccb1cfde0f

branches/tmp/src/librustc/middle/mem_categorization.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub use self::Note::*;
7171
pub use self::deref_kind::*;
7272
pub use self::categorization::*;
7373

74+
use middle::check_const;
7475
use middle::def;
7576
use middle::region;
7677
use middle::ty::{self, Ty};
@@ -808,17 +809,29 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
808809
span: Span,
809810
expr_ty: Ty<'tcx>)
810811
-> cmt<'tcx> {
811-
match self.typer.temporary_scope(id) {
812-
Some(scope) => {
813-
match expr_ty.sty {
814-
ty::ty_vec(_, Some(0)) => self.cat_rvalue(id, span, ty::ReStatic, expr_ty),
815-
_ => self.cat_rvalue(id, span, ty::ReScope(scope), expr_ty)
816-
}
812+
let qualif = self.tcx().const_qualif_map.borrow().get(&id).cloned()
813+
.unwrap_or(check_const::NOT_CONST);
814+
815+
// Only promote `[T; 0]` before an RFC for rvalue promotions
816+
// is accepted.
817+
let qualif = match expr_ty.sty {
818+
ty::ty_vec(_, Some(0)) => qualif,
819+
_ => check_const::NOT_CONST
820+
};
821+
822+
let re = match qualif & check_const::NON_STATIC_BORROWS {
823+
check_const::PURE_CONST => {
824+
// Constant rvalues get promoted to 'static.
825+
ty::ReStatic
817826
}
818-
None => {
819-
self.cat_rvalue(id, span, ty::ReStatic, expr_ty)
827+
_ => {
828+
match self.typer.temporary_scope(id) {
829+
Some(scope) => ty::ReScope(scope),
830+
None => ty::ReStatic
831+
}
820832
}
821-
}
833+
};
834+
self.cat_rvalue(id, span, re, expr_ty)
822835
}
823836

824837
pub fn cat_rvalue(&self,

0 commit comments

Comments
 (0)