mirror of https://github.com/rust-lang/rust.git
Remove elements from the todo list the correct way in constant.rs
This commit is contained in:
parent
c40788c1b2
commit
49d24a6333
|
@ -170,3 +170,7 @@ fn int_to_float(a: u8, b: i32) -> (f64, f32) {
|
||||||
fn make_array() -> [u8; 3] {
|
fn make_array() -> [u8; 3] {
|
||||||
[42, 0, 5]
|
[42, 0, 5]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn some_promoted_tuple() -> &'static (&'static str, &'static str) {
|
||||||
|
&("abc", "some")
|
||||||
|
}
|
||||||
|
|
|
@ -59,11 +59,26 @@ pub trait Mul<RHS = Self> {
|
||||||
impl Mul for u8 {
|
impl Mul for u8 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn mul(self, rhs: Self) -> Self {
|
fn mul(self, rhs: Self) -> Self::Output {
|
||||||
self * rhs
|
self * rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[lang = "sub"]
|
||||||
|
pub trait Sub<RHS = Self> {
|
||||||
|
type Output;
|
||||||
|
|
||||||
|
fn sub(self, rhs: RHS) -> Self::Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sub for usize {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn sub(self, rhs: Self) -> Self {
|
||||||
|
self - rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[lang = "bitor"]
|
#[lang = "bitor"]
|
||||||
pub trait BitOr<RHS = Self> {
|
pub trait BitOr<RHS = Self> {
|
||||||
type Output;
|
type Output;
|
||||||
|
|
|
@ -104,17 +104,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
|
||||||
) -> CPlace<'tcx> {
|
) -> CPlace<'tcx> {
|
||||||
let ty = fx.monomorphize(&const_.ty);
|
let ty = fx.monomorphize(&const_.ty);
|
||||||
let layout = fx.layout_of(ty);
|
let layout = fx.layout_of(ty);
|
||||||
if !fx
|
|
||||||
.tcx
|
|
||||||
.sess
|
|
||||||
.crate_types
|
|
||||||
.get()
|
|
||||||
.contains(&CrateType::Executable)
|
|
||||||
{
|
|
||||||
// TODO: cranelift-module api seems to be used wrong,
|
|
||||||
// thus causing panics for some consts, so this disables it
|
|
||||||
return CPlace::Addr(fx.bcx.ins().iconst(types::I64, 0), layout);
|
|
||||||
}
|
|
||||||
let alloc = fx.tcx.const_value_to_allocation(const_);
|
let alloc = fx.tcx.const_value_to_allocation(const_);
|
||||||
//println!("const value: {:?} allocation: {:?}", value, alloc);
|
//println!("const value: {:?} allocation: {:?}", value, alloc);
|
||||||
let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc);
|
let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc);
|
||||||
|
@ -161,10 +151,16 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>(
|
||||||
let mut todo = HashMap::new();
|
let mut todo = HashMap::new();
|
||||||
define_global_for_alloc_id(module, cx, alloc_id, &mut todo);
|
define_global_for_alloc_id(module, cx, alloc_id, &mut todo);
|
||||||
|
|
||||||
while let Some((alloc_id, data_id)) = {
|
loop {
|
||||||
let next = todo.drain().next();
|
let (alloc_id, data_id) = {
|
||||||
next
|
if let Some(alloc_id) = todo.keys().next().map(|alloc_id| *alloc_id) {
|
||||||
} {
|
let data_id = todo.remove(&alloc_id).unwrap();
|
||||||
|
(alloc_id, data_id)
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"cur: {:?}:{:?} todo: {:?} done: {:?}",
|
"cur: {:?}:{:?} todo: {:?} done: {:?}",
|
||||||
alloc_id, data_id, todo, cx.done
|
alloc_id, data_id, todo, cx.done
|
||||||
|
|
Loading…
Reference in New Issue