Skip to content

Commit 920d27b

Browse files
committed
Fixed crashes in the framework for bound comparisons.
1 parent 8a8f5c0 commit 920d27b

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/semcheck/translate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ fn translate_predicate<'a, 'tcx>(id_mapping: &IdMapping,
178178
},
179179
Predicate::RegionOutlives(region_outlives_predicate) => {
180180
Predicate::RegionOutlives(region_outlives_predicate.map_bound(|r_pred| {
181-
let l = translate_region(id_mapping, tcx, &r_pred.0);
182-
let r = translate_region(id_mapping, tcx, &r_pred.1);
181+
let l = translate_region(id_mapping, tcx, r_pred.0);
182+
let r = translate_region(id_mapping, tcx, r_pred.1);
183183
OutlivesPredicate(l, r)
184184
}))
185185
},
186186
Predicate::TypeOutlives(type_outlives_predicate) => {
187187
Predicate::TypeOutlives(type_outlives_predicate.map_bound(|r_pred| {
188188
let l = translate(id_mapping, tcx, index_map, &r_pred.0);
189-
let r = translate_region(id_mapping, tcx, &r_pred.1);
189+
let r = translate_region(id_mapping, tcx, r_pred.1);
190190
OutlivesPredicate(l, r)
191191
}))
192192
},

src/semcheck/traverse.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use semcheck::changes::ChangeType::*;
2121
use semcheck::changes::ChangeSet;
2222
use semcheck::mapping::{IdMapping, NameMapping};
2323
use semcheck::mismatch::Mismatch;
24-
use semcheck::translate::translate_item_type;
24+
use semcheck::translate::{translate_item_type, translate_param_env};
2525

2626
use std::collections::{BTreeMap, HashSet, VecDeque};
2727

@@ -45,7 +45,7 @@ pub fn run_analysis<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, old: DefId, new: DefI
4545

4646
// third pass
4747
for (old, new) in id_mapping.items() {
48-
diff_bounds(&mut changes, tcx, old.def_id(), new.def_id());
48+
diff_bounds(&mut changes, &id_mapping, tcx, old, new);
4949
}
5050

5151
// fourth pass
@@ -540,21 +540,36 @@ fn diff_generics(changes: &mut ChangeSet,
540540
// being exported.
541541

542542
/// Given two items, compare the bounds on their type and region parameters.
543-
fn diff_bounds<'a, 'tcx>(_changes: &mut ChangeSet,
544-
_tcx: TyCtxt<'a, 'tcx, 'tcx>,
545-
_old: DefId,
546-
_new: DefId)
547-
-> (Vec<ChangeType<'tcx>>, Vec<(DefId, DefId)>)
548-
{
543+
fn diff_bounds<'a, 'tcx>(changes: &mut ChangeSet,
544+
id_mapping: &IdMapping,
545+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
546+
old: Def,
547+
new: Def) {
548+
use rustc::hir::def::Def::Macro;
549+
550+
let old_def_id = old.def_id();
551+
let new_def_id = new.def_id();
552+
553+
if changes.item_breaking(old_def_id) ||
554+
id_mapping.get_trait_def(&old_def_id)
555+
.map_or(false, |did| changes.trait_item_breaking(did)) {
556+
return;
557+
}
558+
559+
if let Macro(_, _) = old {
560+
return; // TODO: more cases like this one
561+
}
562+
563+
let old_param_env =
564+
translate_param_env(id_mapping, tcx, old_def_id, tcx.param_env(old_def_id));
565+
549566
/* let old_param_env = tcx.param_env(old);
550567
let res = Default::default();
551568
552569
let old_preds = tcx.predicates_of(old).predicates;
553570
let new_preds = tcx.predicates_of(new).predicates;
554571
555572
res */
556-
557-
Default::default()
558573
}
559574

560575
// Below functions constitute the fourth and last pass of analysis, in which the types of

0 commit comments

Comments
 (0)