about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-08-17 20:22:52 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2022-08-17 20:22:52 +0200
commitbe2641a61f2d34fe4f937a49dacfcb82bf0b9075 (patch)
tree8676db11d489dbe535c416319eb62d27b9fe8d8e
parent4b162141631e900f760752eacdd6d5e510ac4e42 (diff)
downloadrust-be2641a61f2d34fe4f937a49dacfcb82bf0b9075.tar.gz
rust-be2641a61f2d34fe4f937a49dacfcb82bf0b9075.zip
Fortify check for const generics.
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index ff81747cafe..5bb02bc246c 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -1453,16 +1453,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                     .enumerate()
                     .skip(1) // Remove `Self` for `ExistentialPredicate`.
                     .map(|(index, arg)| {
-                        if let ty::GenericArgKind::Type(ty) = arg.unpack() {
-                            debug!(?ty);
-                            if ty == dummy_self {
-                                let param = &generics.params[index];
-                                missing_type_params.push(param.name);
-                                return tcx.ty_error().into();
-                            } else if ty.walk().any(|arg| arg == dummy_self.into()) {
-                                references_self = true;
-                                return tcx.ty_error().into();
-                            }
+                        if arg == dummy_self.into() {
+                            let param = &generics.params[index];
+                            missing_type_params.push(param.name);
+                            return tcx.ty_error().into();
+                        } else if arg.walk().any(|arg| arg == dummy_self.into()) {
+                            references_self = true;
+                            return tcx.ty_error().into();
                         }
                         arg
                     })
@@ -1509,10 +1506,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                 // Like for trait refs, verify that `dummy_self` did not leak inside default type
                 // parameters.
                 let references_self = b.projection_ty.substs.iter().skip(1).any(|arg| {
-                    if let ty::GenericArgKind::Type(ty) = arg.unpack() {
-                        if ty == dummy_self || ty.walk().any(|arg| arg == dummy_self.into()) {
-                            return true;
-                        }
+                    if arg.walk().any(|arg| arg == dummy_self.into()) {
+                        return true;
                     }
                     false
                 });
@@ -1524,7 +1519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                         .substs
                         .iter()
                         .map(|arg| {
-                            if let ty::GenericArgKind::Type(_) = arg.unpack() {
+                            if arg.walk().any(|arg| arg == dummy_self.into()) {
                                 return tcx.ty_error().into();
                             }
                             arg