Skip to content

Commit f76d841

Browse files
committed
Rename to Slab
1 parent 515c64f commit f76d841

28 files changed

+201
-370
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3958,7 +3958,7 @@ class GenericTypeParamDecl final
39583958
/// type parameter.
39593959
///
39603960
/// \code
3961-
/// struct Vector<Element, let N: Int>
3961+
/// struct Slab<let count: Int, Element: ~Copyable>
39623962
/// \endcode
39633963
bool isValue() const {
39643964
return getParamKind() == GenericTypeParamKind::Value;

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8176,11 +8176,11 @@ ERROR(invalid_value_for_type_same_type,none,
81768176
"cannot constrain type parameter %0 to be integer %1", (Type, Type))
81778177

81788178
//===----------------------------------------------------------------------===//
8179-
// MARK: Vector
8179+
// MARK: Slab
81808180
//===----------------------------------------------------------------------===//
81818181

8182-
ERROR(vector_literal_incorrect_count,none,
8183-
"expected %0 elements in vector literal, but got %1", (Type, Type))
8182+
ERROR(slab_literal_incorrect_count,none,
8183+
"expected %0 elements in slab literal, but got %1", (Type, Type))
81848184

81858185
//===----------------------------------------------------------------------===//
81868186
// MARK: @abi Attribute

include/swift/AST/KnownStdlibTypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ KNOWN_STDLIB_TYPE_DECL(DecodingError, NominalTypeDecl, 0)
9797

9898
KNOWN_STDLIB_TYPE_DECL(Result, NominalTypeDecl, 2)
9999

100-
KNOWN_STDLIB_TYPE_DECL(Vector, NominalTypeDecl, 2)
100+
KNOWN_STDLIB_TYPE_DECL(Slab, NominalTypeDecl, 2)
101101

102102
#undef KNOWN_STDLIB_TYPE_DECL

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7246,7 +7246,7 @@ class GenericTypeParamType : public SubstitutableType,
72467246
/// Returns \c true if this type parameter is declared as a value.
72477247
///
72487248
/// \code
7249-
/// struct Vector<Element, let N: Int>
7249+
/// struct Slab<let count: Int, Element: ~Copyable>
72507250
/// \endcode
72517251
bool isValue() const {
72527252
return ParamKind == GenericTypeParamKind::Value;

include/swift/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ UPCOMING_FEATURE(GlobalActorIsolatedTypesUsability, 0434, 6)
225225
UPCOMING_FEATURE(ExistentialAny, 335, 7)
226226
UPCOMING_FEATURE(InternalImportsByDefault, 409, 7)
227227
UPCOMING_FEATURE(MemberImportVisibility, 444, 7)
228-
UPCOMING_FEATURE(ImportCArraysAsVectors, 453, 7)
229228

230229
EXPERIMENTAL_FEATURE(StaticAssert, false)
231230
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)

include/swift/Sema/CSFix.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ enum class FixKind : uint8_t {
484484
/// result.
485485
AllowSendingMismatch,
486486

487-
/// Ignore when a 'Vector' literal has mismatched number of elements to the
487+
/// Ignore when a 'Slab' literal has mismatched number of elements to the
488488
/// type it's attempting to bind to.
489-
AllowVectorLiteralCountMismatch,
489+
AllowSlabLiteralCountMismatch,
490490
};
491491

492492
class ConstraintFix {
@@ -3841,12 +3841,12 @@ class IgnoreKeyPathSubscriptIndexMismatch final : public ConstraintFix {
38413841
}
38423842
};
38433843

3844-
class AllowVectorLiteralCountMismatch final : public ConstraintFix {
3844+
class AllowSlabLiteralCountMismatch final : public ConstraintFix {
38453845
Type lhsCount, rhsCount;
38463846

3847-
AllowVectorLiteralCountMismatch(ConstraintSystem &cs, Type lhsCount,
3848-
Type rhsCount, ConstraintLocator *locator)
3849-
: ConstraintFix(cs, FixKind::AllowVectorLiteralCountMismatch, locator),
3847+
AllowSlabLiteralCountMismatch(ConstraintSystem &cs, Type lhsCount,
3848+
Type rhsCount, ConstraintLocator *locator)
3849+
: ConstraintFix(cs, FixKind::AllowSlabLiteralCountMismatch, locator),
38503850
lhsCount(lhsCount), rhsCount(rhsCount) {}
38513851

38523852
public:
@@ -3856,12 +3856,12 @@ class AllowVectorLiteralCountMismatch final : public ConstraintFix {
38563856

38573857
bool diagnose(const Solution &solution, bool asNote = false) const override;
38583858

3859-
static AllowVectorLiteralCountMismatch *
3859+
static AllowSlabLiteralCountMismatch *
38603860
create(ConstraintSystem &cs, Type lhsCount, Type rhsCount,
38613861
ConstraintLocator *locator);
38623862

38633863
static bool classof(const ConstraintFix *fix) {
3864-
return fix->getKind() == FixKind::AllowVectorLiteralCountMismatch;
3864+
return fix->getKind() == FixKind::AllowSlabLiteralCountMismatch;
38653865
}
38663866
};
38673867

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ UNINTERESTING_FEATURE(ExistentialAny)
6969
UNINTERESTING_FEATURE(InferSendableFromCaptures)
7070
UNINTERESTING_FEATURE(ImplicitOpenExistentials)
7171
UNINTERESTING_FEATURE(MemberImportVisibility)
72-
UNINTERESTING_FEATURE(ImportCArraysAsVectors) // fixme?
7372

7473
// ----------------------------------------------------------------------------
7574
// MARK: - Experimental Features

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ Type TypeBase::isArrayType() {
811811
if (isArray())
812812
return boundStruct->getGenericArgs()[0];
813813

814-
if (isVector())
814+
if (isSlab())
815815
return boundStruct->getGenericArgs()[1];
816816
}
817817
return Type();

lib/ClangImporter/ImportType.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ namespace {
634634
}
635635

636636
ImportResult VisitConstantArrayType(const clang::ConstantArrayType *type) {
637+
// FIXME: Map to a real fixed-size Swift array type when we have those.
638+
// Importing as a tuple at least fills the right amount of space, and
639+
// we can cheese static-offset "indexing" using .$n operations.
640+
637641
Type elementType = Impl.importTypeIgnoreIUO(
638642
type->getElementType(), ImportTypeKind::Value, addImportDiagnostic,
639643
AllowNSUIntegerAsInt, Bridgeability::None, ImportTypeAttrs());
@@ -642,25 +646,15 @@ namespace {
642646

643647
auto size = type->getSize().getZExtValue();
644648

645-
if (size == 1)
646-
return elementType;
647-
648-
auto &ctx = elementType->getASTContext();
649-
650-
if (ctx.LangOpts.hasFeature(Feature::ImportCArraysAsVectors)) {
651-
auto vector = cast<StructDecl>(ctx.getVectorDecl());
652-
auto countType = IntegerType::get(std::to_string(size),
653-
/* isNegative */ false, ctx);
654-
return BoundGenericStructType::get(vector, /* parent */ nullptr,
655-
{countType, elementType});
656-
}
657-
658649
// An array of size N is imported as an N-element tuple which
659650
// takes very long to compile. We chose 4096 as the upper limit because
660651
// we don't want to break arrays of size PATH_MAX.
661652
if (size > 4096)
662653
return Type();
663654

655+
if (size == 1)
656+
return elementType;
657+
664658
SmallVector<TupleTypeElt, 8> elts{static_cast<size_t>(size), elementType};
665659
return TupleType::get(elts, elementType->getASTContext());
666660
}

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ ParserStatus Parser::parseGenericArguments(SmallVectorImpl<TypeRepr *> &Args,
716716
// variadic generic types.
717717
if (!startsWithGreater(Tok)) {
718718
while (true) {
719-
// Note: This can be a value type, e.g. 'Vector<3, Int>'.
719+
// Note: This can be a value type, e.g. 'Slab<3, Int>'.
720720
ParserResult<TypeRepr> Ty = parseTypeOrValue(diag::expected_type);
721721
if (Ty.isNull() || Ty.hasCodeCompletion()) {
722722
// Skip until we hit the '>'.

0 commit comments

Comments
 (0)