summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps/issue-11881.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/ui-fulldeps/issue-11881.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui-fulldeps/issue-11881.rs')
-rw-r--r--tests/ui-fulldeps/issue-11881.rs91
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/ui-fulldeps/issue-11881.rs b/tests/ui-fulldeps/issue-11881.rs
deleted file mode 100644
index f6360db9b..000000000
--- a/tests/ui-fulldeps/issue-11881.rs
+++ /dev/null
@@ -1,91 +0,0 @@
-// run-pass
-
-#![allow(unused_must_use)]
-#![allow(dead_code)]
-#![allow(unused_imports)]
-
-use std::fmt;
-use std::io::prelude::*;
-use std::io::Cursor;
-use std::slice;
-use std::marker::PhantomData;
-
-trait Encoder {
- type Error;
-}
-
-trait Encodable<S: Encoder> {
- fn encode(&self, s: &mut S) -> Result<(), S::Error>;
-}
-
-struct JsonEncoder<'a>(PhantomData<&'a mut ()>);
-
-impl Encoder for JsonEncoder<'_> {
- type Error = ();
-}
-
-struct AsJson<'a, T> {
- inner: &'a T,
-}
-
-impl<'a, T: for<'r> Encodable<JsonEncoder<'r>>> fmt::Display for AsJson<'a, T> {
- /// Encodes a json value into a string
- fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
- Ok(())
- }
-}
-
-fn as_json<T>(t: &T) -> AsJson<'_, T> {
- AsJson { inner: t }
-}
-
-struct OpaqueEncoder(Vec<u8>);
-
-impl Encoder for OpaqueEncoder {
- type Error = ();
-}
-
-
-struct Foo {
- baz: bool,
-}
-
-impl<S: Encoder> Encodable<S> for Foo {
- fn encode(&self, _s: &mut S) -> Result<(), S::Error> {
- Ok(())
- }
-}
-
-struct Bar {
- froboz: usize,
-}
-
-impl<S: Encoder> Encodable<S> for Bar {
- fn encode(&self, _s: &mut S) -> Result<(), S::Error> {
- Ok(())
- }
-}
-
-enum WireProtocol {
- JSON,
- Opaque,
- // ...
-}
-
-fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) {
- write!(wr, "{}", as_json(val));
-}
-
-fn encode_opaque<T: Encodable<OpaqueEncoder>>(val: &T, wr: Vec<u8>) {
- let mut encoder = OpaqueEncoder(wr);
- val.encode(&mut encoder);
-}
-
-pub fn main() {
- let target = Foo { baz: false };
- let proto = WireProtocol::JSON;
- match proto {
- WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())),
- WireProtocol::Opaque => encode_opaque(&target, Vec::new()),
- }
-}