Skip to content

Commit 319da28

Browse files
committed
---
yaml --- r: 183948 b: refs/heads/master c: 74199c2 h: refs/heads/master v: v3
1 parent d222f6d commit 319da28

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d622235b303409016d8b764b4ae7f2098223ce4d
2+
refs/heads/master: 74199c24d0c09d5096eba1c1da7ce2d85a207d4b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77

trunk/src/librustc/middle/infer/bivariate.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//! Applies the "bivariance relationship" to two types and/or regions.
12+
//! If (A,B) are bivariant then either A <: B or B <: A. It occurs
13+
//! when type/lifetime parameters are unconstrained. Usually this is
14+
//! an error, but we permit it in the specific case where a type
15+
//! parameter is constrained in a where-clause via an associated type.
16+
//!
17+
//! There are several ways one could implement bivariance. You could
18+
//! just do nothing at all, for example, or you could fully verify
19+
//! that one of the two subtyping relationships hold. We choose to
20+
//! thread a middle line: we relate types up to regions, but ignore
21+
//! all region relationships.
22+
//!
23+
//! At one point, handling bivariance in this fashion was necessary
24+
//! for inference, but I'm actually not sure if that is true anymore.
25+
//! In particular, it might be enough to say (A,B) are bivariant for
26+
//! all (A,B).
27+
1128
use middle::ty::{BuiltinBounds};
1229
use middle::ty::{self, Ty};
1330
use middle::ty::TyVar;

trunk/src/librustc/middle/infer/sub.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
3939
fn tys_with_variance(&self, v: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
4040
-> cres<'tcx, Ty<'tcx>>
4141
{
42-
// Once we're equating, it doesn't matter what the variance is.
4342
match v {
4443
ty::Invariant => self.equate().tys(a, b),
4544
ty::Covariant => self.tys(a, b),

trunk/src/librustc/middle/traits/select.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
803803
ambiguous: false
804804
};
805805

806-
// Check for the `PhantomFn` trait. This is really just a special annotation that
807-
// *always* be considered to match, no matter what the type parameters etc.
806+
// Check for the `PhantomFn` trait. This is really just a
807+
// special annotation that is *always* considered to match, no
808+
// matter what the type parameters are etc.
808809
if self.tcx().lang_items.phantom_fn() == Some(obligation.predicate.def_id()) {
809810
candidates.vec.push(PhantomFnCandidate);
810811
return Ok(candidates);

0 commit comments

Comments
 (0)