about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-04-04 10:39:26 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-04-04 10:39:26 +0000
commitb5d96d5ec5388b89c700b4b9e6f7f73afa9cbcb1 (patch)
tree4cc8c9c0da32c8d8930584f0e69a8994c52f6253 /tests
parent35d06f9c747bc791d7d6902248d851da98616a57 (diff)
downloadrust-b5d96d5ec5388b89c700b4b9e6f7f73afa9cbcb1.tar.gz
rust-b5d96d5ec5388b89c700b4b9e6f7f73afa9cbcb1.zip
Move a const-prop-lint specific hack from mir interpret to const-prop-lint and make it fallible
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/mir/issue-109743.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/ui/mir/issue-109743.rs b/tests/ui/mir/issue-109743.rs
new file mode 100644
index 00000000000..73f3405e3ad
--- /dev/null
+++ b/tests/ui/mir/issue-109743.rs
@@ -0,0 +1,51 @@
+// build-pass
+// compile-flags: --crate-type=lib
+
+use std::marker::PhantomData;
+
+pub trait StreamOnce {
+    type Token;
+}
+
+impl StreamOnce for &str {
+    type Token = ();
+}
+
+pub trait Parser<Input: StreamOnce> {
+    type PartialState: Default;
+    fn parse_mode(&self, _state: &Self::PartialState) {}
+    fn parse_mode_impl() {}
+}
+
+pub fn parse_bool<'a>() -> impl Parser<&'a str> {
+    pub struct TokensCmp<C, Input>
+    where
+        Input: StreamOnce,
+    {
+        _cmp: C,
+        _marker: PhantomData<Input>,
+    }
+
+    impl<Input, C> Parser<Input> for TokensCmp<C, Input>
+    where
+        C: FnMut(Input::Token),
+        Input: StreamOnce,
+    {
+        type PartialState = ();
+    }
+
+    TokensCmp { _cmp: |_| (), _marker: PhantomData }
+}
+
+pub struct ParseBool;
+
+impl<'a> Parser<&'a str> for ParseBool
+where
+    &'a str: StreamOnce,
+{
+    type PartialState = ();
+
+    fn parse_mode_impl() {
+        parse_bool().parse_mode(&Default::default())
+    }
+}