diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 5b0eea6bcc5..8bb83c54da8 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -45,8 +45,6 @@ use std::collections::hash_map::Entry; bitflags! { #[derive(RustcEncodable, RustcDecodable)] flags ConstQualif: u8 { - // Const rvalue which can be placed behind a reference. - const PURE_CONST = 0, // Inner mutability (can not be placed behind a reference) or behind // &mut in a non-global expression. Can be copied from static memory. const MUTABLE_MEM = 1 << 0, @@ -104,7 +102,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { { let (old_mode, old_qualif) = (self.mode, self.qualif); self.mode = mode; - self.qualif = ConstQualif::PURE_CONST; + self.qualif = ConstQualif::empty(); let r = f(self); self.mode = old_mode; self.qualif = old_qualif; @@ -128,7 +126,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { Entry::Occupied(entry) => return *entry.get(), Entry::Vacant(entry) => { // Prevent infinite recursion on re-entry. - entry.insert(ConstQualif::PURE_CONST); + entry.insert(ConstQualif::empty()); } } self.with_mode(mode, |this| { @@ -273,7 +271,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_expr(&mut self, ex: &ast::Expr) { let mut outer = self.qualif; - self.qualif = ConstQualif::PURE_CONST; + self.qualif = ConstQualif::empty(); let node_ty = ty::node_id_to_type(self.tcx, ex.id); check_expr(self, ex, node_ty); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index c4ab89e3b4d..3fff1504993 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -850,9 +850,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { // Compute maximum lifetime of this rvalue. This is 'static if // we can promote to a constant, otherwise equal to enclosing temp // lifetime. - let re = match qualif & check_const::ConstQualif::NON_STATIC_BORROWS { - check_const::ConstQualif::PURE_CONST => ty::ReStatic, - _ => self.temporary_scope(id), + let re = if qualif.intersects(check_const::ConstQualif::NON_STATIC_BORROWS) { + self.temporary_scope(id) + } else { + ty::ReStatic }; let ret = self.cat_rvalue(id, span, re, expr_ty); debug!("cat_rvalue_node ret {}", ret.repr(self.tcx())); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c80dba6d1fb..5298c9682b4 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -849,7 +849,6 @@ impl<'tcx> ctxt<'tcx> { // recursing over the type itself. bitflags! { flags TypeFlags: u32 { - const NO_TYPE_FLAGS = 0, const HAS_PARAMS = 1 << 0, const HAS_SELF = 1 << 1, const HAS_TY_INFER = 1 << 2, @@ -2925,7 +2924,7 @@ struct FlagComputation { impl FlagComputation { fn new() -> FlagComputation { - FlagComputation { flags: TypeFlags::NO_TYPE_FLAGS, depth: 0 } + FlagComputation { flags: TypeFlags::empty(), depth: 0 } } fn for_sty(st: &sty) -> FlagComputation { diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 3aaf4addd89..503bdf8dadb 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -186,7 +186,7 @@ fn get_const_val(ccx: &CrateContext, ref_expr: &ast::Expr) -> ValueRef { let expr = get_const_expr(ccx, def_id, ref_expr); let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); - get_const_expr_as_global(ccx, expr, check_const::ConstQualif::PURE_CONST, empty_substs) + get_const_expr_as_global(ccx, expr, check_const::ConstQualif::empty(), empty_substs) } pub fn get_const_expr_as_global<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a7b1beace51..eb1c338ac85 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -88,7 +88,6 @@ use std::slice; bitflags! { flags Restrictions: u8 { - const UNRESTRICTED = 0, const RESTRICTION_STMT_EXPR = 1 << 0, const RESTRICTION_NO_STRUCT_LITERAL = 1 << 1, } @@ -339,7 +338,7 @@ impl<'a> Parser<'a> { buffer_start: 0, buffer_end: 0, tokens_consumed: 0, - restrictions: Restrictions::UNRESTRICTED, + restrictions: Restrictions::empty(), quote_depth: 0, obsolete_set: HashSet::new(), mod_path_stack: Vec::new(), @@ -2991,7 +2990,7 @@ impl<'a> Parser<'a> { /// Parse an expression pub fn parse_expr_nopanic(&mut self) -> PResult> { - return self.parse_expr_res(Restrictions::UNRESTRICTED); + self.parse_expr_res(Restrictions::empty()) } /// Parse an expression, subject to the given restrictions