Skip to content

Commit 646ec7d

Browse files
committed
Address nits by @pcwalton
1 parent 53ede44 commit 646ec7d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/librustc/middle/traits/select.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
314314
// an impl. Even if there are no impls in this crate, perhaps
315315
// the type would be unified with something from another crate
316316
// that does provide an impl.
317-
let input_types = self.input_types(&*stack.skol_trait_ref);
317+
let input_types = stack.skol_trait_ref.input_types();
318318
if input_types.iter().any(|&t| ty::type_is_skolemized(t)) {
319319
debug!("evaluate_stack_intercrate({}) --> unbound argument, must be ambiguous",
320320
stack.skol_trait_ref.repr(self.tcx()));
@@ -521,7 +521,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
521521
// found in the source. This is because all the
522522
// compiler-provided impls (such as those for unboxed
523523
// closures) do not have relevant coercions. This simplifies
524-
// life immensly.
524+
// life immensely.
525525

526526
let mut impls =
527527
self.assemble_method_candidates_from_impls(rcvr_ty, xform_self_ty, obligation);
@@ -586,7 +586,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
586586
*/
587587

588588
self.infcx.commit_if_ok(|| {
589-
match self.infcx.sub_types(false, infer::Misc(obligation.cause.span),
589+
match self.infcx.sub_types(false, infer::RelateSelfType(obligation.cause.span),
590590
rcvr_ty, xform_self_ty) {
591591
Ok(()) => { }
592592
Err(_) => { return Err(()); }
@@ -850,7 +850,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
850850
// scope. Otherwise, use the generic tcx cache, since the
851851
// result holds across all environments.
852852
if
853-
self.input_types(&**cache_skol_trait_ref).iter().any(
853+
cache_skol_trait_ref.input_types().iter().any(
854854
|&t| ty::type_has_self(t) || ty::type_has_params(t))
855855
{
856856
&self.param_env.selection_cache
@@ -1955,11 +1955,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19551955

19561956
found_skol
19571957
}
1958-
1959-
fn input_types<'a>(&self, trait_ref: &'a ty::TraitRef) -> &'a [ty::t] {
1960-
// Select only the "input types" from a trait-reference.
1961-
trait_ref.substs.types.as_slice()
1962-
}
19631958
}
19641959

19651960
impl Repr for Candidate {

src/librustc/middle/ty.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,14 @@ impl TraitRef {
12541254
pub fn self_ty(&self) -> ty::t {
12551255
self.substs.self_ty().unwrap()
12561256
}
1257+
1258+
pub fn input_types(&self) -> &[ty::t] {
1259+
// Select only the "input types" from a trait-reference. For
1260+
// now this is all the types that appear in the
1261+
// trait-reference, but it should eventually exclude
1262+
// associated types.
1263+
self.substs.types.as_slice()
1264+
}
12571265
}
12581266

12591267
/// When type checking, we use the `ParameterEnvironment` to track

0 commit comments

Comments
 (0)