@@ -225,7 +225,7 @@ pub struct OpaqueTyId<I: Interner>(pub I::DefId);
225
225
226
226
impl_debugs ! ( ImplId , ClauseId ) ;
227
227
228
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
228
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
229
229
pub struct Ty < I : Interner > {
230
230
interned : I :: InternedType ,
231
231
}
@@ -819,7 +819,7 @@ impl<T, L> ParameterKind<T, L> {
819
819
}
820
820
}
821
821
822
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
822
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
823
823
pub struct Parameter < I : Interner > {
824
824
interned : I :: InternedParameter ,
825
825
}
@@ -1124,7 +1124,7 @@ impl<I: Interner> QuantifiedWhereClause<I> {
1124
1124
}
1125
1125
}
1126
1126
1127
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1127
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1128
1128
pub struct QuantifiedWhereClauses < I : Interner > {
1129
1129
interned : I :: InternedQuantifiedWhereClauses ,
1130
1130
}
@@ -1142,25 +1142,26 @@ impl<I: Interner> QuantifiedWhereClauses<I> {
1142
1142
interner : & I ,
1143
1143
clauses : impl IntoIterator < Item = impl CastTo < QuantifiedWhereClause < I > > > ,
1144
1144
) -> Self {
1145
- use crate :: cast :: Caster ;
1146
- QuantifiedWhereClauses {
1147
- interned : I :: intern_quantified_where_clauses (
1148
- interner ,
1149
- clauses . into_iter ( ) . casted ( interner) ,
1150
- ) ,
1151
- }
1145
+ Self :: from_fallible (
1146
+ interner ,
1147
+ clauses
1148
+ . into_iter ( )
1149
+ . map ( |p| -> Result < QuantifiedWhereClause < I > , ( ) > { Ok ( p . cast ( interner) ) } ) ,
1150
+ )
1151
+ . unwrap ( )
1152
1152
}
1153
1153
1154
1154
pub fn from_fallible < E > (
1155
1155
interner : & I ,
1156
1156
clauses : impl IntoIterator < Item = Result < impl CastTo < QuantifiedWhereClause < I > > , E > > ,
1157
1157
) -> Result < Self , E > {
1158
1158
use crate :: cast:: Caster ;
1159
- let clauses = clauses
1160
- . into_iter ( )
1161
- . casted ( interner)
1162
- . collect :: < Result < Vec < QuantifiedWhereClause < I > > , _ > > ( ) ?;
1163
- Ok ( Self :: from ( interner, clauses) )
1159
+ Ok ( QuantifiedWhereClauses {
1160
+ interned : I :: intern_quantified_where_clauses (
1161
+ interner,
1162
+ clauses. into_iter ( ) . casted ( interner) ,
1163
+ ) ?,
1164
+ } )
1164
1165
}
1165
1166
1166
1167
pub fn iter ( & self , interner : & I ) -> std:: slice:: Iter < ' _ , QuantifiedWhereClause < I > > {
@@ -1459,7 +1460,7 @@ impl<I: Interner> ProgramClauseData<I> {
1459
1460
}
1460
1461
}
1461
1462
1462
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1463
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1463
1464
pub struct ProgramClause < I : Interner > {
1464
1465
interned : I :: InternedProgramClause ,
1465
1466
}
@@ -1485,7 +1486,7 @@ impl<I: Interner> ProgramClause<I> {
1485
1486
}
1486
1487
}
1487
1488
1488
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1489
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1489
1490
pub struct ProgramClauses < I : Interner > {
1490
1491
interned : I :: InternedProgramClauses ,
1491
1492
}
@@ -1503,22 +1504,23 @@ impl<I: Interner> ProgramClauses<I> {
1503
1504
interner : & I ,
1504
1505
clauses : impl IntoIterator < Item = impl CastTo < ProgramClause < I > > > ,
1505
1506
) -> Self {
1506
- use crate :: cast:: Caster ;
1507
- ProgramClauses {
1508
- interned : I :: intern_program_clauses ( interner, clauses. into_iter ( ) . casted ( interner) ) ,
1509
- }
1507
+ Self :: from_fallible (
1508
+ interner,
1509
+ clauses
1510
+ . into_iter ( )
1511
+ . map ( |p| -> Result < ProgramClause < I > , ( ) > { Ok ( p. cast ( interner) ) } ) ,
1512
+ )
1513
+ . unwrap ( )
1510
1514
}
1511
1515
1512
1516
pub fn from_fallible < E > (
1513
1517
interner : & I ,
1514
1518
clauses : impl IntoIterator < Item = Result < impl CastTo < ProgramClause < I > > , E > > ,
1515
1519
) -> Result < Self , E > {
1516
1520
use crate :: cast:: Caster ;
1517
- let clauses = clauses
1518
- . into_iter ( )
1519
- . casted ( interner)
1520
- . collect :: < Result < Vec < ProgramClause < I > > , _ > > ( ) ?;
1521
- Ok ( Self :: from ( interner, clauses) )
1521
+ Ok ( ProgramClauses {
1522
+ interned : I :: intern_program_clauses ( interner, clauses. into_iter ( ) . casted ( interner) ) ?,
1523
+ } )
1522
1524
}
1523
1525
1524
1526
pub fn iter ( & self , interner : & I ) -> std:: slice:: Iter < ' _ , ProgramClause < I > > {
@@ -1538,7 +1540,7 @@ impl<I: Interner> ProgramClauses<I> {
1538
1540
}
1539
1541
}
1540
1542
1541
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1543
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1542
1544
pub struct ParameterKinds < I : Interner > {
1543
1545
interned : I :: InternedParameterKinds ,
1544
1546
}
@@ -1556,19 +1558,22 @@ impl<I: Interner> ParameterKinds<I> {
1556
1558
interner : & I ,
1557
1559
parameter_kinds : impl IntoIterator < Item = ParameterKind < ( ) > > ,
1558
1560
) -> Self {
1559
- ParameterKinds {
1560
- interned : I :: intern_parameter_kinds ( interner, parameter_kinds. into_iter ( ) ) ,
1561
- }
1561
+ Self :: from_fallible (
1562
+ interner,
1563
+ parameter_kinds
1564
+ . into_iter ( )
1565
+ . map ( |p| -> Result < ParameterKind < ( ) > , ( ) > { Ok ( p) } ) ,
1566
+ )
1567
+ . unwrap ( )
1562
1568
}
1563
1569
1564
1570
pub fn from_fallible < E > (
1565
1571
interner : & I ,
1566
1572
parameter_kinds : impl IntoIterator < Item = Result < ParameterKind < ( ) > , E > > ,
1567
1573
) -> Result < Self , E > {
1568
- let parameter_kinds = parameter_kinds
1569
- . into_iter ( )
1570
- . collect :: < Result < Vec < ParameterKind < ( ) > > , _ > > ( ) ?;
1571
- Ok ( Self :: from ( interner, parameter_kinds) )
1574
+ Ok ( ParameterKinds {
1575
+ interned : I :: intern_parameter_kinds ( interner, parameter_kinds. into_iter ( ) ) ?,
1576
+ } )
1572
1577
}
1573
1578
1574
1579
pub fn iter ( & self , interner : & I ) -> std:: slice:: Iter < ' _ , ParameterKind < ( ) > > {
@@ -1588,7 +1593,7 @@ impl<I: Interner> ParameterKinds<I> {
1588
1593
}
1589
1594
}
1590
1595
1591
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1596
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1592
1597
pub struct CanonicalVarKinds < I : Interner > {
1593
1598
interned : I :: InternedCanonicalVarKinds ,
1594
1599
}
@@ -1606,19 +1611,22 @@ impl<I: Interner> CanonicalVarKinds<I> {
1606
1611
interner : & I ,
1607
1612
parameter_kinds : impl IntoIterator < Item = ParameterKind < UniverseIndex > > ,
1608
1613
) -> Self {
1609
- CanonicalVarKinds {
1610
- interned : I :: intern_canonical_var_kinds ( interner, parameter_kinds. into_iter ( ) ) ,
1611
- }
1614
+ Self :: from_fallible (
1615
+ interner,
1616
+ parameter_kinds
1617
+ . into_iter ( )
1618
+ . map ( |p| -> Result < ParameterKind < UniverseIndex > , ( ) > { Ok ( p) } ) ,
1619
+ )
1620
+ . unwrap ( )
1612
1621
}
1613
1622
1614
1623
pub fn from_fallible < E > (
1615
1624
interner : & I ,
1616
1625
parameter_kinds : impl IntoIterator < Item = Result < ParameterKind < UniverseIndex > , E > > ,
1617
1626
) -> Result < Self , E > {
1618
- let parameter_kinds = parameter_kinds
1619
- . into_iter ( )
1620
- . collect :: < Result < Vec < ParameterKind < UniverseIndex > > , _ > > ( ) ?;
1621
- Ok ( Self :: from ( interner, parameter_kinds) )
1627
+ Ok ( CanonicalVarKinds {
1628
+ interned : I :: intern_canonical_var_kinds ( interner, parameter_kinds. into_iter ( ) ) ?,
1629
+ } )
1622
1630
}
1623
1631
1624
1632
pub fn iter ( & self , interner : & I ) -> std:: slice:: Iter < ' _ , ParameterKind < UniverseIndex > > {
@@ -1704,7 +1712,7 @@ impl<T: HasInterner> UCanonical<T> {
1704
1712
}
1705
1713
}
1706
1714
1707
- #[ derive( Clone , PartialEq , Eq , Hash , HasInterner ) ]
1715
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , HasInterner ) ]
1708
1716
/// A list of goals.
1709
1717
pub struct Goals < I : Interner > {
1710
1718
interned : I :: InternedGoals ,
@@ -1720,22 +1728,23 @@ impl<I: Interner> Goals<I> {
1720
1728
}
1721
1729
1722
1730
pub fn from ( interner : & I , goals : impl IntoIterator < Item = impl CastTo < Goal < I > > > ) -> Self {
1723
- use crate :: cast:: Caster ;
1724
- Goals {
1725
- interned : I :: intern_goals ( interner, goals. into_iter ( ) . casted ( interner) ) ,
1726
- }
1731
+ Self :: from_fallible (
1732
+ interner,
1733
+ goals
1734
+ . into_iter ( )
1735
+ . map ( |p| -> Result < Goal < I > , ( ) > { Ok ( p. cast ( interner) ) } ) ,
1736
+ )
1737
+ . unwrap ( )
1727
1738
}
1728
1739
1729
1740
pub fn from_fallible < E > (
1730
1741
interner : & I ,
1731
1742
goals : impl IntoIterator < Item = Result < impl CastTo < Goal < I > > , E > > ,
1732
1743
) -> Result < Self , E > {
1733
1744
use crate :: cast:: Caster ;
1734
- let goals = goals
1735
- . into_iter ( )
1736
- . casted ( interner)
1737
- . collect :: < Result < Vec < Goal < I > > , _ > > ( ) ?;
1738
- Ok ( Goals :: from ( interner, goals) )
1745
+ Ok ( Goals {
1746
+ interned : I :: intern_goals ( interner, goals. into_iter ( ) . casted ( interner) ) ?,
1747
+ } )
1739
1748
}
1740
1749
1741
1750
pub fn iter ( & self , interner : & I ) -> std:: slice:: Iter < ' _ , Goal < I > > {
@@ -1755,7 +1764,7 @@ impl<I: Interner> Goals<I> {
1755
1764
}
1756
1765
}
1757
1766
1758
- #[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1767
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord , HasInterner ) ]
1759
1768
/// A general goal; this is the full range of questions you can pose to Chalk.
1760
1769
pub struct Goal < I : Interner > {
1761
1770
interned : I :: InternedGoal ,
@@ -1904,7 +1913,7 @@ pub enum Constraint<I: Interner> {
1904
1913
}
1905
1914
1906
1915
/// A mapping of inference variables to instantiations thereof.
1907
- #[ derive( Clone , PartialEq , Eq , Hash , HasInterner ) ]
1916
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , HasInterner ) ]
1908
1917
pub struct Substitution < I : Interner > {
1909
1918
/// Map free variable with given index to the value with the same
1910
1919
/// index. Naturally, the kind of the variable must agree with
0 commit comments