about summary refs log tree commit diff
path: root/tests/ui/trait-bounds
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-08-21 01:12:22 -0400
committerGitHub <noreply@github.com>2025-08-21 01:12:22 -0400
commit0af35f6a3bb60aa4f1348bb6d69d80809ff818f9 (patch)
tree987e325d87eb1151e6d60e09270ae45e0b4e09bc /tests/ui/trait-bounds
parent64c43edffedaee7c06c024ea7fc3f84f73cac81f (diff)
parent27e6726cb82d413f623715dfa099d2b8410e016a (diff)
downloadrust-0af35f6a3bb60aa4f1348bb6d69d80809ff818f9.tar.gz
rust-0af35f6a3bb60aa4f1348bb6d69d80809ff818f9.zip
Rollup merge of #145642 - xizheyin:145611, r=lcnr
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix rust-lang/rust#145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? `````@lcnr`````

cc `````@compiler-errors`````
Diffstat (limited to 'tests/ui/trait-bounds')
-rw-r--r--tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs11
-rw-r--r--tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr20
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs b/tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs
new file mode 100644
index 00000000000..74551ce493f
--- /dev/null
+++ b/tests/ui/trait-bounds/trait-bound-adt-issue-145611.rs
@@ -0,0 +1,11 @@
+// This test is for regression of issue #145611
+// There should not be cycle error in effective_visibilities query.
+
+trait LocalTrait {}
+struct SomeType;
+fn impls_trait<T: LocalTrait>() {}
+fn foo() -> impl Sized {
+    impls_trait::<SomeType>(); //~ ERROR the trait bound `SomeType: LocalTrait` is not satisfied [E0277]
+}
+
+fn main() {}
diff --git a/tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr b/tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr
new file mode 100644
index 00000000000..21a2cce20cb
--- /dev/null
+++ b/tests/ui/trait-bounds/trait-bound-adt-issue-145611.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the trait bound `SomeType: LocalTrait` is not satisfied
+  --> $DIR/trait-bound-adt-issue-145611.rs:8:19
+   |
+LL |     impls_trait::<SomeType>();
+   |                   ^^^^^^^^ the trait `LocalTrait` is not implemented for `SomeType`
+   |
+help: this trait has no implementations, consider adding one
+  --> $DIR/trait-bound-adt-issue-145611.rs:4:1
+   |
+LL | trait LocalTrait {}
+   | ^^^^^^^^^^^^^^^^
+note: required by a bound in `impls_trait`
+  --> $DIR/trait-bound-adt-issue-145611.rs:6:19
+   |
+LL | fn impls_trait<T: LocalTrait>() {}
+   |                   ^^^^^^^^^^ required by this bound in `impls_trait`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.