-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5538f9e
commit 38cff22
Showing
5 changed files
with
232 additions
and
96 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,32 @@ | ||
mod inner { | ||
use sealed::sealed; | ||
|
||
#[sealed(partial)] | ||
pub trait A { | ||
#[seal(uncallable)] | ||
fn sealed() {} | ||
|
||
fn unsealed(); | ||
} | ||
} | ||
|
||
use inner::A; | ||
|
||
struct B; | ||
|
||
impl A for B { | ||
fn sealed() {} | ||
fn unsealed() {} | ||
} | ||
|
||
struct C; | ||
|
||
impl A for C { | ||
fn sealed(_token: Token) {} | ||
fn unsealed() {} | ||
} | ||
|
||
fn main() { | ||
B::sealed(); | ||
B::unsealed(); | ||
} |
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,38 @@ | ||
error[E0412]: cannot find type `Token` in this scope | ||
--> tests/fail/11-implementing-sealed-function.rs:25:23 | ||
| | ||
25 | fn sealed(_token: Token) {} | ||
| ^^^^^ not found in this scope | ||
| | ||
help: consider importing one of these items | ||
| | ||
13 | use crate::inner::__seal_a::Token; | ||
| | ||
13 | use syn::token::Token; | ||
| | ||
|
||
error[E0050]: method `sealed` has 0 parameters but the declaration in trait `A::sealed` has 1 | ||
--> tests/fail/11-implementing-sealed-function.rs:18:5 | ||
| | ||
4 | #[sealed(partial)] | ||
| ------------------ trait requires 1 parameter | ||
... | ||
18 | fn sealed() {} | ||
| ^^^^^^^^^^^ expected 1 parameter, found 0 | ||
|
||
error[E0061]: this function takes 1 argument but 0 arguments were supplied | ||
--> tests/fail/11-implementing-sealed-function.rs:30:5 | ||
| | ||
30 | B::sealed(); | ||
| ^^^^^^^^^-- supplied 0 arguments | ||
| | | ||
| expected 1 argument | ||
| | ||
note: associated function defined here | ||
--> tests/fail/11-implementing-sealed-function.rs:7:12 | ||
| | ||
4 | / #[sealed(partial)] | ||
5 | | pub trait A { | ||
6 | | #[seal(uncallable)] | ||
7 | | fn sealed() {} | ||
| |____________^^^^^- |
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,25 @@ | ||
mod inner { | ||
use sealed::sealed; | ||
|
||
#[sealed(partial)] | ||
pub trait A { | ||
#[seal(uncallable)] | ||
fn sealed() {} | ||
|
||
fn unsealed(); | ||
} | ||
} | ||
|
||
use inner::A; | ||
|
||
struct B; | ||
|
||
impl A for B { | ||
fn unsealed() {} | ||
} | ||
|
||
fn main() { | ||
B::sealed(); | ||
B::sealed(Token); | ||
B::unsealed(); | ||
} |
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,27 @@ | ||
error[E0425]: cannot find value `Token` in this scope | ||
--> tests/fail/12-calling-sealed-function.rs:23:15 | ||
| | ||
23 | B::sealed(Token); | ||
| ^^^^^ not found in this scope | ||
| | ||
help: consider importing this unit struct | ||
| | ||
13 | use crate::inner::__seal_a::Token; | ||
| | ||
|
||
error[E0061]: this function takes 1 argument but 0 arguments were supplied | ||
--> tests/fail/12-calling-sealed-function.rs:22:5 | ||
| | ||
22 | B::sealed(); | ||
| ^^^^^^^^^-- supplied 0 arguments | ||
| | | ||
| expected 1 argument | ||
| | ||
note: associated function defined here | ||
--> tests/fail/12-calling-sealed-function.rs:7:12 | ||
| | ||
4 | / #[sealed(partial)] | ||
5 | | pub trait A { | ||
6 | | #[seal(uncallable)] | ||
7 | | fn sealed() {} | ||
| |____________^^^^^- |