summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-13 21:58:36 +0200
committerGitHub <noreply@github.com>2023-04-13 21:58:36 +0200
commit232eb698edecb9bc7d5f2bcb9305fdd1291ff63f (patch)
tree4c4ab8c03e108564ef44f8b5e638d3d2e63a7be2 /tests
parentd146211c64de2e2baed7b0347a1f35c278713e31 (diff)
parent1178c49a1bc76c7ca242cede37855cb5468b290c (diff)
downloadrust-232eb698edecb9bc7d5f2bcb9305fdd1291ff63f.tar.gz
rust-232eb698edecb9bc7d5f2bcb9305fdd1291ff63f.zip
Rollup merge of #110193 - compiler-errors:body-owner-issue, r=WaffleLapkin
Check for body owner fallibly in error reporting

Sometimes the "body id" we use for an obligation cause is not actually a body owner, like when we're doing WF checking on items.

Fixes #110157
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/wf/issue-110157.rs12
-rw-r--r--tests/ui/wf/issue-110157.stderr32
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/wf/issue-110157.rs b/tests/ui/wf/issue-110157.rs
new file mode 100644
index 00000000000..43a8ce72ff1
--- /dev/null
+++ b/tests/ui/wf/issue-110157.rs
@@ -0,0 +1,12 @@
+struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>);
+
+impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
+//~^ ERROR type annotations needed
+where
+    F: Fn(&Missing) -> Result<I, ()>,
+    //~^ ERROR cannot find type `Missing` in this scope
+    I: Iterator<Item = Missing>,
+    //~^ ERROR cannot find type `Missing` in this scope
+{}
+
+fn main() {}
diff --git a/tests/ui/wf/issue-110157.stderr b/tests/ui/wf/issue-110157.stderr
new file mode 100644
index 00000000000..91d801e9470
--- /dev/null
+++ b/tests/ui/wf/issue-110157.stderr
@@ -0,0 +1,32 @@
+error[E0412]: cannot find type `Missing` in this scope
+  --> $DIR/issue-110157.rs:6:12
+   |
+LL |     F: Fn(&Missing) -> Result<I, ()>,
+   |            ^^^^^^^ not found in this scope
+
+error[E0412]: cannot find type `Missing` in this scope
+  --> $DIR/issue-110157.rs:8:24
+   |
+LL |     I: Iterator<Item = Missing>,
+   |                        ^^^^^^^ not found in this scope
+
+error[E0283]: type annotations needed
+  --> $DIR/issue-110157.rs:3:31
+   |
+LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
+   |                               ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `I`
+   |
+   = note: cannot satisfy `_: Iterator`
+note: required for `NeedsDropTypes<'tcx, F>` to implement `Iterator`
+  --> $DIR/issue-110157.rs:3:18
+   |
+LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
+   |                  ^^^^^^^^     ^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL |     I: Iterator<Item = Missing>,
+   |        ------------------------ unsatisfied trait bound introduced here
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0283, E0412.
+For more information about an error, try `rustc --explain E0283`.