Skip to content

Commit 2edb643

Browse files
committed
rollup merge of #24921: tamird/bitflags-associated-const
Conflicts: src/librustc/lib.rs
2 parents cc04cd4 + 8c58fe1 commit 2edb643

24 files changed

+341
-295
lines changed

src/librustc/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,23 @@
2525
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2626
html_root_url = "http://doc.rust-lang.org/nightly/")]
2727

28+
#![feature(associated_consts)]
2829
#![feature(box_patterns)]
2930
#![feature(box_syntax)]
3031
#![feature(collections)]
3132
#![feature(core)]
33+
#![feature(fs_canonicalize)]
3234
#![feature(hash)]
35+
#![feature(into_cow)]
3336
#![feature(libc)]
37+
#![feature(path_ext)]
3438
#![feature(quote)]
3539
#![feature(rustc_diagnostic_macros)]
3640
#![feature(rustc_private)]
41+
#![feature(slice_patterns)]
3742
#![feature(staged_api)]
3843
#![feature(std_misc)]
39-
#![feature(path_ext)]
4044
#![feature(str_char)]
41-
#![feature(into_cow)]
42-
#![feature(fs_canonicalize)]
43-
#![feature(slice_patterns)]
4445
#![cfg_attr(test, feature(test))]
4546

4647
#![allow(trivial_casts)]

src/librustc/middle/check_const.rs

+48-46
Large diffs are not rendered by default.

src/librustc/middle/mem_categorization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -838,20 +838,20 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
838838
expr_ty: Ty<'tcx>)
839839
-> cmt<'tcx> {
840840
let qualif = self.tcx().const_qualif_map.borrow().get(&id).cloned()
841-
.unwrap_or(check_const::NOT_CONST);
841+
.unwrap_or(check_const::ConstQualif::NOT_CONST);
842842

843843
// Only promote `[T; 0]` before an RFC for rvalue promotions
844844
// is accepted.
845845
let qualif = match expr_ty.sty {
846846
ty::ty_vec(_, Some(0)) => qualif,
847-
_ => check_const::NOT_CONST
847+
_ => check_const::ConstQualif::NOT_CONST
848848
};
849849

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::NON_STATIC_BORROWS {
854-
check_const::PURE_CONST => ty::ReStatic,
853+
let re = match qualif & check_const::ConstQualif::NON_STATIC_BORROWS {
854+
check_const::ConstQualif::PURE_CONST => ty::ReStatic,
855855
_ => self.temporary_scope(id),
856856
};
857857
let ret = self.cat_rvalue(id, span, re, expr_ty);

src/librustc/middle/ty.rs

+32-30
Original file line numberDiff line numberDiff line change
@@ -848,16 +848,18 @@ impl<'tcx> ctxt<'tcx> {
848848
// recursing over the type itself.
849849
bitflags! {
850850
flags TypeFlags: u32 {
851-
const NO_TYPE_FLAGS = 0b0,
852-
const HAS_PARAMS = 0b1,
853-
const HAS_SELF = 0b10,
854-
const HAS_TY_INFER = 0b100,
855-
const HAS_RE_INFER = 0b1000,
856-
const HAS_RE_LATE_BOUND = 0b10000,
857-
const HAS_REGIONS = 0b100000,
858-
const HAS_TY_ERR = 0b1000000,
859-
const HAS_PROJECTION = 0b10000000,
860-
const NEEDS_SUBST = HAS_PARAMS.bits | HAS_SELF.bits | HAS_REGIONS.bits,
851+
const NO_TYPE_FLAGS = 0,
852+
const HAS_PARAMS = 1 << 0,
853+
const HAS_SELF = 1 << 1,
854+
const HAS_TY_INFER = 1 << 2,
855+
const HAS_RE_INFER = 1 << 3,
856+
const HAS_RE_LATE_BOUND = 1 << 4,
857+
const HAS_REGIONS = 1 << 5,
858+
const HAS_TY_ERR = 1 << 6,
859+
const HAS_PROJECTION = 1 << 7,
860+
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
861+
TypeFlags::HAS_SELF.bits |
862+
TypeFlags::HAS_REGIONS.bits,
861863
}
862864
}
863865

@@ -890,8 +892,8 @@ macro_rules! sty_debug_print {
890892
ty::ty_err => /* unimportant */ continue,
891893
$(ty::$variant(..) => &mut $variant,)*
892894
};
893-
let region = t.flags.intersects(ty::HAS_RE_INFER);
894-
let ty = t.flags.intersects(ty::HAS_TY_INFER);
895+
let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER);
896+
let ty = t.flags.intersects(ty::TypeFlags::HAS_TY_INFER);
895897

896898
variant.total += 1;
897899
total.total += 1;
@@ -993,23 +995,23 @@ impl<'tcx> Borrow<sty<'tcx>> for InternedTy<'tcx> {
993995
}
994996

