Declaring part of a tuple as nonisolated(unsafe)

I would like to declare one part of a tuple as nonisolated(unsafe) in a global declaration:

let (nonisolated(unsafe) a, b) = ...

a is a regex, b a String. I am using a tuple because this tuple is created by a macro using a single String literal which I would like to avoid repeating, so I do not want to use two declarations.

I cannot use

nonisolated(unsafe) let (a, b) = ...

bebause then I get the warning "'nonisolated(unsafe)' is unnecessary for a constant with 'Sendable' type 'String', consider removing it" (which I cannot even silence because -Xswiftc -print-diagnostic-groups does not give me any "diagnostic group" for this warning and I actually do not think this would be the right way).

I there some clever but clean trick that I can use, or is this just not possible, and if it is not possible, should this be possible?

2 Likes

I found a solution to my case (that is even a bit better, because I do not need to have two names a and b):

struct RegexWith3GroupsAndDescription {
    
    nonisolated(unsafe) let regex: Regex<(Substring, Substring, Substring)>
    let description: String
    
    init(_ regexWithDescription: (regex: Regex<(Substring, Substring, Substring)>, description: String)) {
        self.regex = regexWithDescription.regex
        self.description = regexWithDescription.description
    }
}

nonisolated(unsafe) let a =  (<what above was written at the right side of "=">)

with <what above was written at the right side of "="> replaced accordingly.

But the above question remains still valid, why is it not possible to write let (nonisolated(unsafe) a, b) = ...?