@@ -181,7 +181,6 @@ pub enum ProjectionElem<V: PartialEq> {
181181 } ,
182182 /// "Downcast" to a variant of an enum or a coroutine.
183183 Downcast ( VariantId ) ,
184- OpaqueCast ( std:: convert:: Infallible ) , // TODO remove this
185184}
186185
187186impl < V : PartialEq > ProjectionElem < V > {
@@ -195,7 +194,6 @@ impl<V: PartialEq> ProjectionElem<V> {
195194 }
196195 ProjectionElem :: Subslice { from, to } => ProjectionElem :: Subslice { from, to } ,
197196 ProjectionElem :: Downcast ( variant_id) => ProjectionElem :: Downcast ( variant_id) ,
198- ProjectionElem :: OpaqueCast ( ty) => ProjectionElem :: OpaqueCast ( ty) ,
199197 }
200198 }
201199
@@ -212,7 +210,6 @@ impl<V: PartialEq> ProjectionElem<V> {
212210 }
213211 ProjectionElem :: Subslice { from, to } => ProjectionElem :: Subslice { from, to } ,
214212 ProjectionElem :: Downcast ( variant_id) => ProjectionElem :: Downcast ( variant_id) ,
215- ProjectionElem :: OpaqueCast ( ty) => ProjectionElem :: OpaqueCast ( ty) ,
216213 } )
217214 }
218215}
@@ -1257,7 +1254,7 @@ impl<'db> PlaceTy<'db> {
12571254 . instantiate ( infcx. interner , args)
12581255 . skip_norm_wip ( )
12591256 }
1260- // TODO TyKind::Coroutine...
1257+ // FIXME TyKind::Coroutine...
12611258 _ => panic ! ( "can't downcast non-adt non-coroutine type: {self_ty:?}" ) ,
12621259 }
12631260 } else {
@@ -1272,7 +1269,7 @@ impl<'db> PlaceTy<'db> {
12721269 TyKind :: Closure ( _, args) => {
12731270 args. as_closure ( ) . tupled_upvars_ty ( ) . tuple_fields ( ) [ f. 0 as usize ]
12741271 }
1275- // TODO TyKind::Coroutine / TyKind::CoroutineClosure...
1272+ // FIXME TyKind::Coroutine / TyKind::CoroutineClosure...
12761273 TyKind :: Tuple ( tys) => tys
12771274 . get ( f. 0 as usize )
12781275 . cloned ( )
@@ -1291,7 +1288,7 @@ impl<'db> PlaceTy<'db> {
12911288 ) -> PlaceTy < ' db > {
12921289 self . projection_ty_core (
12931290 infcx. interner ,
1294- & elem,
1291+ elem,
12951292 |ty| {
12961293 if matches ! ( ty. kind( ) , TyKind :: Alias ( ..) ) {
12971294 let mut ocx = ObligationCtxt :: new ( infcx) ;
@@ -1311,16 +1308,13 @@ impl<'db> PlaceTy<'db> {
13111308 /// projects `place_ty` onto `elem`, returning the appropriate
13121309 /// `Ty` or downcast variant corresponding to that projection.
13131310 /// The `handle_field` callback must map a `FieldIndex` to its `Ty`
1314- pub fn projection_ty_core < V : PartialEq > (
1311+ pub fn projection_ty_core < V : PartialEq + :: std :: fmt :: Debug > (
13151312 self ,
13161313 tcx : DbInterner < ' db > ,
13171314 elem : & ProjectionElem < V > ,
13181315 mut structurally_normalize : impl FnMut ( Ty < ' db > ) -> Ty < ' db > ,
13191316 mut handle_field : impl FnMut ( Ty < ' db > , Option < VariantId > , FieldIndex /*, T*/ ) -> Ty < ' db > ,
1320- ) -> PlaceTy < ' db >
1321- where
1322- V : :: std:: fmt:: Debug ,
1323- {
1317+ ) -> PlaceTy < ' db > {
13241318 // we only bail on mir building when there are type mismatches
13251319 // but error types may pop up resulting in us still attempting to build the mir
13261320 // so just propagate the error type
@@ -1330,7 +1324,7 @@ impl<'db> PlaceTy<'db> {
13301324 if self . variant_id . is_some ( ) && !matches ! ( elem, ProjectionElem :: Field ( ..) ) {
13311325 panic ! ( "cannot use non field projection on downcasted place" )
13321326 }
1333- let answer = match * elem {
1327+ match * elem {
13341328 ProjectionElem :: Deref => {
13351329 let ty = structurally_normalize ( self . ty ) . builtin_deref ( true ) . unwrap_or_else ( || {
13361330 panic ! ( "deref projection of non-dereferenceable ty {:?}" , self )
@@ -1355,13 +1349,9 @@ impl<'db> PlaceTy<'db> {
13551349 } )
13561350 }
13571351 ProjectionElem :: Downcast ( index) => PlaceTy { ty : self . ty , variant_id : Some ( index) } ,
1358- ProjectionElem :: Field ( f) => PlaceTy :: from_ty ( handle_field (
1359- structurally_normalize ( self . ty ) ,
1360- self . variant_id . clone ( ) ,
1361- f,
1362- ) ) ,
1363- ProjectionElem :: OpaqueCast ( _ty) => unimplemented ! ( "not emitted, to be removed" ) ,
1364- } ;
1365- answer
1352+ ProjectionElem :: Field ( f) => {
1353+ PlaceTy :: from_ty ( handle_field ( structurally_normalize ( self . ty ) , self . variant_id , f) )
1354+ }
1355+ }
13661356 }
13671357}
0 commit comments