Skip to content

Commit 32a0a76

Browse files
committed
Fix panic, tidy error
1 parent 75884d4 commit 32a0a76

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/librustc/traits/select.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1174,18 +1174,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
11741174
// resolving specializations.
11751175
if candidates.len() > 1 {
11761176
let mut i = 0;
1177-
//candidates.retain(|c| {
1178-
// match c.candidate {
1179-
// ParamCandidate(poly_trait_ref) => {
1180-
// if poly_trait_ref == stack.obligation.predicate.map_bound(|x| x.trait_ref) {
1181-
// debug!("Dropping candidate (== obligation): {:?}", c);
1182-
// return false;
1183-
// }
1184-
// }
1185-
// _ => {}
1186-
// }
1187-
// true
1188-
//});
11891177
while i < candidates.len() {
11901178
let is_dup =
11911179
(0..candidates.len())

src/librustc/ty/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2732,21 +2732,21 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
27322732
// are any errors at that point, so after type checking you can be
27332733
// sure that this will succeed without errors anyway.
27342734

2735-
let id = tcx.hir.as_local_node_id(def_id).unwrap();
2736-
debug!("param_env: handling def_id={:?}, id={:?}", def_id, id);
2737-
2738-
if let Some(hir::map::NodeItem(item)) = tcx.hir.find(id) {
2739-
debug!(" param_env: self node: {:?}", item.node);
2740-
if let hir::ItemTrait(..) = item.node {
2741-
debug!(" param_env: self is trait!");
2742-
let trait_ref = ty::TraitRef {
2743-
def_id: def_id,
2744-
substs: Substs::identity_for_item(tcx, def_id)
2745-
};
2746-
predicates.push(trait_ref.to_poly_trait_ref().to_predicate());
2735+
if let Some(id) = tcx.hir.as_local_node_id(def_id) {
2736+
debug!("param_env: handling def_id={:?}, id={:?}", def_id, id);
2737+
if let Some(hir::map::NodeItem(item)) = tcx.hir.find(id) {
2738+
debug!(" param_env: self node: {:?}", item.node);
2739+
if let hir::ItemTrait(..) = item.node {
2740+
debug!(" param_env: self is trait!");
2741+
let trait_ref = ty::TraitRef {
2742+
def_id: def_id,
2743+
substs: Substs::identity_for_item(tcx, def_id)
2744+
};
2745+
predicates.push(trait_ref.to_poly_trait_ref().to_predicate());
2746+
}
27472747
}
2748+
debug!(" param_env predicates: {:?}", predicates);
27482749
}
2749-
debug!(" param_env predicates: {:?}", predicates);
27502750

27512751
let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
27522752
traits::Reveal::UserFacing);

0 commit comments

Comments
 (0)