-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
when they are written wrongly using an equality constraint
- Loading branch information
Showing
11 changed files
with
181 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,48 @@ | ||
// Test equality constraints on associated types. Check we get an error when an | ||
// equality constraint is used in a qualified path. | ||
// equality constraint is used outside of type parameter declarations | ||
|
||
pub trait Foo { | ||
type A; | ||
fn boo(&self) -> <Self as Foo>::A; | ||
} | ||
|
||
struct Bar; | ||
struct Qux; | ||
|
||
impl Foo for isize { | ||
type A = usize; | ||
fn boo(&self) -> usize { 42 } | ||
} | ||
|
||
fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {} | ||
fn baz<I: Foo>(_x: &<I as Foo<A=Bar>>::A) {} | ||
//~^ ERROR associated type bindings are not allowed here | ||
|
||
|
||
trait Tr1<T1> { | ||
} | ||
|
||
impl Tr1<T1 = String> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 1 generic argument but 0 generic arguments were supplied | ||
} | ||
|
||
trait Tr3<T1, T2, T3> { | ||
} | ||
|
||
// E0229 is emitted only for the first erroneous equality | ||
// constraint (T2) not for any subequent ones (e.g. T3) | ||
impl Tr3<i32, T2 = Qux, T3 = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
|
||
struct Generic<T> { _t: T } | ||
|
||
impl Tr3<i32, Qux, T3 = Generic<i32>> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 2 generic arguments were supplied | ||
} | ||
|
||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,100 @@ | ||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:16:30 | ||
--> $DIR/associated-types-eq-2.rs:17:31 | ||
| | ||
LL | fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {} | ||
| ^^^^^ associated type not allowed here | ||
LL | fn baz<I: Foo>(_x: &<I as Foo<A=Bar>>::A) {} | ||
| ^^^^^ associated type not allowed here | ||
| | ||
help: to use `Bar` as a generic argument specify it directly | ||
| | ||
LL | fn baz<I: Foo>(_x: &<I as Foo<Bar>>::A) {} | ||
| ~~~ | ||
|
||
error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:24:6 | ||
| | ||
LL | impl Tr1<T1 = String> for Bar { | ||
| ^^^ expected 1 generic argument | ||
| | ||
note: trait defined here, with 1 generic parameter: `T1` | ||
--> $DIR/associated-types-eq-2.rs:21:7 | ||
| | ||
LL | trait Tr1<T1> { | ||
| ^^^ -- | ||
help: add missing generic argument | ||
| | ||
LL | impl Tr1<T1, T1 = String> for Bar { | ||
| +++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:24:10 | ||
| | ||
LL | impl Tr1<T1 = String> for Bar { | ||
| ^^^^^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `String` as a generic argument specify it directly | ||
| | ||
LL | impl Tr1<String> for Bar { | ||
| ~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied | ||
--> $DIR/associated-types-eq-2.rs:34:6 | ||
| | ||
LL | impl Tr3<i32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^ --- supplied 1 generic argument | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:29:7 | ||
| | ||
LL | trait Tr3<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<i32, T2, T3, T2 = Qux, T3 = usize> for Bar { | ||
| ++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:34:15 | ||
| | ||
LL | impl Tr3<i32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `Qux` as a generic argument specify it directly | ||
| | ||
LL | impl Tr3<i32, Qux, T3 = usize> for Bar { | ||
| ~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 2 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:42:6 | ||
| | ||
LL | impl Tr3<i32, Qux, T3 = Generic<i32>> for Bar { | ||
| ^^^ --- --- supplied 2 generic arguments | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:29:7 | ||
| | ||
LL | trait Tr3<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic argument | ||
| | ||
LL | impl Tr3<i32, Qux, T3, T3 = Generic<i32>> for Bar { | ||
| ++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:42:20 | ||
| | ||
LL | impl Tr3<i32, Qux, T3 = Generic<i32>> for Bar { | ||
| ^^^^^^^^^^^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `Generic<i32>` as a generic argument specify it directly | ||
| | ||
LL | impl Tr3<i32, Qux, Generic<i32>> for Bar { | ||
| ~~~~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 7 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0229`. | ||
Some errors have detailed explanations: E0107, E0229. | ||
For more information about an error, try `rustc --explain E0107`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters