Skip to content

Commit 2142edf

Browse files
committed
---
yaml --- r: 180122 b: refs/heads/auto c: 35ff6c59676269dd6c0fa9f8048e47ccb1cfde0f h: refs/heads/master v: v3
1 parent c956c9b commit 2142edf

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 17e054bbca1e696e564d5e71044b9746288aca92
13+
refs/heads/auto: 35ff6c59676269dd6c0fa9f8048e47ccb1cfde0f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)