about summary refs log tree commit diff
path: root/tests/ui/mir
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-23 20:16:03 +0000
committerbors <bors@rust-lang.org>2025-07-23 20:16:03 +0000
commitace633090349fc5075b5b0d56294de985e7d1191 (patch)
tree2a2779f150b176783ad4d053e4b649cf91a92b1e /tests/ui/mir
parent29a58723b05d004c2e19ddcf2be80d514401f22e (diff)
parentb1d88ba086ee6f34584ed4e8eb09761a03fe249d (diff)
downloadrust-ace633090349fc5075b5b0d56294de985e7d1191.tar.gz
rust-ace633090349fc5075b5b0d56294de985e7d1191.zip
Auto merge of #144233 - cjgillot:unsat-mir, r=oli-obk
Consider parent predicates in ImpossiblePredicates pass.

This pass is double edged. It avoids some ICEs (yay!) but also degrades diagnostics from constant evaluation.

Fixes rust-lang/rust#121363
Fixes rust-lang/rust#131507
Fixes rust-lang/rust#140100
Fixes rust-lang/rust#140365
Diffstat (limited to 'tests/ui/mir')
-rw-r--r--tests/ui/mir/meaningless-bound.rs20
-rw-r--r--tests/ui/mir/meaningless-bound.stderr19
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/mir/meaningless-bound.rs b/tests/ui/mir/meaningless-bound.rs
new file mode 100644
index 00000000000..c9427e7ece5
--- /dev/null
+++ b/tests/ui/mir/meaningless-bound.rs
@@ -0,0 +1,20 @@
+//! Regression test for #140100 and #140365
+//@compile-flags: -C opt-level=1 -Zvalidate-mir
+
+fn a()
+where
+    b: Sized,
+    //~^ ERROR cannot find type `b` in this scope
+{
+    println!()
+}
+
+fn f() -> &'static str
+where
+    Self: Sized,
+    //~^ ERROR cannot find type `Self` in this scope
+{
+    ""
+}
+
+fn main() {}
diff --git a/tests/ui/mir/meaningless-bound.stderr b/tests/ui/mir/meaningless-bound.stderr
new file mode 100644
index 00000000000..dc08def83b6
--- /dev/null
+++ b/tests/ui/mir/meaningless-bound.stderr
@@ -0,0 +1,19 @@
+error[E0412]: cannot find type `b` in this scope
+  --> $DIR/meaningless-bound.rs:6:5
+   |
+LL |     b: Sized,
+   |     ^ not found in this scope
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/meaningless-bound.rs:14:5
+   |
+LL | fn f() -> &'static str
+   |    - `Self` not allowed in a function
+LL | where
+LL |     Self: Sized,
+   |     ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0411, E0412.
+For more information about an error, try `rustc --explain E0411`.