]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_typeck/src/check/cast.rs
Rollup merge of #98111 - eggyal:issue-97982, r=GuillaumeGomez
[rust.git] / compiler / rustc_typeck / src / check / cast.rs
index 1248d5c8426ae968893c06d313748923971c8991..81a979865acc3bef7e38809da9397e043c55c4a9 100644 (file)
@@ -41,9 +41,7 @@
 use rustc_middle::ty::cast::{CastKind, CastTy};
 use rustc_middle::ty::error::TypeError;
 use rustc_middle::ty::subst::SubstsRef;
-use rustc_middle::ty::{
-    self, Binder, TraitObjectRepresentation, Ty, TypeAndMut, TypeVisitable, VariantDef,
-};
+use rustc_middle::ty::{self, Binder, Ty, TypeAndMut, TypeVisitable, VariantDef};
 use rustc_session::lint;
 use rustc_session::Session;
 use rustc_span::symbol::sym;
@@ -107,7 +105,7 @@ fn pointer_kind(
 
         Ok(match *t.kind() {
             ty::Slice(_) | ty::Str => Some(PointerKind::Length),
-            ty::Dynamic(ref tty, ..) => Some(PointerKind::VTable(tty.principal_def_id())),
+            ty::Dynamic(ref tty, _, ty::Dyn) => Some(PointerKind::VTable(tty.principal_def_id())),
             ty::Adt(def, substs) if def.is_struct() => match def.non_enum_variant().fields.last() {
                 None => Some(PointerKind::Thin),
                 Some(f) => {
@@ -144,6 +142,7 @@ fn pointer_kind(
             | ty::Generator(..)
             | ty::Adt(..)
             | ty::Never
+            | ty::Dynamic(_, _, ty::DynStar)
             | ty::Error(_) => {
                 let reported = self
                     .tcx
@@ -241,14 +240,14 @@ fn check_dyn_star_cast<'tcx>(
     //
     // this would return `existential_predicates = [?Self: Clone, ?Self: Debug]` and `region = 'static`.
     let (existential_predicates, region) = match cast_ty.kind() {
-        ty::Dynamic(predicates, region, TraitObjectRepresentation::Sized) => (predicates, region),
+        ty::Dynamic(predicates, region, ty::DynStar) => (predicates, region),
         _ => panic!("Invalid dyn* cast_ty"),
     };
 
     let cause = ObligationCause::new(
         expr.span,
         fcx.body_id,
-        // FIXME: Use a better obligation cause code
+        // FIXME(dyn-star): Use a better obligation cause code
         ObligationCauseCode::MiscObligation,
     );
 
@@ -289,7 +288,7 @@ fn new(
         // cases now. We do a more thorough check at the end, once
         // inference is more completely known.
         match cast_ty.kind() {
-            ty::Dynamic(_, _, TraitObjectRepresentation::Unsized) | ty::Slice(..) => {
+            ty::Dynamic(_, _, ty::Dyn) | ty::Slice(..) => {
                 let reported = check.report_cast_to_unsized_type(fcx);
                 Err(reported)
             }
@@ -929,10 +928,10 @@ pub fn do_check(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
 
             (Int(_) | Float, Int(_) | Float) => Ok(CastKind::NumericCast),
 
-            // FIXME: this needs more conditions...
+            // FIXME(dyn-star): this needs more conditions...
             (_, DynStar) => Ok(CastKind::DynStarCast),
 
-            // FIXME: do we want to allow dyn* upcasting or other casts?
+            // FIXME(dyn-star): do we want to allow dyn* upcasting or other casts?
             (DynStar, _) => Err(CastError::IllegalCast),
         }
     }