TypeCheckItem::visit (HIR::StructStruct &struct_decl)
{
auto lifetime_pin = context->push_clean_lifetime_resolver ();
+ auto &mappings = Analysis::Mappings::get ();
std::vector<TyTy::SubstitutionParamMapping> substitutions;
if (struct_decl.has_generics ())
{
TyTy::BaseType *field_type
= TypeCheckType::Resolve (field.get_field_type ());
+ auto infer_type = field_type->contains_infer ();
+ if (infer_type)
+ {
+ rust_error_at (mappings.lookup_location (infer_type->get_ref ()),
+ "the placeholder %<_%> is not allowed within types on "
+ "item signatures for structs");
+ return;
+ }
auto *ty_field
= new TyTy::StructFieldType (field.get_mappings ().get_hirid (),
field.get_field_name ().as_string (),
}
else if (auto arr = x->try_as<const ArrayType> ())
{
- return arr->get_element_type ()->contains_infer ();
+ auto type_infer = (arr->get_element_type ()->contains_infer ());
+ if (type_infer)
+ return type_infer;
+ return arr->get_capacity ()->contains_infer ();
}
else if (auto slice = x->try_as<const SliceType> ())
{
{
return x;
}
+ else if (x->get_kind () == TyTy::TypeKind::CONST)
+ {
+ if (x->as_const_type ()->const_kind () == BaseConstType::Infer)
+ {
+ return x;
+ }
+ }
return nullptr;
}
--- /dev/null
+#![feature(no_core)]
+#![no_core]
+
+struct Test10 {
+ a: _, // { dg-error "the placeholder ... is not allowed within types on item" }
+}
+
+struct Test11 {
+ a: _, // { dg-error "the placeholder ... is not allowed within types on item" }
+ b: i32,
+}
+
+struct Test12 {
+ a: (_, _), // { dg-error "the placeholder ... is not allowed within types on item" }
+}
+
+struct Test13 {
+ a: [_; _], // { dg-error "the placeholder ... is not allowed within types on item" }
+}
+
+struct Test14 {
+ a: [i32; _], // { dg-error "the placeholder ... is not allowed within types on item" }
+}