Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit de10ccd

Browse files
committed
Add some more tests
1 parent d17e651 commit de10ccd

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Check that projections will constrain opaque types while looking for
2+
//! matching impls.
3+
4+
//@ revisions: current next
5+
//@ ignore-compare-mode-next-solver (explicit revisions)
6+
//@[next] compile-flags: -Znext-solver
7+
//@check-pass
8+
9+
#![feature(type_alias_impl_trait)]
10+
11+
struct Foo;
12+
13+
type Bar = impl Sized;
14+
15+
trait Trait<T> {
16+
type Assoc: Default;
17+
}
18+
19+
impl Trait<()> for Foo {
20+
type Assoc = u32;
21+
}
22+
23+
fn bop(_: Bar) {
24+
let x = <Foo as Trait<Bar>>::Assoc::default();
25+
}
26+
27+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>`
2+
--> $DIR/constrain_in_projection2.rs:27:14
3+
|
4+
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
5+
| ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc`
6+
|
7+
note: multiple `impl`s satisfying `Foo: Trait<Bar>` found
8+
--> $DIR/constrain_in_projection2.rs:18:1
9+
|
10+
LL | impl Trait<()> for Foo {
11+
| ^^^^^^^^^^^^^^^^^^^^^^
12+
...
13+
LL | impl Trait<u32> for Foo {
14+
| ^^^^^^^^^^^^^^^^^^^^^^^
15+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0283`.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>`
2+
--> $DIR/constrain_in_projection2.rs:27:14
3+
|
4+
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
5+
| ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc`
6+
|
7+
note: multiple `impl`s satisfying `Foo: Trait<Bar>` found
8+
--> $DIR/constrain_in_projection2.rs:18:1
9+
|
10+
LL | impl Trait<()> for Foo {
11+
| ^^^^^^^^^^^^^^^^^^^^^^
12+
...
13+
LL | impl Trait<u32> for Foo {
14+
| ^^^^^^^^^^^^^^^^^^^^^^^
15+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0283`.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//! Check that projections will constrain opaque types while looking for
2+
//! matching impls and error if ambiguous.
3+
4+
//@ revisions: current next
5+
//@ ignore-compare-mode-next-solver (explicit revisions)
6+
//@[next] compile-flags: -Znext-solver
7+
8+
#![feature(type_alias_impl_trait)]
9+
10+
struct Foo;
11+
12+
type Bar = impl Sized;
13+
14+
trait Trait<T> {
15+
type Assoc: Default;
16+
}
17+
18+
impl Trait<()> for Foo {
19+
type Assoc = u32;
20+
}
21+
22+
impl Trait<u32> for Foo {
23+
type Assoc = u32;
24+
}
25+
26+
fn bop(_: Bar) {
27+
let x = <Foo as Trait<Bar>>::Assoc::default();
28+
//~^ ERROR: cannot satisfy `Foo: Trait<Bar>`
29+
}
30+
31+
fn main() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /