@@ -2194,25 +2194,23 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
2194
2194
unsigned numDiagnostics =
2195
2195
moveChecker.diagnosticEmitter .getDiagnosticCount ();
2196
2196
2197
- // Before we do anything, run the borrow to destructure transform in case
2198
- // we have a switch_enum user.
2199
- if (!getASTContext ().LangOpts .hasFeature (Feature::BorrowingSwitch)) {
2200
- BorrowToDestructureTransform borrowToDestructure (
2201
- moveChecker.allocator , markedValue, li, moveChecker.diagnosticEmitter ,
2202
- moveChecker.poa );
2203
- if (!borrowToDestructure.transform ()) {
2204
- assert (moveChecker.diagnosticEmitter
2205
- .didEmitCheckerDoesntUnderstandDiagnostic ());
2206
- LLVM_DEBUG (llvm::dbgs ()
2207
- << " Failed to perform borrow to destructure transform!\n " );
2208
- return false ;
2209
- }
2210
- // If we emitted an error diagnostic, do not transform further and instead
2211
- // mark that we emitted an early diagnostic and return true.
2212
- if (numDiagnostics != moveChecker.diagnosticEmitter .getDiagnosticCount ()) {
2213
- LLVM_DEBUG (llvm::dbgs () << " Emitting borrow to destructure error!\n " );
2214
- return true ;
2215
- }
2197
+ // Before we do anything, run the borrow to destructure transform to reduce
2198
+ // copies through borrows.
2199
+ BorrowToDestructureTransform borrowToDestructure (
2200
+ moveChecker.allocator , markedValue, li, moveChecker.diagnosticEmitter ,
2201
+ moveChecker.poa );
2202
+ if (!borrowToDestructure.transform ()) {
2203
+ assert (moveChecker.diagnosticEmitter
2204
+ .didEmitCheckerDoesntUnderstandDiagnostic ());
2205
+ LLVM_DEBUG (llvm::dbgs ()
2206
+ << " Failed to perform borrow to destructure transform!\n " );
2207
+ return false ;
2208
+ }
2209
+ // If we emitted an error diagnostic, do not transform further and instead
2210
+ // mark that we emitted an early diagnostic and return true.
2211
+ if (numDiagnostics != moveChecker.diagnosticEmitter .getDiagnosticCount ()) {
2212
+ LLVM_DEBUG (llvm::dbgs () << " Emitting borrow to destructure error!\n " );
2213
+ return true ;
2216
2214
}
2217
2215
2218
2216
// Now, validate that what we will transform into a take isn't a take that
0 commit comments