Skip to content

Commit e9dd810

Browse files
Merge pull request #6964 from practicalswift/gardening-20170121
[gardening] Typos. NULL → nullptr. \t. Incorrect Doxygen. Redundant REQUIRES. Unused diagnostics. PEP-8.
2 parents e4b13d0 + f74763f commit e9dd810

20 files changed

+76
-83
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Swift 3.1
2222

2323
* [SE-0080][]:
2424

25-
Adds a new family of conversion initializers to all numeric types that
26-
either complete successfully without loss of information or return nil.
25+
Adds a new family of conversion initializers to all numeric types that
26+
either complete successfully without loss of information or return nil.
2727

2828
* Swift will now warn when an `NSObject` subclass attempts to override the
2929
class `initialize` method. Swift doesn't guarantee that references to class
@@ -49,7 +49,7 @@ Swift 3.1
4949
the compiler will prevent them from being used in the first place.
5050

5151
* Indirect fields from C structures and unions are now always imported, while
52-
they previously weren't imported if they belonged to an union. This is done by
52+
they previously weren't imported if they belonged to a union. This is done by
5353
naming anonymous fields. For example:
5454

5555
```c
@@ -83,7 +83,7 @@ Swift 3.1
8383

8484
* The `withoutActuallyEscaping` function from [SE-0103][] has been implemented.
8585
To pass off a non-escaping closure to an API that formally takes an
86-
`@escaping` closure, but which is used in a way that will not in fact
86+
`@escaping` closure, but which is used in a way that will not in fact
8787
escape it in practice, use `withoutActuallyEscaping` to get an escapable
8888
copy of the closure and delimit its expected lifetime. For example:
8989

docs/StringManifesto.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ work that could be done in the Swift 4 timeframe.
2727
### Ergonomics
2828

2929
It's worth noting that ergonomics and correctness are mutually-reinforcing. An
30-
API that is easy to usebut incorrectlycannot be considered an ergonomic
30+
API that is easy to use--but incorrectly--cannot be considered an ergonomic
3131
success. Conversely, an API that's simply hard to use is also hard to use
3232
correctly. Achieving optimal performance without compromising ergonomics or
3333
correctness is a greater challenge.
@@ -46,13 +46,13 @@ its overall complexity.
4646

4747
**Method Arity** | **Standard Library** | **Foundation**
4848
---|:---:|:---:
49-
0: `ƒ()` | 5 | 7
50-
1: `ƒ(:)` | 19 | 48
51-
2: `ƒ(::)` | 13 | 19
52-
3: `ƒ(:::)` | 5 | 11
53-
4: `ƒ(::::)` | 1 | 7
54-
5: `ƒ(:::::)` | - | 2
55-
6: `ƒ(::::::)` | - | 1
49+
0: `f()` | 5 | 7
50+
1: `f(:)` | 19 | 48
51+
2: `f(::)` | 13 | 19
52+
3: `f(:::)` | 5 | 11
53+
4: `f(::::)` | 1 | 7
54+
5: `f(:::::)` | - | 2
55+
6: `f(::::::)` | - | 1
5656

5757
**API Kind** | **Standard Library** | **Foundation**
5858
---|:---:|:---:
@@ -100,8 +100,8 @@ constitutes correct behavior in an extremely complex domain, so
100100
Unicode-correctness is, and will remain, a fundamental design principle behind
101101
Swift's `String`. That said, the Unicode standard is an evolving document, so
102102
this objective reference-point is not fixed. <sup id="a1">[1](#f1)</sup> While
103-
many of the most important operationse.g. string hashing, equality, and
104-
non-localized comparison[will be stable](#collation-semantics), the semantics
103+
many of the most important operations--e.g. string hashing, equality, and
104+
non-localized comparison--[will be stable](#collation-semantics), the semantics
105105
of others, such as grapheme breaking and localized comparison and case
106106
conversion, are expected to change as platforms are updated, so programs should
107107
be written so their correctness does not depend on precise stability of these
@@ -188,7 +188,7 @@ pattern matching | locale, case/diacritic/width-insensitivity
188188
The defaults for case-, diacritic-, and width-insensitivity are sometimes different for
189189
localized operations than for non-localized operations, so for example a
190190
localized search should be case-insensitive by default, and a non-localized search
191-
should be case-sensitive by default. We propose a standard language of
191+
should be case-sensitive by default. We propose a standard "language" of
192192
defaulted parameters to be used for these purposes, with usage roughly like this:
193193

194194
```swift
@@ -229,13 +229,13 @@ extension Unicode {
229229

230230
#### Collation Semantics
231231

232-
What Unicode says about collationwhich is used in `<`, `==`, and hashing turns
232+
What Unicode says about collation--which is used in `<`, `==`, and hashing-- turns
233233
out to be quite interesting, once you pick it apart. The full Unicode Collation
234234
Algorithm (UCA) works like this:
235235

236236
1. Fully normalize both strings.
237237
2. Convert each string to a sequence of numeric triples to form a collation key.
238-
3. Flatten the key by concatenating the sequence of first elements to the
238+
3. "Flatten" the key by concatenating the sequence of first elements to the
239239
sequence of second elements to the sequence of third elements.
240240
4. Lexicographically compare the flattened keys.
241241

@@ -249,7 +249,7 @@ lie.
249249
*However*, there are some bright spots to this story. First, as it turns out,
250250
string sorting (localized or not) should be done down to what's called
251251
the
252-
[identical level](http://unicode.org/reports/tr10/#Multi_Level_Comparison),
252+
["identical" level](http://unicode.org/reports/tr10/#Multi_Level_Comparison),
253253
which adds a step 3a: append the string's normalized form to the flattened
254254
collation key. At first blush this just adds work, but consider what it does
255255
for equality: two strings that normalize the same, naturally, will collate the
@@ -261,7 +261,7 @@ entirely skip the expensive part of collation for equality comparison.
261261
Next, naturally, anything that applies to equality also applies to hashing: it
262262
is sufficient to hash the string's normalized form, bypassing collation keys.
263263
This should provide significant speedups over the current implementation.
264-
Perhaps more importantly, since comparison down to the identical level applies
264+
Perhaps more importantly, since comparison down to the "identical" level applies
265265
even to localized strings, it means that hashing and equality can be implemented
266266
exactly the same way for localized and non-localized text, and hash tables with
267267
localized keys will remain valid across current-locale changes.
@@ -279,14 +279,14 @@ implementation has apparently been very well optimized.
279279

280280
Following this scheme everywhere would also allow us to make sorting behavior
281281
consistent across platforms. Currently, we sort `String` according to the UCA,
282-
except that*only on Apple platforms*pairs of ASCII characters are ordered by
282+
except that--*only on Apple platforms*--pairs of ASCII characters are ordered by
283283
unicode scalar value.
284284

285285
#### Syntax
286286

287287
Because the current `Comparable` protocol expresses all comparisons with binary
288-
operators, string comparisonswhich may require
289-
additional [options](#operations-with-options)do not fit smoothly into the
288+
operators, string comparisons--which may require
289+
additional [options](#operations-with-options)--do not fit smoothly into the
290290
existing syntax. At the same time, we'd like to solve other problems with
291291
comparison, as outlined
292292
in
@@ -342,17 +342,17 @@ strings.
342342
This quirk aside, every aspect of strings-as-collections-of-graphemes appears to
343343
comport perfectly with Unicode. We think the concatenation problem is tolerable,
344344
because the cases where it occurs all represent partially-formed constructs. The
345-
largest classisolated combining characters such as ◌́ (U+0301 COMBINING ACUTE
346-
ACCENT)are explicitly called out in the Unicode standard as
347-
[degenerate](http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries) or
348-
[defective](http://www.unicode.org/versions/Unicode9.0.0/ch03.pdf). The other
349-
casessuch as a string ending in a zero-width joiner or half of a regional
350-
indicatorappear to be equally transient and unlikely outside of a text editor.
345+
largest class--isolated combining characters such as ◌́ (U+0301 COMBINING ACUTE
346+
ACCENT)--are explicitly called out in the Unicode standard as
347+
"[degenerate](http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)" or
348+
"[defective](http://www.unicode.org/versions/Unicode9.0.0/ch03.pdf)". The other
349+
cases--such as a string ending in a zero-width joiner or half of a regional
350+
indicator--appear to be equally transient and unlikely outside of a text editor.
351351

352352
Admitting these cases encourages exploration of grapheme composition and is
353-
consistent with what appears to be an overall Unicode philosophy that no
354-
special provisions are made to get marginally better behavior for cases that
355-
never occur in practice. <sup id="a2">[2](#f2)</sup> Furthermore, it seems
353+
consistent with what appears to be an overall Unicode philosophy that "no
354+
special provisions are made to get marginally better behavior for... cases that
355+
never occur in practice." <sup id="a2">[2](#f2)</sup> Furthermore, it seems
356356
unlikely to disturb the semantics of any plausible algorithms. We can handle
357357
these cases by documenting them, explicitly stating that the elements of a
358358
`String` are an emergent property based on Unicode rules.
@@ -402,7 +402,7 @@ The benefits of restoring `Collection` conformance are substantial:
402402
Because of its collection-like behavior, users naturally think of `String`
403403
in collection terms, but run into frustrating limitations where it fails to
404404
conform and are left to wonder where all the differences lie. Many simply
405-
correct this limitation by declaring a trivial conformance:
405+
"correct" this limitation by declaring a trivial conformance:
406406

407407
```swift
408408
extension String : BidirectionalCollection {}
@@ -569,8 +569,8 @@ property) explicitly of type `String`, a type conversion will be performed, and
569569
at this point the substring buffer is copied and the original string's storage
570570
can be released.
571571

572-
A `String` that was not its own `Substring` could be one worda single tagged
573-
pointerwithout requiring additional allocations. `Substring`s would be a view
572+
A `String` that was not its own `Substring` could be one word--a single tagged
573+
pointer--without requiring additional allocations. `Substring`s would be a view
574574
onto a `String`, so are 3 words - pointer to owner, pointer to start, and a
575575
length. The small string optimization for `Substring` would take advantage of
576576
the larger size, probably with a less compressed encoding for speed.
@@ -596,7 +596,7 @@ standard library will traffic in generic models of
596596

597597
In this model, **if a user is unsure about which type to use, `String` is always
598598
a reasonable default**. A `Substring` passed where `String` is expected will be
599-
implicitly copied. When compared to the same type, copied storage model, we
599+
implicitly copied. When compared to the "same type, copied storage" model, we
600600
have effectively deferred the cost of copying from the point where a substring
601601
is created until it must be converted to `String` for use with an API.
602602

@@ -605,11 +605,11 @@ if for performance reasons you are tempted to add a `Range` argument to your
605605
method as well as a `String` to avoid unnecessary copies, you should instead
606606
use `Substring`.
607607

608-
##### The Empty Subscript
608+
##### The "Empty Subscript"
609609

610610
To make it easy to call such an optimized API when you only have a `String` (or
611611
to call any API that takes a `Collection`'s `SubSequence` when all you have is
612-
the `Collection`), we propose the following empty subscript operation,
612+
the `Collection`), we propose the following "empty subscript" operation,
613613

614614
```swift
615615
extension Collection {
@@ -638,7 +638,7 @@ takesAnArrayOfSubstring(arrayOfString.map { $0[] })
638638

639639
As we have seen, all three options above have downsides, but it's possible
640640
these downsides could be eliminated/mitigated by the compiler. We are proposing
641-
one such mitigationimplicit conversionas part of the the "different type,
641+
one such mitigation--implicit conversion--as part of the the "different type,
642642
shared storage" option, to help avoid the cognitive load on developers of
643643
having to deal with a separate `Substring` type.
644644

@@ -743,7 +743,7 @@ let iToJ = Range(nsr, in: s) // Equivalent to i..<j
743743
With `Substring` and `String` being distinct types and sharing almost all
744744
interface and semantics, and with the highest-performance string processing
745745
requiring knowledge of encoding and layout that the currency types can't
746-
provide, it becomes important to capture the common string API in a protocol.
746+
provide, it becomes important to capture the common "string API" in a protocol.
747747
Since Unicode conformance is a key feature of string processing in Swift, we
748748
call that protocol `Unicode`:
749749

@@ -812,8 +812,8 @@ protocols in protocols.
812812
#### Low-Level Textual Analysis
813813

814814
We should provide convenient APIs for processing strings by character. For example,
815-
it should be easy to cleanly express, if this string starts with `"f"`, process
816-
the rest of the string as follows Swift is well-suited to expressing this
815+
it should be easy to cleanly express, "if this string starts with `"f"`, process
816+
the rest of the string as follows..." Swift is well-suited to expressing this
817817
common pattern beautifully, but we need to add the APIs. Here are two examples
818818
of the sort of code that might be possible given such APIs:
819819

@@ -886,8 +886,8 @@ compile-time syntax checking and optimization.
886886

887887
### String Indices
888888

889-
`String` currently has four views`characters`, `unicodeScalars`, `utf8`, and
890-
`utf16`each with its own opaque index type. The APIs used to translate indices
889+
`String` currently has four views--`characters`, `unicodeScalars`, `utf8`, and
890+
`utf16`--each with its own opaque index type. The APIs used to translate indices
891891
between views add needless complexity, and the opacity of indices makes them
892892
difficult to serialize.
893893

@@ -924,7 +924,7 @@ let i = String.Index(codeUnitOffset: offset)
924924
Index interchange between `String` and its `unicodeScalars`, `codeUnits`,
925925
and [`extendedASCII`](#parsing-ascii-structure) views can be made entirely
926926
seamless by having them share an index type (semantics of indexing a `String`
927-
between grapheme cluster boundaries are TBDit can either trap or be forgiving).
927+
between grapheme cluster boundaries are TBD--it can either trap or be forgiving).
928928
Having a common index allows easy traversal into the interior of graphemes,
929929
something that is often needed, without making it likely that someone will do it
930930
by accident.
@@ -1146,7 +1146,7 @@ on the top-level Swift namespace.
11461146

11471147
- The ability to handle `UTF-8`-encoded strings (models of `Unicode`) is not in
11481148
question here; this is about what encodings must be storable, without
1149-
transcoding, in the common currency type called `String`.
1149+
transcoding, in the common currency type called "`String`".
11501150
- ASCII, Latin-1, UCS-2, and UTF-16 are UTF-16 subsets. UTF-8 is not.
11511151
- If we have a way to get at a `String`'s code units, we need a concrete type in
11521152
which to express them in the API of `String`, which is a concrete type
@@ -1161,10 +1161,10 @@ on the top-level Swift namespace.
11611161
### Do we need a type-erasable base protocol for UnicodeEncoding?
11621162

11631163
UnicodeEncoding has an associated type, but it may be important to be able to
1164-
traffic in completely dynamic encoding values, e.g. for tell me the most
1165-
efficient encoding for this string.
1164+
traffic in completely dynamic encoding values, e.g. for "tell me the most
1165+
efficient encoding for this string."
11661166

1167-
### Should there be a string facade?
1167+
### Should there be a string "facade?"
11681168

11691169
One possible design alternative makes `Unicode` a vehicle for expressing
11701170
the storage and encoding of code units, but does not attempt to give it an API
@@ -1204,11 +1204,11 @@ struct String<U: Unicode = StringStorage>
12041204
typealias Substring = String<StringStorage.SubSequence>
12051205
```
12061206

1207-
One advantage of such a design is that naïve users will always extend the right
1208-
type (`String`) without thinking, and the new APIs will show up on `Substring`,
1207+
One advantage of such a design is that naïve users will always extend "the right
1208+
type" (`String`) without thinking, and the new APIs will show up on `Substring`,
12091209
`MyUTF8String`, etc. That said, it also has downsides that should not be
12101210
overlooked, not least of which is the confusability of the meaning of the word
1211-
string. Is it referring to the generic or the concrete type?
1211+
"string." Is it referring to the generic or the concrete type?
12121212

12131213
### `TextOutputStream` and `TextOutputStreamable`
12141214

@@ -1268,8 +1268,8 @@ little benefit. [↩](#a2)
12681268

12691269
<b id="f5">5</b> The queries supported by `NSCharacterSet` map directly onto
12701270
properties in a table that's indexed by unicode scalar value. This table is
1271-
part of the Unicode standard. Some of these queries (e.g., is this an
1272-
uppercase character?) may have fairly obvious generalizations to grapheme
1271+
part of the Unicode standard. Some of these queries (e.g., "is this an
1272+
uppercase character?") may have fairly obvious generalizations to grapheme
12731273
clusters, but exactly how to do it is a research topic and *ideally* we'd either
12741274
establish the existing practice that the Unicode committee would standardize, or
12751275
the Unicode committee would do the research and we'd implement their

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,8 +2348,6 @@ ERROR(generic_type_requires_arguments,none,
23482348
"reference to generic type %0 requires arguments in <...>", (Type))
23492349
NOTE(generic_type_declared_here,none,
23502350
"generic type %0 declared here", (Identifier))
2351-
ERROR(cannot_partially_specialize_generic_function,none,
2352-
"cannot partially specialize a generic function", ())
23532351

23542352
WARNING(use_of_void_pointer,none,
23552353
"Unsafe%0Pointer<Void> has been replaced by Unsafe%0RawPointer", (StringRef))

include/swift/AST/ExprNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define UNCHECKED_EXPR(Id, Parent) EXPR(Id, Parent)
4141
#endif
4242

43-
/// An literal expression node represents a literal value, such as a number,
43+
/// A literal expression node represents a literal value, such as a number,
4444
/// boolean, string, etc.
4545
///
4646
/// By default, these are treated like any other expression.

include/swift/AST/LayoutConstraint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
8-
// See http://swift.org/LICENSE.txt for license information
9-
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212
//

include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ class Parser {
861861
ParserResult<TypeRepr> parseTypeSimple(Diag<> MessageID,
862862
bool HandleCodeCompletion = true);
863863

864-
// \brief Parse layout constraint.
864+
/// \brief Parse layout constraint.
865865
LayoutConstraintInfo parseLayoutConstraint(Identifier LayoutConstraintID);
866866

867867
bool parseGenericArguments(SmallVectorImpl<TypeRepr*> &Args,

lib/AST/LayoutConstraint.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//===- LayoutConstraint.cpp - Layout constraints types and APIs -*- C++ -*-===//
1+
//===--- LayoutConstraint.cpp - Layout constraints types and APIs ---------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
55
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
8-
// See http://swift.org/LICENSE.txt for license information
9-
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212
//

lib/AST/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ namespace {
843843

844844
template <typename T>
845845
struct OperatorLookup {
846-
// Don't fold this into the static_assert: this would trigger an MSVC bug
847-
// that causes the assertion to fail.
846+
// Don't fold this into the static_assert: this would trigger an MSVC bug
847+
// that causes the assertion to fail.
848848
static constexpr T* ptr = static_cast<T*>(nullptr);
849849
static_assert(ptr, "Only usable with operators");
850850
};

lib/SILGen/SILGenBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- SILGenBuilder.h --------------------------------------------------===//
1+
//===--- SILGenBuilder.h ----------------------------------------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//

0 commit comments

Comments
 (0)