Skip to content

Commit abfa754

Browse files
committed
Update tests for dropck normalization errors
New test cases are from rust-lang#135039
1 parent e70e3ae commit abfa754

9 files changed

+129
-6
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Test that we don't ICE for a typeck error that only shows up in dropck
2+
// issue #135039
3+
//@ edition:2018
4+
5+
pub trait AuthUser {
6+
type Id;
7+
}
8+
9+
pub trait AuthnBackend {
10+
type User: AuthUser;
11+
}
12+
13+
pub struct AuthSession<Backend: AuthnBackend> {
14+
user: Option<Backend::User>,
15+
data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
16+
}
17+
18+
pub trait Authz: Sized {
19+
type AuthnBackend: AuthnBackend<User = Self>;
20+
}
21+
22+
pub trait Query<User: Authz> {
23+
type Output;
24+
async fn run(&self) -> Result<Self::Output, ()>;
25+
}
26+
27+
pub async fn run_query<User: Authz, Q: Query<User> + 'static>(
28+
auth: AuthSession<User::AuthnBackend>,
29+
//~^ ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
30+
//~| ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
31+
query: Q,
32+
) -> Result<Q::Output, ()> {
33+
let user = auth.user;
34+
query.run().await
35+
}
36+
37+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: the trait bound `User: AuthUser` is not satisfied
2+
--> $DIR/dropck-only-error-async.rs:28:5
3+
|
4+
LL | auth: AuthSession<User::AuthnBackend>,
5+
| ^^^^ the trait `AuthUser` is not implemented for `User`
6+
7+
error[E0277]: the trait bound `User: AuthUser` is not satisfied
8+
--> $DIR/dropck-only-error-async.rs:28:5
9+
|
10+
LL | auth: AuthSession<User::AuthnBackend>,
11+
| ^^^^ the trait `AuthUser` is not implemented for `User`
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0277`.

tests/ui/dropck/dropck-only-error.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Test that we don't ICE for a typeck error that only shows up in dropck
2+
// issue #135039
3+
4+
pub trait AuthUser {
5+
type Id;
6+
}
7+
8+
pub trait AuthnBackend {
9+
type User: AuthUser;
10+
}
11+
12+
pub struct AuthSession<Backend: AuthnBackend> {
13+
data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
14+
}
15+
16+
pub trait Authz: Sized {
17+
type AuthnBackend: AuthnBackend<User = Self>;
18+
}
19+
20+
pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
21+
//~^ ERROR the trait bound `User: AuthUser` is not satisfied [E0277]
22+
23+
fn main() {}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0277]: the trait bound `User: AuthUser` is not satisfied
2+
--> $DIR/dropck-only-error.rs:20:31
3+
|
4+
LL | pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
5+
| ^^^^ the trait `AuthUser` is not implemented for `User`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: the trait bound `(): BaseWithAssoc` is not satisfied
2+
--> $DIR/issue-103899.rs:24:54
3+
|
4+
LL | fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
5+
| ^^^^^^^^^^^^^^^^ the trait `BaseWithAssoc` is not implemented for `()`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/issue-103899.rs:4:1
9+
|
10+
LL | trait BaseWithAssoc {
11+
| ^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: the trait bound `(): BaseWithAssoc` is not satisfied
2+
--> $DIR/issue-103899.rs:24:54
3+
|
4+
LL | fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
5+
| ^^^^^^^^^^^^^^^^ the trait `BaseWithAssoc` is not implemented for `()`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/issue-103899.rs:4:1
9+
|
10+
LL | trait BaseWithAssoc {
11+
| ^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.

tests/ui/typeck/issue-103899.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
//@ revisions: current next
22
//@ ignore-compare-mode-next-solver (explicit revisions)
3-
//@ check-fail
4-
//@ failure-status: 101
5-
//@ dont-check-compiler-stderr
6-
//@ known-bug: #103899
73

84
trait BaseWithAssoc {
95
type Assoc;
@@ -26,6 +22,7 @@ struct DoubleProject<L: WrapperWithAssoc> {
2622
}
2723

2824
fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
25+
//~^ ERROR the trait bound `(): BaseWithAssoc` is not satisfied [E0277]
2926
loop {}
3027
}
3128

tests/ui/wf/hir-wf-check-erase-regions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> {
88
//~^ ERROR `&'a T` is not an iterator
99
type Item = &'a T;
1010

11-
fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator
11+
fn into_iter(self) -> Self::IntoIter {
12+
//~^ ERROR `&'a T` is not an iterator
13+
//~| ERROR `&T` is not an iterator
1214
unimplemented!()
1315
}
1416
}

tests/ui/wf/hir-wf-check-erase-regions.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ LL | fn into_iter(self) -> Self::IntoIter {
3434
note: required by a bound in `Flatten`
3535
--> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL
3636

37-
error: aborting due to 3 previous errors
37+
error[E0277]: `&T` is not an iterator
38+
--> $DIR/hir-wf-check-erase-regions.rs:11:27
39+
|
40+
LL | fn into_iter(self) -> Self::IntoIter {
41+
| ^^^^^^^^^^^^^^ `&T` is not an iterator
42+
|
43+
= help: the trait `Iterator` is not implemented for `&T`
44+
= help: the trait `Iterator` is implemented for `&mut I`
45+
= note: required for `&T` to implement `IntoIterator`
46+
47+
error: aborting due to 4 previous errors
3848

3949
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)