Skip to content

Commit 27f22b8

Browse files
committed
rustc: qualify expressions in check_const for potential promotion.
1 parent 3bdce1e commit 27f22b8

File tree

5 files changed

+449
-136
lines changed

5 files changed

+449
-136
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
@@ -142,6 +142,7 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
142142
tag_table_upvar_borrow_map = 0x55,
143143
tag_table_capture_modes = 0x56,
144144
tag_table_object_cast_map = 0x57,
145+
tag_table_const_qualif = 0x58,
145146
}
146147

147148
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;
@@ -1329,6 +1330,15 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
13291330
})
13301331
})
13311332
}
1333+
1334+
for &qualif in tcx.const_qualif_map.borrow().get(&id).iter() {
1335+
rbml_w.tag(c::tag_table_const_qualif, |rbml_w| {
1336+
rbml_w.id(id);
1337+
rbml_w.tag(c::tag_table_val, |rbml_w| {
1338+
qualif.encode(rbml_w).unwrap()
1339+
})
1340+
})
1341+
}
13321342
}
13331343

13341344
trait doc_decoder_helpers {
@@ -1960,6 +1970,10 @@ fn decode_side_tables(dcx: &DecodeContext,
19601970
dcx.tcx.closures.borrow_mut().insert(ast_util::local_def(id),
19611971
closure);
19621972
}
1973+
c::tag_table_const_qualif => {
1974+
let qualif: ConstQualif = Decodable::decode(val_dsr).unwrap();
1975+
dcx.tcx.const_qualif_map.borrow_mut().insert(id, qualif);
1976+
}
19631977
_ => {
19641978
dcx.tcx.sess.bug(
19651979
&format!("unknown tag found in side tables: {:x}",

0 commit comments

Comments
 (0)