diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-06-26 14:47:06 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-07-10 15:54:56 +0000 |
commit | 3016c44e535fe134d88c03ec3d61e3066e43180c (patch) | |
tree | ede922bdb7f1124def97b0d8788fafa02c85d98d /gcc/rust/util/rust-optional-test.cc | |
parent | 1fe255e4928dd3a6d1ab574f92d472b1eea894c2 (diff) | |
download | gcc-3016c44e535fe134d88c03ec3d61e3066e43180c.zip gcc-3016c44e535fe134d88c03ec3d61e3066e43180c.tar.gz gcc-3016c44e535fe134d88c03ec3d61e3066e43180c.tar.bz2 |
gccrs: Remove Rust::Optional in favor of tl::optional
gcc/rust/ChangeLog:
* Make-lang.in: Remove rust-optional-test.cc's object file
* ast/rust-macro.h: Remove use of Rust::Optional
* backend/rust-compile-base.cc
(HIRCompileBase::resolve_method_address): Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::check_for_privacy_violation): Likewise.
(PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* checks/errors/rust-feature-gate.cc (FeatureGate::check): Likewise.
* checks/errors/rust-feature.cc (Feature::create): Likewise.
(Feature::as_name): Likewise.
* checks/errors/rust-feature.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* lex/rust-lex.cc (Lexer::Lexer): Likewise.
(Lexer::skip_token): Likewise.
(Lexer::dump_and_skip): Likewise.
* lex/rust-lex.h: Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise.
* rust-lang.cc (run_rust_tests): Likewise.
* rust-session-manager.cc (Session::compile_crate): Likewise.
(TargetOptions::dump_target_options): Likewise.
* rust-session-manager.h (struct TargetOptions): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_module_children): Likewise.
(Mappings::lookup_module_chidren_items): Likewise.
(Mappings::lookup_module_child): Likewise.
(Mappings::lookup_parent_module): Likewise.
* util/rust-hir-map.h (RUST_HIR_MAP_H): Likewise.
* util/rust-optional-test.cc: Removed.
* util/rust-optional.h: Removed.
Diffstat (limited to 'gcc/rust/util/rust-optional-test.cc')
-rw-r--r-- | gcc/rust/util/rust-optional-test.cc | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/gcc/rust/util/rust-optional-test.cc b/gcc/rust/util/rust-optional-test.cc deleted file mode 100644 index 9fbbe7d..0000000 --- a/gcc/rust/util/rust-optional-test.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2020-2023 Free Software Foundation, Inc. - -// This file is part of GCC. - -// GCC is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 3, or (at your option) any later -// version. - -// GCC is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. - -// You should have received a copy of the GNU General Public License -// along with GCC; see the file COPYING3. If not see -// <http://www.gnu.org/licenses/>. - -#include "rust-system.h" -#include "rust-optional.h" -#include "selftest.h" - -#if CHECKING_P - -static void -rust_optional_create () -{ - auto opt = Rust::Optional<int>::some (15); - - ASSERT_TRUE (opt.is_some ()); - ASSERT_EQ (opt.get (), 15); - - Rust::Optional<int> const_opt = Rust::Optional<int>::some (15); - const int &value = const_opt.get (); - - ASSERT_EQ (value, 15); -} - -static void -rust_optional_operators () -{ - auto opt = Rust::Optional<int>::some (15); - - // as bool - ASSERT_TRUE (opt); - - // deref - ASSERT_EQ (*opt, 15); - - class Methodable - { - public: - int method () { return 15; } - }; - - auto m_opt = Rust::Optional<Methodable>::some (Methodable ()); - ASSERT_EQ (m_opt->method (), 15); -} - -static void -rust_optional_take () -{ - auto opt = Rust::Optional<int>::some (15); - auto value = opt.take (); - - ASSERT_EQ (value, 15); - ASSERT_TRUE (opt.is_none ()); -} - -static void -rust_optional_map () -{ - auto opt = Rust::Optional<int>::some (15); - auto twice = opt.map<int> ([] (int value) { return value * 2; }); - - ASSERT_FALSE (opt); - ASSERT_TRUE (twice); - ASSERT_EQ (*twice, 30); -} - -static void -rust_optional_reference () -{ - auto value = std::vector<std::string> (); - value.emplace_back ("rust"); - value.emplace_back ("+"); - value.emplace_back ("gcc"); - value.emplace_back ("="); - value.emplace_back ("<3"); - - auto opt = Rust::Optional<std::vector<std::string> &>::some (value); - - ASSERT_EQ (opt->at (0), "rust"); - ASSERT_EQ (opt->at (2), "gcc"); -} - -#endif /* #if CHECKING_P */ - -void -rust_optional_test () -{ -#if CHECKING_P - rust_optional_create (); - rust_optional_operators (); - rust_optional_take (); - rust_optional_map (); - rust_optional_reference (); - -#endif /* #if CHECKING_P */ -} |