Skip to content

Commit 5cfa713

Browse files
committed
Use empty() instead of a special const
1 parent 252b544 commit 5cfa713

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

src/librustc/middle/check_const.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ use std::collections::hash_map::Entry;
4545
bitflags! {
4646
#[derive(RustcEncodable, RustcDecodable)]
4747
flags ConstQualif: u8 {
48-
// Const rvalue which can be placed behind a reference.
49-
const PURE_CONST = 0,
5048
// Inner mutability (can not be placed behind a reference) or behind
5149
// &mut in a non-global expression. Can be copied from static memory.
5250
const MUTABLE_MEM = 1 << 0,
@@ -104,7 +102,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
104102
{
105103
let (old_mode, old_qualif) = (self.mode, self.qualif);
106104
self.mode = mode;
107-
self.qualif = ConstQualif::PURE_CONST;
105+
self.qualif = ConstQualif::empty();
108106
let r = f(self);
109107
self.mode = old_mode;
110108
self.qualif = old_qualif;
@@ -128,7 +126,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
128126
Entry::Occupied(entry) => return *entry.get(),
129127
Entry::Vacant(entry) => {
130128
// Prevent infinite recursion on re-entry.
131-
entry.insert(ConstQualif::PURE_CONST);
129+
entry.insert(ConstQualif::empty());
132130
}
133131
}
134132
self.with_mode(mode, |this| {
@@ -273,7 +271,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
273271

274272
fn visit_expr(&mut self, ex: &ast::Expr) {
275273
let mut outer = self.qualif;
276-
self.qualif = ConstQualif::PURE_CONST;
274+
self.qualif = ConstQualif::empty();
277275

278276
let node_ty = ty::node_id_to_type(self.tcx, ex.id);
279277
check_expr(self, ex, node_ty);

src/librustc/middle/mem_categorization.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -850,9 +850,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
850850
// Compute maximum lifetime of this rvalue. This is 'static if
851851
// we can promote to a constant, otherwise equal to enclosing temp
852852
// lifetime.
853-
let re = match qualif & check_const::ConstQualif::NON_STATIC_BORROWS {
854-
check_const::ConstQualif::PURE_CONST => ty::ReStatic,
855-
_ => self.temporary_scope(id),
853+
let re = if qualif.intersects(check_const::ConstQualif::NON_STATIC_BORROWS) {
854+
self.temporary_scope(id)
855+
} else {
856+
ty::ReStatic
856857
};
857858
let ret = self.cat_rvalue(id, span, re, expr_ty);
858859
debug!("cat_rvalue_node ret {}", ret.repr(self.tcx()));

src/librustc/middle/ty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ impl<'tcx> ctxt<'tcx> {
849849
// recursing over the type itself.
850850
bitflags! {
851851
flags TypeFlags: u32 {
852-
const NO_TYPE_FLAGS = 0,
853852
const HAS_PARAMS = 1 << 0,
854853
const HAS_SELF = 1 << 1,
855854
const HAS_TY_INFER = 1 << 2,
@@ -2925,7 +2924,7 @@ struct FlagComputation {
29252924

29262925
impl FlagComputation {
29272926
fn new() -> FlagComputation {
2928-
FlagComputation { flags: TypeFlags::NO_TYPE_FLAGS, depth: 0 }
2927+
FlagComputation { flags: TypeFlags::empty(), depth: 0 }
29292928
}
29302929

29312930
fn for_sty(st: &sty) -> FlagComputation {

src/librustc_trans/trans/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn get_const_val(ccx: &CrateContext,
186186
ref_expr: &ast::Expr) -> ValueRef {
187187
let expr = get_const_expr(ccx, def_id, ref_expr);
188188
let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
189-
get_const_expr_as_global(ccx, expr, check_const::ConstQualif::PURE_CONST, empty_substs)
189+
get_const_expr_as_global(ccx, expr, check_const::ConstQualif::empty(), empty_substs)
190190
}
191191

192192
pub fn get_const_expr_as_global<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,

src/libsyntax/parse/parser.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ use std::slice;
8888

8989
bitflags! {
9090
flags Restrictions: u8 {
91-
const UNRESTRICTED = 0,
9291
const RESTRICTION_STMT_EXPR = 1 << 0,
9392
const RESTRICTION_NO_STRUCT_LITERAL = 1 << 1,
9493
}
@@ -339,7 +338,7 @@ impl<'a> Parser<'a> {
339338
buffer_start: 0,
340339
buffer_end: 0,
341340
tokens_consumed: 0,
342-
restrictions: Restrictions::UNRESTRICTED,
341+
restrictions: Restrictions::empty(),
343342
quote_depth: 0,
344343
obsolete_set: HashSet::new(),
345344
mod_path_stack: Vec::new(),
@@ -2991,7 +2990,7 @@ impl<'a> Parser<'a> {
29912990

29922991
/// Parse an expression
29932992
pub fn parse_expr_nopanic(&mut self) -> PResult<P<Expr>> {
2994-
return self.parse_expr_res(Restrictions::UNRESTRICTED);
2993+
self.parse_expr_res(Restrictions::empty())
29952994
}
29962995

29972996
/// Parse an expression, subject to the given restrictions

0 commit comments

Comments
 (0)