Skip to content

Commit 03295a7

Browse files
committed
rustc: qualify expressions in check_const for potential promotion.
1 parent 7be460f commit 03295a7

File tree

5 files changed

+454
-140
lines changed

5 files changed

+454
-140
lines changed

src/librustc/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ register_diagnostics! {
5959
E0010,
6060
E0011,
6161
E0012,
62+
E0013,
6263
E0014,
6364
E0015,
6465
E0016,

src/librustc/metadata/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
143143
tag_table_upvar_capture_map = 0x56,
144144
tag_table_capture_modes = 0x57,
145145
tag_table_object_cast_map = 0x58,
146+
tag_table_const_qualif = 0x59,
146147
}
147148

148149
pub const tag_item_trait_item_sort: uint = 0x60;

src/librustc/middle/astencode.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use metadata::tydecode;
2323
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
2424
use metadata::tydecode::{RegionParameter, ClosureSource};
2525
use metadata::tyencode;
26+
use middle::check_const::ConstQualif;
2627
use middle::mem_categorization::Typer;
2728
use middle::subst;
2829
use middle::subst::VecPerParamSpace;
@@ -1306,6 +1307,15 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
13061307
})
13071308
})
13081309
}
1310+
1311+
for &qualif in tcx.const_qualif_map.borrow().get(&id).iter() {
1312+
rbml_w.tag(c::tag_table_const_qualif, |rbml_w| {
1313+
rbml_w.id(id);
1314+
rbml_w.tag(c::tag_table_val, |rbml_w| {
1315+
qualif.encode(rbml_w).unwrap()
1316+
})
1317+
})
1318+
}
13091319
}
13101320

13111321
trait doc_decoder_helpers {
@@ -1920,6 +1930,10 @@ fn decode_side_tables(dcx: &DecodeContext,
19201930
dcx.tcx.closure_kinds.borrow_mut().insert(ast_util::local_def(id),
19211931
closure_kind);
19221932
}
1933+
c::tag_table_const_qualif => {
1934+
let qualif: ConstQualif = Decodable::decode(val_dsr).unwrap();
1935+
dcx.tcx.const_qualif_map.borrow_mut().insert(id, qualif);
1936+
}
19231937
_ => {
19241938
dcx.tcx.sess.bug(
19251939
&format!("unknown tag found in side tables: {:x}",

0 commit comments

Comments
 (0)