about summary refs log tree commit diff
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-09 13:58:53 +1000
committerGitHub <noreply@github.com>2025-08-09 13:58:53 +1000
commit9d989bf1cf7474b9aab4939c3c350246665a7382 (patch)
treed7aeaffd08beadace8dbd0625d5832ad95ed4115 /tests/ui/impl-trait
parentd0ddce85856c8aa61def350989e72b990d03ee6d (diff)
parent4eee55691aeb345cbac0ad558003d5f2ed72b478 (diff)
downloadrust-9d989bf1cf7474b9aab4939c3c350246665a7382.tar.gz
rust-9d989bf1cf7474b9aab4939c3c350246665a7382.zip
Rollup merge of #145115 - lcnr:less-borrowck-tainting, r=compiler-errors
defer opaque type errors, generally greatly reduce tainting

fixes the test for rust-lang/rust#135528, does not actually fix that issue properly.

This is useful as it causes the migration to rust-lang/rust#139587 to be a lot easier.
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/issues/type-error-post-normalization-test.rs24
-rw-r--r--tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr14
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs
new file mode 100644
index 00000000000..0108bb23611
--- /dev/null
+++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs
@@ -0,0 +1,24 @@
+//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
+
+// This previously introduced a `{type_error}`` in the MIR body
+// during the `PostAnalysisNormalize` pass. While the underlying issue
+// #135528 did not get fixed, this reproducer no longer ICEs.
+
+#![feature(type_alias_impl_trait)]
+type Tait = impl Copy;
+
+fn set(x: &isize) -> isize {
+    *x
+}
+
+#[define_opaque(Tait)]
+fn d(x: Tait) {
+    set(x);
+}
+
+#[define_opaque(Tait)]
+fn other_define() -> Tait {
+    () //~^ ERROR concrete type differs from previous defining opaque type use
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr
new file mode 100644
index 00000000000..7d63c1cfbd6
--- /dev/null
+++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+  --> $DIR/type-error-post-normalization-test.rs:20:22
+   |
+LL | fn other_define() -> Tait {
+   |                      ^^^^ expected `&isize`, got `()`
+   |
+note: previous use here
+  --> $DIR/type-error-post-normalization-test.rs:16:9
+   |
+LL |     set(x);
+   |         ^
+
+error: aborting due to 1 previous error
+