Skip to content

Instantly share code, notes, and snippets.

@edwardw
Last active Aug 29, 2015
Embed
What would you like to do?
A fix for #22077 on top of #22338
diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs
index 2f3bd5d..5a319a6 100644
--- a/src/librustc_typeck/check/assoc.rs
+++ b/src/librustc_typeck/check/assoc.rs
@@ -9,31 +9,35 @@
// except according to those terms.
use middle::infer::InferCtxt;
-use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation,
- SelectionContext, ObligationCause};
+use middle::subst::Substs;
+use middle::traits::{self, FulfillmentContext, SelectionContext};
+use middle::traits::{MiscObligation, Normalized, ObligationCause};
use middle::ty::{self, HasProjectionTypes};
use middle::ty_fold::{TypeFoldable, TypeFolder};
use syntax::ast;
use syntax::codemap::Span;
use util::ppaux::Repr;
-pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
- typer: &(ty::ClosureTyper<'tcx>+'a),
+pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &'a InferCtxt<'a,'tcx>,
+ typer: &'a (ty::ClosureTyper<'tcx>+'a),
fulfillment_cx: &mut FulfillmentContext<'tcx>,
span: Span,
body_id: ast::NodeId,
- value: &T)
+ value: &T,
+ ambient_substs: Option<&'a Substs<'tcx>>)
-> T
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx>
{
debug!("normalize_associated_types_in(value={})", value.repr(infcx.tcx));
- let mut selcx = SelectionContext::new(infcx, typer, None);
+ let mut selcx = SelectionContext::new(infcx, typer, ambient_substs);
let cause = ObligationCause::new(span, body_id, MiscObligation);
let Normalized { value: result,
obligations } = traits::normalize(&mut selcx, cause, value);
+
debug!("normalize_associated_types_in: result={} predicates={}",
result.repr(infcx.tcx),
obligations.repr(infcx.tcx));
+
for obligation in obligations {
fulfillment_cx.register_predicate_obligation(infcx, obligation);
}
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 4228d23..a7aa80a 100644
--- a/src/librustc_typeck/check/compare_method.rs
+++ b/src/librustc_typeck/check/compare_method.rs
@@ -285,7 +285,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
&mut fulfillment_cx,
impl_m_span,
impl_m_body_id,
- &impl_sig);
+ &impl_sig,
+ Some(&impl_param_env.free_substs));
let impl_fty =
ty::mk_bare_fn(tcx,
None,
@@ -305,7 +306,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
&mut fulfillment_cx,
impl_m_span,
impl_m_body_id,
- &trait_sig);
+ &trait_sig,
+ Some(&impl_param_env.free_substs));
let trait_fty =
ty::mk_bare_fn(tcx,
None,
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index d12b231..a83125a 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -416,7 +416,8 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
typer,
&mut *fulfillment_cx, span,
body_id,
- value)
+ value,
+ None)
}
}
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 18dd122..973713b 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -1246,7 +1246,7 @@ impl<K, V, S, H> Default for HashMap<K, V, S>
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<K, Q: ?Sized, V, S, H> Index<Q> for HashMap<K, V, S>
+impl<K, V, S, H, Q: ?Sized> Index<Q> for HashMap<K, V, S>
where K: Eq + Hash<H>,
Q: Eq + Hash<H> + BorrowFrom<K>,
S: HashState<Hasher=H>,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment