summaryrefslogtreecommitdiffstats
path: root/src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs')
-rw-r--r--src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs b/src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs
deleted file mode 100644
index 580c85f9b..000000000
--- a/src/test/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// run-pass
-
-#![allow(unused_imports)]
-// This briefly tests the capability of `Cell` and `RefCell` to implement the
-// `Encodable` and `Decodable` traits via `#[derive(Encodable, Decodable)]`
-#![feature(rustc_private)]
-
-extern crate rustc_macros;
-extern crate rustc_serialize;
-
-use rustc_macros::{Decodable, Encodable};
-use rustc_serialize::opaque::{MemDecoder, MemEncoder};
-use rustc_serialize::{Decodable, Encodable, Encoder};
-use std::cell::{Cell, RefCell};
-
-#[derive(Encodable, Decodable)]
-struct A {
- baz: isize,
-}
-
-#[derive(Encodable, Decodable)]
-struct B {
- foo: Cell<bool>,
- bar: RefCell<A>,
-}
-
-fn main() {
- let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) };
-
- let mut encoder = MemEncoder::new();
- obj.encode(&mut encoder);
- let data = encoder.finish();
-
- let mut decoder = MemDecoder::new(&data, 0);
- let obj2 = B::decode(&mut decoder);
-
- assert_eq!(obj.foo.get(), obj2.foo.get());
- assert_eq!(obj.bar.borrow().baz, obj2.bar.borrow().baz);
-}