Skip to content

Commit d82f52a

Browse files
authored
fix warnings from API changes (#3736)
motivation: no warnings changes: * mark generateManifest as discardableResult * udpated call-sites of TSC Path contains to isDescendantOfOrEqual(to:)
1 parent d5d3b92 commit d82f52a

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

Sources/Build/ManifestBuilder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class LLBuildManifestBuilder {
4949

5050
// MARK:- Generate Manifest
5151
/// Generate manifest at the given path.
52+
@discardableResult
5253
public func generateManifest(at path: AbsolutePath) throws -> BuildManifest {
5354
manifest.createTarget(TargetKind.main.targetName)
5455
manifest.createTarget(TargetKind.test.targetName)

Sources/Commands/SwiftPackageTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ extension SwiftPackageTool {
779779

780780
try repository.archive(to: destination)
781781

782-
if destination.contains(packageRoot) {
782+
if destination.isDescendantOfOrEqual(to: packageRoot) {
783783
let relativePath = destination.relative(to: packageRoot)
784784
swiftTool.outputStream <<< "Created \(relativePath.pathString)" <<< "\n"
785785
} else {

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public final class PackageBuilder {
546546

547547
let path = packagePath.appending(relativeSubPath)
548548
// Make sure the target is inside the package root.
549-
guard path.contains(packagePath) else {
549+
guard path.isDescendantOfOrEqual(to: packagePath) else {
550550
throw ModuleError.targetOutsidePackage(package: self.manifest.name, target: target.name)
551551
}
552552
if fileSystem.isDirectory(path) {
@@ -797,7 +797,7 @@ public final class PackageBuilder {
797797
// Compute the path to public headers directory.
798798
let publicHeaderComponent = manifestTarget.publicHeadersPath ?? ClangTarget.defaultPublicHeadersComponent
799799
let publicHeadersPath = potentialModule.path.appending(try RelativePath(validating: publicHeaderComponent))
800-
guard publicHeadersPath.contains(potentialModule.path) else {
800+
guard publicHeadersPath.isDescendantOfOrEqual(to: potentialModule.path) else {
801801
throw ModuleError.invalidPublicHeadersDirectory(potentialModule.name)
802802
}
803803

@@ -937,7 +937,7 @@ public final class PackageBuilder {
937937

938938
// Ensure that the search path is contained within the package.
939939
let subpath = try RelativePath(validating: setting.value[0])
940-
guard targetRoot.appending(subpath).contains(packagePath) else {
940+
guard targetRoot.appending(subpath).isDescendantOfOrEqual(to: packagePath) else {
941941
throw ModuleError.invalidHeaderSearchPath(subpath.pathString)
942942
}
943943

@@ -1127,12 +1127,12 @@ public final class PackageBuilder {
11271127
// If the target root's parent directory is inside the package, start
11281128
// search there. Otherwise, we start search from the target root.
11291129
var searchPath = target.sources.root.parentDirectory
1130-
if !searchPath.contains(packagePath) {
1130+
if !searchPath.isDescendantOfOrEqual(to: packagePath) {
11311131
searchPath = target.sources.root
11321132
}
11331133

11341134
while true {
1135-
assert(searchPath.contains(packagePath), "search path \(searchPath) is outside the package \(packagePath)")
1135+
assert(searchPath.isDescendantOfOrEqual(to: packagePath), "search path \(searchPath) is outside the package \(packagePath)")
11361136
// If we have already searched this path, skip.
11371137
if !pathsSearched.contains(searchPath) {
11381138
SwiftTarget.testManifestNames.forEach { name in

Sources/PackageLoading/TargetSourcesBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public struct TargetSourcesBuilder {
191191
// First match any resources explicitly declared in the manifest file.
192192
for declaredResource in target.resources {
193193
let resourcePath = self.targetPath.appending(RelativePath(declaredResource.path))
194-
if path.contains(resourcePath) {
194+
if path.isDescendantOfOrEqual(to: resourcePath) {
195195
if matchedRule.rule != .none {
196196
diags.emit(.error("duplicate resource rule '\(declaredResource.rule)' found for file at '\(path)'"))
197197
}
@@ -202,7 +202,7 @@ public struct TargetSourcesBuilder {
202202
// Match any sources explicitly declared in the manifest file.
203203
if let declaredSources = self.declaredSources {
204204
for sourcePath in declaredSources {
205-
if path.contains(sourcePath) {
205+
if path.isDescendantOfOrEqual(to: sourcePath) {
206206
if matchedRule.rule != .none {
207207
diags.emit(.error("duplicate rule found for file at '\(path)'"))
208208
}

Sources/PackageModel/Target.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public final class ClangTarget: Target {
428428
dependencies: [Target.Dependency] = [],
429429
buildSettings: BuildSettings.AssignmentTable = .init()
430430
) {
431-
assert(includeDir.contains(sources.root), "\(includeDir) should be contained in the source root \(sources.root)")
431+
assert(includeDir.isDescendantOfOrEqual(to: sources.root), "\(includeDir) should be contained in the source root \(sources.root)")
432432
self.isCXX = sources.containsCXXFiles
433433
self.cLanguageStandard = cLanguageStandard
434434
self.cxxLanguageStandard = cxxLanguageStandard

0 commit comments

Comments
 (0)