Skip to content

Commit 48d3843

Browse files
Add requisite imports and bitset to hold qualifs
1 parent c2e121d commit 48d3843

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/librustc_mir/transform/check_consts/qualifs.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
use rustc::mir::*;
2+
use rustc::mir::interpret::ConstValue;
3+
use rustc::ty::{self, Ty};
4+
use rustc_data_structures::bit_set::BitSet;
5+
use syntax_pos::DUMMY_SP;
6+
7+
use super::Item as ConstCx;
8+
use super::validation::Mode;
9+
10+
#[derive(Clone, Copy)]
11+
pub struct QualifSet(u8);
12+
13+
impl QualifSet {
14+
fn contains<Q: ?Sized + Qualif>(self) -> bool {
15+
self.0 & (1 << Q::IDX) != 0
16+
}
17+
}
18+
119
/// A "qualif"(-ication) is a way to look for something "bad" in the MIR that would disqualify some
220
/// code for promotion or prevent it from evaluating at compile time. So `return true` means
321
/// "I found something bad, no reason to go on searching". `false` is only returned if we
@@ -103,7 +121,7 @@ pub trait Qualif {
103121
} else {
104122
let (bits, _) = cx.tcx.at(constant.span).mir_const_qualif(def_id);
105123

106-
let qualif = PerQualif::decode_from_bits(bits).0[Self::IDX];
124+
let qualif = QualifSet(bits).contains::<Self>();
107125

108126
// Just in case the type is more specific than
109127
// the definition, e.g., impl associated const

0 commit comments

Comments
 (0)