Fix no-compile base_unittests for base::Pass() -> std::move conversion
BUG=557422
TEST=gn gen out/Release --args="enable_nocompile_tests=true" && ninja -C out/Release base_nocompile_tests
Review URL: https://codereview.chromium.org/1556683003
Cr-Commit-Position: refs/heads/master@{#367467}
CrOS-Libchrome-Original-Commit: a6e26be9e9ddddc988d547a1e95c5952832a9198
diff --git a/base/callback_list_unittest.nc b/base/callback_list_unittest.nc
index 45ac994..ef193f4 100644
--- a/base/callback_list_unittest.nc
+++ b/base/callback_list_unittest.nc
@@ -7,6 +7,8 @@
#include "base/callback_list.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
@@ -24,7 +26,7 @@
public:
FooListener() {}
- void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); }
+ void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = std::move(f); }
scoped_ptr<Foo> foo_;
diff --git a/base/memory/scoped_ptr_unittest.nc b/base/memory/scoped_ptr_unittest.nc
index ebbfdb6..329c976 100644
--- a/base/memory/scoped_ptr_unittest.nc
+++ b/base/memory/scoped_ptr_unittest.nc
@@ -5,8 +5,11 @@
// This is a "No Compile Test" suite.
// http://dev.chromium.org/developers/testing/no-compile-tests
-#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+
+#include <utility>
+
+#include "base/macros.h"
#include "base/memory/ref_counted.h"
namespace {
@@ -25,7 +28,7 @@
#if defined(NCTEST_NO_PASS_DOWNCAST) // [r"fatal error: no viable conversion from returned value of type 'scoped_ptr<\(anonymous namespace\)::Parent, default_delete<\(anonymous namespace\)::Parent>>' to function return type 'scoped_ptr<\(anonymous namespace\)::Child, default_delete<\(anonymous namespace\)::Child>>'"]
scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
- return object.Pass();
+ return object;
}
#elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"fatal error: static_assert failed \"T is a refcounted type and needs a scoped_refptr\""]
@@ -46,7 +49,7 @@
void WontCompile() {
scoped_ptr<int[]> a;
scoped_ptr<int*> b;
- b = a.Pass();
+ b = std::move(a);
}
#elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"fatal error: no viable overloaded '='"]
@@ -54,21 +57,21 @@
void WontCompile() {
scoped_ptr<int*> a;
scoped_ptr<int[]> b;
- b = a.Pass();
+ b = std::move(a);
}
#elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"fatal error: no matching constructor for initialization of 'scoped_ptr<int \*>'"]
void WontCompile() {
scoped_ptr<int[]> a;
- scoped_ptr<int*> b(a.Pass());
+ scoped_ptr<int*> b(std::move(a));
}
#elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"fatal error: no matching constructor for initialization of 'scoped_ptr<int \[\]>'"]
void WontCompile() {
scoped_ptr<int*> a;
- scoped_ptr<int[]> b(a.Pass());
+ scoped_ptr<int[]> b(std::move(a));
}
#elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguous"]