995997
pub fn type_has_params(ty: Ty) -> bool {
996-
ty.flags.intersects(HAS_PARAMS)
998+
ty.flags.intersects(TypeFlags::HAS_PARAMS)
997999
}
9981000
pub fn type_has_self(ty: Ty) -> bool {
999-
ty.flags.intersects(HAS_SELF)
1001+
ty.flags.intersects(TypeFlags::HAS_SELF)
10001002
}
10011003
pub fn type_has_ty_infer(ty: Ty) -> bool {
1002-
ty.flags.intersects(HAS_TY_INFER)
1004+
ty.flags.intersects(TypeFlags::HAS_TY_INFER)
10031005
}
10041006
pub fn type_needs_infer(ty: Ty) -> bool {
1005-
ty.flags.intersects(HAS_TY_INFER | HAS_RE_INFER)
1007+
ty.flags.intersects(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_RE_INFER)
10061008
}
10071009
pub fn type_has_projection(ty: Ty) -> bool {
1008-
ty.flags.intersects(HAS_PROJECTION)
1010+
ty.flags.intersects(TypeFlags::HAS_PROJECTION)
10091011
}
10101012

10111013
pub fn type_has_late_bound_regions(ty: Ty) -> bool {
1012-
ty.flags.intersects(HAS_RE_LATE_BOUND)
1014+
ty.flags.intersects(TypeFlags::HAS_RE_LATE_BOUND)
10131015
}
10141016

10151017
/// An "escaping region" is a bound region whose binder is not part of `t`.
@@ -2810,7 +2812,7 @@ struct FlagComputation {
28102812

28112813
impl FlagComputation {
28122814
fn new() -> FlagComputation {
2813-
FlagComputation { flags: NO_TYPE_FLAGS, depth: 0 }
2815+
FlagComputation { flags: TypeFlags::NO_TYPE_FLAGS, depth: 0 }
28142816
}
28152817

28162818
fn for_sty(st: &sty) -> FlagComputation {
@@ -2855,20 +2857,20 @@ impl FlagComputation {
28552857

28562858
// You might think that we could just return ty_err for
28572859
// any type containing ty_err as a component, and get
2858-
// rid of the HAS_TY_ERR flag -- likewise for ty_bot (with
2860+
// rid of the TypeFlags::HAS_TY_ERR flag -- likewise for ty_bot (with
28592861
// the exception of function types that return bot).
28602862
// But doing so caused sporadic memory corruption, and
28612863
// neither I (tjc) nor nmatsakis could figure out why,
28622864
// so we're doing it this way.
28632865
&ty_err => {
2864-
self.add_flags(HAS_TY_ERR)
2866+
self.add_flags(TypeFlags::HAS_TY_ERR)
28652867
}
28662868

28672869
&ty_param(ref p) => {
28682870
if p.space == subst::SelfSpace {
2869-
self.add_flags(HAS_SELF);
2871+
self.add_flags(TypeFlags::HAS_SELF);
28702872
} else {
2871-
self.add_flags(HAS_PARAMS);
2873+
self.add_flags(TypeFlags::HAS_PARAMS);
28722874
}
28732875
}
28742876

@@ -2877,15 +2879,15 @@ impl FlagComputation {
28772879
}
28782880

28792881
&ty_infer(_) => {
2880-
self.add_flags(HAS_TY_INFER)
2882+
self.add_flags(TypeFlags::HAS_TY_INFER)
28812883
}
28822884

28832885
&ty_enum(_, substs) | &ty_struct(_, substs) => {
28842886
self.add_substs(substs);
28852887
}
28862888

28872889
&ty_projection(ref data) => {
2888-
self.add_flags(HAS_PROJECTION);
2890+
self.add_flags(TypeFlags::HAS_PROJECTION);
28892891
self.add_projection_ty(data);
28902892
}
28912893

@@ -2949,11 +2951,11 @@ impl FlagComputation {
29492951
}
29502952

29512953
fn add_region(&mut self, r: Region) {
2952-
self.add_flags(HAS_REGIONS);
2954+
self.add_flags(TypeFlags::HAS_REGIONS);
29532955
match r {
2954-
ty::ReInfer(_) => { self.add_flags(HAS_RE_INFER); }
2956+
ty::ReInfer(_) => { self.add_flags(TypeFlags::HAS_RE_INFER); }
29552957
ty::ReLateBound(debruijn, _) => {
2956-
self.add_flags(HAS_RE_LATE_BOUND);
2958+
self.add_flags(TypeFlags::HAS_RE_LATE_BOUND);
29572959
self.add_depth(debruijn.depth);
29582960
}
29592961
_ => { }
@@ -3307,11 +3309,11 @@ pub fn type_is_nil(ty: Ty) -> bool {
33073309
}
33083310

33093311
pub fn type_is_error(ty: Ty) -> bool {
3310-
ty.flags.intersects(HAS_TY_ERR)
3312+
ty.flags.intersects(TypeFlags::HAS_TY_ERR)
33113313
}
33123314

33133315
pub fn type_needs_subst(ty: Ty) -> bool {
3314-
ty.flags.intersects(NEEDS_SUBST)
3316+
ty.flags.intersects(TypeFlags::NEEDS_SUBST)
33153317
}
33163318

33173319
pub fn trait_ref_contains_error(tref: &ty::TraitRef) -> bool {

0 commit comments

Comments
 (0)