Skip to content

Commit

Permalink
fix: Silence expected use after move warnings (#1819)
Browse files Browse the repository at this point in the history
Fixes #1818
  • Loading branch information
godexsoft authored Jan 10, 2025
1 parent c0d5272 commit 91c00e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/unit/util/MoveTrackerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(MoveTrackerTests, SimpleChecks)
EXPECT_FALSE(moveMe.wasMoved());

auto other = std::move(moveMe);
EXPECT_TRUE(moveMe.wasMoved());
EXPECT_TRUE(moveMe.wasMoved()); // NOLINT(bugprone-use-after-move)
EXPECT_FALSE(other.wasMoved());
}

Expand All @@ -46,7 +46,7 @@ TEST(MoveTrackerTests, SupportReuse)

original = std::move(other);
EXPECT_FALSE(original.wasMoved());
EXPECT_TRUE(other.wasMoved());
EXPECT_TRUE(other.wasMoved()); // NOLINT(bugprone-use-after-move)
}

TEST(MoveTrackerTests, SelfMove)
Expand All @@ -62,7 +62,8 @@ TEST(MoveTrackerTests, SelfMoveAfterWasMoved)
auto original = MoveMe();
[[maybe_unused]] auto fake = std::move(original);

// NOLINTNEXTLINE(bugprone-use-after-move)
[&](MoveMe& from) { original = std::move(from); }(original); // avoids the compiler catching self-move

EXPECT_TRUE(original.wasMoved());
EXPECT_TRUE(original.wasMoved()); // NOLINT(bugprone-use-after-move)
}

0 comments on commit 91c00e7

Please sign in to comment.