-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile-fail tests for interfaces/impls
Closes #1475
- Loading branch information
Showing
3 changed files
with
29 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
iface bar { fn dup() -> self; fn blah<X>(); } | ||
impl of bar for int { fn dup() -> int { self } fn blah<X>() {} } | ||
impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} } | ||
impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} } | ||
|
||
fn main() { | ||
10.dup::<int>(); //! ERROR does not take type parameters | ||
10.blah::<int, int>(); //! ERROR incorrect number of type parameters | ||
10u.dup(); //! ERROR multiple applicable methods | ||
(10 as bar).dup(); //! ERROR contains a self type | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
iface foo { fn foo(); } | ||
|
||
impl of foo for uint {} //! ERROR missing method `foo` | ||
|
||
impl of foo for uint { fn foo() -> int {} } //! ERROR incompatible type | ||
|
||
impl of int for uint { fn foo() {} } //! ERROR can only implement interface | ||
|
||
fn main() {} |