Skip to content

Commit be2641a

Browse files
committed
Fortify check for const generics.
1 parent 4b16214 commit be2641a

File tree

1 file changed

+10
-15
lines changed
  • compiler/rustc_typeck/src/astconv

1 file changed

+10
-15
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,16 +1453,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14531453
.enumerate()
14541454
.skip(1) // Remove `Self` for `ExistentialPredicate`.
14551455
.map(|(index, arg)| {
1456-
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
1457-
debug!(?ty);
1458-
if ty == dummy_self {
1459-
let param = &generics.params[index];
1460-
missing_type_params.push(param.name);
1461-
return tcx.ty_error().into();
1462-
} else if ty.walk().any(|arg| arg == dummy_self.into()) {
1463-
references_self = true;
1464-
return tcx.ty_error().into();
1465-
}
1456+
if arg == dummy_self.into() {
1457+
let param = &generics.params[index];
1458+
missing_type_params.push(param.name);
1459+
return tcx.ty_error().into();
1460+
} else if arg.walk().any(|arg| arg == dummy_self.into()) {
1461+
references_self = true;
1462+
return tcx.ty_error().into();
14661463
}
14671464
arg
14681465
})
@@ -1509,10 +1506,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15091506
// Like for trait refs, verify that `dummy_self` did not leak inside default type
15101507
// parameters.
15111508
let references_self = b.projection_ty.substs.iter().skip(1).any(|arg| {
1512-
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
1513-
if ty == dummy_self || ty.walk().any(|arg| arg == dummy_self.into()) {
1514-
return true;
1515-
}
1509+
if arg.walk().any(|arg| arg == dummy_self.into()) {
1510+
return true;
15161511
}
15171512
false
15181513
});
@@ -1524,7 +1519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15241519
.substs
15251520
.iter()
15261521
.map(|arg| {
1527-
if let ty::GenericArgKind::Type(_) = arg.unpack() {
1522+
if arg.walk().any(|arg| arg == dummy_self.into()) {
15281523
return tcx.ty_error().into();
15291524
}
15301525
arg

0 commit comments

Comments
 (0)