File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 71a4a661359dbe92493f7321f8b3677dec734df9
2
+ refs/heads/master: 314c011d71c699291361870e13892b4e5867d046
Original file line number Diff line number Diff line change @@ -1947,9 +1947,16 @@ mod unify {
1947
1947
variance : variance ) ->
1948
1948
option:: t < ( ast:: mutability , variance ) > {
1949
1949
1950
- // If you're unifying mutability then the thing inside
1951
- // will be invariant on anything it contains
1952
- let newvariance = variance_transform ( variance, invariant) ;
1950
+ // If you're unifying on something mutable then we have to
1951
+ // be invariant on the inner type
1952
+ let newvariance = alt expected {
1953
+ ast : : mut. {
1954
+ variance_transform ( variance, invariant)
1955
+ }
1956
+ _ {
1957
+ variance_transform( variance, covariant)
1958
+ }
1959
+ } ;
1953
1960
1954
1961
if expected == actual { ret some ( ( expected, newvariance) ) ; }
1955
1962
if variance == covariant {
Original file line number Diff line number Diff line change
1
+ // error-pattern: mismatched types
2
+
3
+ fn main ( ) {
4
+ let v = [ [ 0 ] ] ;
5
+
6
+ // This is ok because the outer vec is covariant with respect
7
+ // to the inner vec. If the outer vec was mutable then we
8
+ // couldn't do this.
9
+ fn f ( & & v: [ [ mutable? int ] ] ) {
10
+ }
11
+
12
+ f ( v) ;
13
+ }
Original file line number Diff line number Diff line change
1
+ // error-pattern: mismatched types
2
+
3
+ fn main ( ) {
4
+ let v = [ [ 0 ] ] ;
5
+
6
+ // This is ok because the outer vec is covariant with respect
7
+ // to the inner vec. If the outer vec was mutable then we
8
+ // couldn't do this.
9
+ fn f ( & & v: [ mutable? [ mutable? int ] ] ) {
10
+ }
11
+
12
+ f ( v) ;
13
+ }
You can’t perform that action at this time.
0 commit comments