提交 03295a71 编写于 作者: E Eduard Burtescu

rustc: qualify expressions in check_const for potential promotion.

上级 7be460ff
......@@ -59,6 +59,7 @@
E0010,
E0011,
E0012,
E0013,
E0014,
E0015,
E0016,
......
......@@ -143,6 +143,7 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
tag_table_upvar_capture_map = 0x56,
tag_table_capture_modes = 0x57,
tag_table_object_cast_map = 0x58,
tag_table_const_qualif = 0x59,
}
pub const tag_item_trait_item_sort: uint = 0x60;
......
......@@ -23,6 +23,7 @@
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
use metadata::tydecode::{RegionParameter, ClosureSource};
use metadata::tyencode;
use middle::check_const::ConstQualif;
use middle::mem_categorization::Typer;
use middle::subst;
use middle::subst::VecPerParamSpace;
......@@ -1306,6 +1307,15 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
})
}
for &qualif in tcx.const_qualif_map.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_const_qualif, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
qualif.encode(rbml_w).unwrap()
})
})
}
}
trait doc_decoder_helpers {
......@@ -1920,6 +1930,10 @@ fn decode_side_tables(dcx: &DecodeContext,
dcx.tcx.closure_kinds.borrow_mut().insert(ast_util::local_def(id),
closure_kind);
}
c::tag_table_const_qualif => {
let qualif: ConstQualif = Decodable::decode(val_dsr).unwrap();
dcx.tcx.const_qualif_map.borrow_mut().insert(id, qualif);
}
_ => {
dcx.tcx.sess.bug(
&format!("unknown tag found in side tables: {:x}",
......
此差异已折叠。
......@@ -44,6 +44,7 @@
use lint;
use metadata::csearch;
use middle;
use middle::check_const;
use middle::const_eval;
use middle::def::{self, DefMap, ExportMap};
use middle::dependency_format;
......@@ -838,6 +839,9 @@ pub struct ctxt<'tcx> {
/// Caches whether traits are object safe
pub object_safety_cache: RefCell<DefIdMap<bool>>,
/// Maps Expr NodeId's to their constant qualification.
pub const_qualif_map: RefCell<NodeMap<check_const::ConstQualif>>,
}
// Flags that we track on types. These flags are propagated upwards
......@@ -2472,6 +2476,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
type_impls_copy_cache: RefCell::new(HashMap::new()),
type_impls_sized_cache: RefCell::new(HashMap::new()),
object_safety_cache: RefCell::new(DefIdMap()),
const_qualif_map: RefCell::new(NodeMap()),
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册