@@ -973,6 +973,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
973
973
locations : Locations ,
974
974
category : ConstraintCategory ,
975
975
) -> Fallible < ( ) > {
976
+ // FIXME(alexreg): see issue #54600.
976
977
if let Err ( terr) = self . sub_types ( sub, sup, locations, category) {
977
978
if let TyKind :: Opaque ( ..) = sup. sty {
978
979
// When you have `let x: impl Foo = ...` in a closure,
@@ -1059,17 +1060,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1059
1060
1060
1061
fn eq_opaque_type_and_type (
1061
1062
& mut self ,
1062
- revealed_ty : Ty < ' tcx > ,
1063
- anon_ty : Ty < ' tcx > ,
1064
- anon_owner_def_id : DefId ,
1063
+ concrete_ty : Ty < ' tcx > ,
1064
+ opaque_ty : Ty < ' tcx > ,
1065
+ parent_def_id : DefId ,
1065
1066
locations : Locations ,
1066
1067
category : ConstraintCategory ,
1067
1068
) -> Fallible < ( ) > {
1068
1069
debug ! (
1069
1070
"eq_opaque_type_and_type( \
1070
- revealed_ty ={:?}, \
1071
- anon_ty ={:?})",
1072
- revealed_ty , anon_ty
1071
+ concrete_ty ={:?}, \
1072
+ opaque_ty ={:?})",
1073
+ concrete_ty , opaque_ty
1073
1074
) ;
1074
1075
let infcx = self . infcx ;
1075
1076
let tcx = infcx. tcx ;
@@ -1085,21 +1086,21 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1085
1086
let dummy_body_id = ObligationCause :: dummy ( ) . body_id ;
1086
1087
let ( output_ty, opaque_type_map) =
1087
1088
obligations. add ( infcx. instantiate_opaque_types (
1088
- anon_owner_def_id ,
1089
+ parent_def_id ,
1089
1090
dummy_body_id,
1090
1091
param_env,
1091
- & anon_ty ,
1092
+ & opaque_ty ,
1092
1093
) ) ;
1093
1094
debug ! (
1094
1095
"eq_opaque_type_and_type: \
1095
1096
instantiated output_ty={:?} \
1096
1097
opaque_type_map={:#?} \
1097
- revealed_ty ={:?}",
1098
- output_ty, opaque_type_map, revealed_ty
1098
+ concrete_ty ={:?}",
1099
+ output_ty, opaque_type_map, concrete_ty
1099
1100
) ;
1100
1101
obligations. add ( infcx
1101
1102
. at ( & ObligationCause :: dummy ( ) , param_env)
1102
- . eq ( output_ty, revealed_ty ) ?) ;
1103
+ . eq ( output_ty, concrete_ty ) ?) ;
1103
1104
1104
1105
for ( & opaque_def_id, opaque_decl) in & opaque_type_map {
1105
1106
let opaque_defn_ty = tcx. type_of ( opaque_def_id) ;
@@ -1524,7 +1525,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1524
1525
}
1525
1526
}
1526
1527
None => {
1527
- // FIXME(canndrew): This is_never should probably be an is_uninhabited
1528
+ // FIXME(canndrew): this ` is_never` should probably be an ` is_uninhabited`.
1528
1529
if !sig. output ( ) . is_never ( ) {
1529
1530
span_mirbug ! ( self , term, "call to converging function {:?} w/o dest" , sig) ;
1530
1531
}
@@ -1910,6 +1911,25 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1910
1911
}
1911
1912
}
1912
1913
1914
+ CastKind :: Hide => {
1915
+ let predicates = match ty. sty {
1916
+ ty:: Opaque ( def_id, substs) => {
1917
+ let bounds = tcx. predicates_of ( def_id) ;
1918
+ let result = bounds. instantiate ( tcx, substs) ;
1919
+ // TODO: do I need to normalize associated types here somehow.
1920
+ // as is done in coercion.rs?
1921
+ result
1922
+ }
1923
+ _ => bug ! ( ) ,
1924
+ } ;
1925
+
1926
+ self . prove_predicates (
1927
+ predicates. predicates ,
1928
+ location. to_locations ( ) ,
1929
+ ConstraintCategory :: Cast ,
1930
+ ) ;
1931
+ }
1932
+
1913
1933
CastKind :: Unsize => {
1914
1934
let & ty = ty;
1915
1935
let trait_ref = ty:: TraitRef {
@@ -1932,7 +1952,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1932
1952
self . add_reborrow_constraint ( location, region, borrowed_place) ;
1933
1953
}
1934
1954
1935
- // FIXME: These other cases have to be implemented in future PRs
1955
+ // FIXME: these other cases have to be implemented in future PRs.
1936
1956
Rvalue :: Use ( ..)
1937
1957
| Rvalue :: Len ( ..)
1938
1958
| Rvalue :: BinaryOp ( ..)
@@ -2164,7 +2184,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
2164
2184
}
2165
2185
2166
2186
// For closures, we have some **extra requirements** we
2167
- //
2168
2187
// have to check. In particular, in their upvars and
2169
2188
// signatures, closures often reference various regions
2170
2189
// from the surrounding function -- we call those the
0 commit comments