summaryrefslogtreecommitdiffstats
path: root/tests/ui/mir
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/mir')
-rw-r--r--tests/ui/mir/debug-ref-undef.rs57
-rw-r--r--tests/ui/mir/validate/storage-live.stderr1
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/mir/debug-ref-undef.rs b/tests/ui/mir/debug-ref-undef.rs
new file mode 100644
index 000000000..37fd22a9d
--- /dev/null
+++ b/tests/ui/mir/debug-ref-undef.rs
@@ -0,0 +1,57 @@
+// run-pass
+// compile-flags: -g -O -Zmir-opt-level=0 -Zinline-mir=y -Zmir-enable-passes=+ReferencePropagation
+
+#![allow(dead_code)]
+
+use std::marker::PhantomData;
+
+struct RawTable<T> {
+ marker: PhantomData<T>,
+}
+
+impl<T> RawTable<T> {
+ fn iter(&self) -> RawIter<T> {
+ RawIter { marker: PhantomData }
+ }
+}
+
+struct RawIter<T> {
+ marker: PhantomData<T>,
+}
+
+impl<T> Iterator for RawIter<T> {
+ type Item = ();
+ fn next(&mut self) -> Option<()> {
+ None
+ }
+}
+
+struct HashMap<T> {
+ table: RawTable<T>,
+}
+
+struct Iter<T> {
+ inner: RawIter<T>, // Removing this breaks the reproducer
+}
+
+impl<T> IntoIterator for &HashMap<T> {
+ type Item = T;
+ type IntoIter = Iter<T>;
+ fn into_iter(self) -> Iter<T> {
+ Iter { inner: self.table.iter() }
+ }
+}
+
+impl<T> Iterator for Iter<T> {
+ type Item = T;
+ fn next(&mut self) -> Option<T> {
+ None
+ }
+}
+
+pub fn main() {
+ let maybe_hash_set: Option<HashMap<()>> = None;
+ for _ in maybe_hash_set.as_ref().unwrap_or(&HashMap { table: RawTable { marker: PhantomData } })
+ {
+ }
+}
diff --git a/tests/ui/mir/validate/storage-live.stderr b/tests/ui/mir/validate/storage-live.stderr
index 720fb0a90..1037ddc88 100644
--- a/tests/ui/mir/validate/storage-live.stderr
+++ b/tests/ui/mir/validate/storage-live.stderr
@@ -5,6 +5,7 @@ error: internal compiler error: broken MIR in Item(DefId(0:8 ~ storage_live[HASH
LL | StorageLive(a);
| ^^^^^^^^^^^^^^
+aborting due to `-Z treat-err-as-bug=1`
error: the compiler unexpectedly panicked. this is a bug.
query stack during panic: