about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2025-01-31 18:13:02 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2025-02-17 11:33:07 +0000
commit87e5969572ebc0d6b97277d4ad06fa3f5a0b7010 (patch)
tree55f6ec0ae46ca50f3d52eaf30969d0509a101969
parentcde8c6f52bf83f3976302a7f7508c962ed6d15ff (diff)
downloadrust-87e5969572ebc0d6b97277d4ad06fa3f5a0b7010.tar.gz
rust-87e5969572ebc0d6b97277d4ad06fa3f5a0b7010.zip
Update tests for dropck normalization errors
Takes crash tests from #135039, #103899, #91985 and #105299 and turns them into ui tests
-rw-r--r--tests/crashes/103899.rs27
-rw-r--r--tests/crashes/105299.rs19
-rw-r--r--tests/ui/dropck/dropck-only-error-ambiguity.rs23
-rw-r--r--tests/ui/dropck/dropck-only-error-ambiguity.stderr11
-rw-r--r--tests/ui/dropck/dropck-only-error-async.rs (renamed from tests/crashes/135039.rs)13
-rw-r--r--tests/ui/dropck/dropck-only-error-async.stderr15
-rw-r--r--tests/ui/dropck/dropck-only-error-gat.rs (renamed from tests/crashes/91985.rs)9
-rw-r--r--tests/ui/dropck/dropck-only-error-gat.stderr15
-rw-r--r--tests/ui/dropck/dropck-only-error.rs23
-rw-r--r--tests/ui/dropck/dropck-only-error.stderr9
-rw-r--r--tests/ui/typeck/issue-103899.current.stderr15
-rw-r--r--tests/ui/typeck/issue-103899.next.stderr15
-rw-r--r--tests/ui/typeck/issue-103899.rs5
-rw-r--r--tests/ui/wf/hir-wf-check-erase-regions.rs4
-rw-r--r--tests/ui/wf/hir-wf-check-erase-regions.stderr12
15 files changed, 154 insertions, 61 deletions
diff --git a/tests/crashes/103899.rs b/tests/crashes/103899.rs
deleted file mode 100644
index 39c2d72bd35..00000000000
--- a/tests/crashes/103899.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-//@ known-bug: #103899
-
-trait BaseWithAssoc {
-    type Assoc;
-}
-
-trait WrapperWithAssoc {
-    type BaseAssoc: BaseWithAssoc;
-}
-
-struct Wrapper<B> {
-    inner: B,
-}
-
-struct ProjectToBase<T: BaseWithAssoc> {
-    data_type_h: T::Assoc,
-}
-
-struct DoubleProject<L: WrapperWithAssoc> {
-    buffer: Wrapper<ProjectToBase<L::BaseAssoc>>,
-}
-
-fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
-    loop {}
-}
-
-fn main() {}
diff --git a/tests/crashes/105299.rs b/tests/crashes/105299.rs
deleted file mode 100644
index 8e3aafa47bc..00000000000
--- a/tests/crashes/105299.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-//@ known-bug: #105299
-
-pub trait Foo: Clone {}
-
-pub struct Bar<'a, T: Clone> {
-    pub cow: std::borrow::Cow<'a, [T]>,
-
-    pub THIS_CAUSES_ICE: (), // #1
-}
-
-impl<T> Bar<'_, T>
-where
-    T: Clone,
-    [T]: Foo,
-{
-    pub fn MOVES_SELF(self) {} // #2
-}
-
-pub fn main() {}
diff --git a/tests/ui/dropck/dropck-only-error-ambiguity.rs b/tests/ui/dropck/dropck-only-error-ambiguity.rs
new file mode 100644
index 00000000000..ddba2af7070
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error-ambiguity.rs
@@ -0,0 +1,23 @@
+// Test that we don't ICE for a typeck error that only shows up in dropck
+// Version where the normalization error is an ambiguous trait implementation.
+// <[T] as ToOwned>::Owned is ambiguous on whether to use T: Clone or [T]::Clone.
+// Regression test for #105299
+
+pub trait Foo: Clone {}
+
+pub struct Bar<'a, T: Clone> {
+    pub cow: std::borrow::Cow<'a, [T]>,
+
+    pub THIS_CAUSES_ICE: (),
+}
+
+impl<T> Bar<'_, T>
+where
+    T: Clone,
+    [T]: Foo,
+{
+    pub fn MOVES_SELF(self) {}
+    //~^ ERROR type annotations needed
+}
+
+pub fn main() {}
diff --git a/tests/ui/dropck/dropck-only-error-ambiguity.stderr b/tests/ui/dropck/dropck-only-error-ambiguity.stderr
new file mode 100644
index 00000000000..de19bd49f4e
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error-ambiguity.stderr
@@ -0,0 +1,11 @@
+error[E0284]: type annotations needed
+  --> $DIR/dropck-only-error-ambiguity.rs:19:23
+   |
+LL |     pub fn MOVES_SELF(self) {}
+   |                       ^^^^ cannot infer type
+   |
+   = note: cannot satisfy `<[T] as ToOwned>::Owned == _`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0284`.
diff --git a/tests/crashes/135039.rs b/tests/ui/dropck/dropck-only-error-async.rs
index c4c5336fd4f..71158e3c6ef 100644
--- a/tests/crashes/135039.rs
+++ b/tests/ui/dropck/dropck-only-error-async.rs
@@ -1,7 +1,6 @@
-//@ known-bug: #135039
-//@ edition:2021
-
-pub type UserId<Backend> = <<Backend as AuthnBackend>::User as AuthUser>::Id;
+// Test that we don't ICE for a typeck error that only shows up in dropck
+// issue #135039
+//@ edition:2018
 
 pub trait AuthUser {
     type Id;
@@ -13,7 +12,7 @@ pub trait AuthnBackend {
 
 pub struct AuthSession<Backend: AuthnBackend> {
     user: Option<Backend::User>,
-    data: Option<UserId<Backend>>,
+    data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
 }
 
 pub trait Authz: Sized {
@@ -27,8 +26,12 @@ pub trait Query<User: Authz> {
 
 pub async fn run_query<User: Authz, Q: Query<User> + 'static>(
     auth: AuthSession<User::AuthnBackend>,
+    //~^ ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
+    //~| ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
     query: Q,
 ) -> Result<Q::Output, ()> {
     let user = auth.user;
     query.run().await
 }
+
+fn main() {}
diff --git a/tests/ui/dropck/dropck-only-error-async.stderr b/tests/ui/dropck/dropck-only-error-async.stderr
new file mode 100644
index 00000000000..4a069c8ac33
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error-async.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `User: AuthUser` is not satisfied
+  --> $DIR/dropck-only-error-async.rs:28:5
+   |
+LL |     auth: AuthSession<User::AuthnBackend>,
+   |     ^^^^ the trait `AuthUser` is not implemented for `User`
+
+error[E0277]: the trait bound `User: AuthUser` is not satisfied
+  --> $DIR/dropck-only-error-async.rs:28:5
+   |
+LL |     auth: AuthSession<User::AuthnBackend>,
+   |     ^^^^ the trait `AuthUser` is not implemented for `User`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/crashes/91985.rs b/tests/ui/dropck/dropck-only-error-gat.rs
index 338550430e1..dadcf76a43f 100644
--- a/tests/crashes/91985.rs
+++ b/tests/ui/dropck/dropck-only-error-gat.rs
@@ -1,6 +1,6 @@
-//@ known-bug: #91985
-
-#![feature(generic_associated_types)]
+// Test that we don't ICE for a typeck error that only shows up in dropck
+// Version that uses a generic associated type
+// Regression test for #91985
 
 pub trait Trait1 {
     type Associated: Ord;
@@ -22,7 +22,7 @@ impl GatTrait for GatStruct {
 
 pub struct OuterStruct<T1: Trait1, T2: Trait2> {
     inner: InnerStruct<T2, GatStruct>,
-    t1:    T1,
+    t1: T1,
 }
 
 pub struct InnerStruct<T: Trait2, G: GatTrait> {
@@ -35,6 +35,7 @@ where
     T2: Trait2<Associated = T1::Associated>,
 {
     pub fn new() -> Self {
+        //~^ ERROR the trait bound `<T1 as Trait1>::Associated: Clone` is not satisfied
         todo!()
     }
 }
diff --git a/tests/ui/dropck/dropck-only-error-gat.stderr b/tests/ui/dropck/dropck-only-error-gat.stderr
new file mode 100644
index 00000000000..53982c0826a
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error-gat.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `<T1 as Trait1>::Associated: Clone` is not satisfied
+  --> $DIR/dropck-only-error-gat.rs:37:21
+   |
+LL |     pub fn new() -> Self {
+   |                     ^^^^ the trait `Clone` is not implemented for `<T1 as Trait1>::Associated`
+   |
+note: required by a bound in `GatTrait::Gat`
+  --> $DIR/dropck-only-error-gat.rs:14:17
+   |
+LL |     type Gat<T: Clone>;
+   |                 ^^^^^ required by this bound in `GatTrait::Gat`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/dropck/dropck-only-error.rs b/tests/ui/dropck/dropck-only-error.rs
new file mode 100644
index 00000000000..e85eeb82e00
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error.rs
@@ -0,0 +1,23 @@
+// Test that we don't ICE for a typeck error that only shows up in dropck
+// issue #135039
+
+pub trait AuthUser {
+    type Id;
+}
+
+pub trait AuthnBackend {
+    type User: AuthUser;
+}
+
+pub struct AuthSession<Backend: AuthnBackend> {
+    data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
+}
+
+pub trait Authz: Sized {
+    type AuthnBackend: AuthnBackend<User = Self>;
+}
+
+pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
+//~^ ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
+
+fn main() {}
diff --git a/tests/ui/dropck/dropck-only-error.stderr b/tests/ui/dropck/dropck-only-error.stderr
new file mode 100644
index 00000000000..6c7cd5d296c
--- /dev/null
+++ b/tests/ui/dropck/dropck-only-error.stderr
@@ -0,0 +1,9 @@
+error[E0277]: the trait bound `User: AuthUser` is not satisfied
+  --> $DIR/dropck-only-error.rs:20:31
+   |
+LL | pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
+   |                               ^^^^ the trait `AuthUser` is not implemented for `User`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/typeck/issue-103899.current.stderr b/tests/ui/typeck/issue-103899.current.stderr
new file mode 100644
index 00000000000..a3a164907be
--- /dev/null
+++ b/tests/ui/typeck/issue-103899.current.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `(): BaseWithAssoc` is not satisfied
+  --> $DIR/issue-103899.rs:24:54
+   |
+LL | fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
+   |                                                      ^^^^^^^^^^^^^^^^ the trait `BaseWithAssoc` is not implemented for `()`
+   |
+help: this trait has no implementations, consider adding one
+  --> $DIR/issue-103899.rs:4:1
+   |
+LL | trait BaseWithAssoc {
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/typeck/issue-103899.next.stderr b/tests/ui/typeck/issue-103899.next.stderr
new file mode 100644
index 00000000000..a3a164907be
--- /dev/null
+++ b/tests/ui/typeck/issue-103899.next.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `(): BaseWithAssoc` is not satisfied
+  --> $DIR/issue-103899.rs:24:54
+   |
+LL | fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
+   |                                                      ^^^^^^^^^^^^^^^^ the trait `BaseWithAssoc` is not implemented for `()`
+   |
+help: this trait has no implementations, consider adding one
+  --> $DIR/issue-103899.rs:4:1
+   |
+LL | trait BaseWithAssoc {
+   | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/typeck/issue-103899.rs b/tests/ui/typeck/issue-103899.rs
index 81ab92a8994..92356ecf288 100644
--- a/tests/ui/typeck/issue-103899.rs
+++ b/tests/ui/typeck/issue-103899.rs
@@ -1,9 +1,5 @@
 //@ revisions: current next
 //@ ignore-compare-mode-next-solver (explicit revisions)
-//@ check-fail
-//@ failure-status: 101
-//@ dont-check-compiler-stderr
-//@ known-bug: #103899
 
 trait BaseWithAssoc {
     type Assoc;
@@ -26,6 +22,7 @@ struct DoubleProject<L: WrapperWithAssoc> {
 }
 
 fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
+    //~^ ERROR the trait bound `(): BaseWithAssoc` is not satisfied [E0277]
     loop {}
 }
 
diff --git a/tests/ui/wf/hir-wf-check-erase-regions.rs b/tests/ui/wf/hir-wf-check-erase-regions.rs
index 01893044c27..20cc1cfe730 100644
--- a/tests/ui/wf/hir-wf-check-erase-regions.rs
+++ b/tests/ui/wf/hir-wf-check-erase-regions.rs
@@ -8,7 +8,9 @@ impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> {
     //~^ ERROR `&'a T` is not an iterator
     type Item = &'a T;
 
-    fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator
+    fn into_iter(self) -> Self::IntoIter {
+        //~^ ERROR `&'a T` is not an iterator
+        //~| ERROR `&T` is not an iterator
         unimplemented!()
     }
 }
diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr
index 4b696dc1d1d..e4d48bf82c0 100644
--- a/tests/ui/wf/hir-wf-check-erase-regions.stderr
+++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr
@@ -34,6 +34,16 @@ LL |     fn into_iter(self) -> Self::IntoIter {
 note: required by a bound in `Flatten`
   --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL
 
-error: aborting due to 3 previous errors
+error[E0277]: `&T` is not an iterator
+  --> $DIR/hir-wf-check-erase-regions.rs:11:27
+   |
+LL |     fn into_iter(self) -> Self::IntoIter {
+   |                           ^^^^^^^^^^^^^^ `&T` is not an iterator
+   |
+   = help: the trait `Iterator` is not implemented for `&T`
+   = help: the trait `Iterator` is implemented for `&mut I`
+   = note: required for `&T` to implement `IntoIterator`
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0277`.