-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only update/query macros can take guard function (#418)
* fix: only update/query take guard function * trim docs * test * fix doc:wq * bump ver * changelog * fix docs
- Loading branch information
Showing
6 changed files
with
69 additions
and
85 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
22 changes: 22 additions & 0 deletions
22
src/ic-cdk-macros/tests/compile_fail/no_guard_function_for_lifecycle.rs
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,22 @@ | ||
use ic_cdk::{heartbeat, init, inspect_message, post_upgrade, pre_upgrade}; | ||
|
||
fn guard_function() -> Result<(), String> { | ||
unimplemented!() | ||
} | ||
|
||
#[init(guard = "guard_function")] | ||
fn init() {} | ||
|
||
#[pre_upgrade(guard = "guard_function")] | ||
fn pre_upgrade() {} | ||
|
||
#[post_upgrade(guard = "guard_function")] | ||
fn post_upgrade() {} | ||
|
||
#[heartbeat(guard = "guard_function")] | ||
fn heartbeat() {} | ||
|
||
#[inspect_message(guard = "guard_function")] | ||
fn inspect_message() {} | ||
|
||
fn main() {} |
29 changes: 29 additions & 0 deletions
29
src/ic-cdk-macros/tests/compile_fail/no_guard_function_for_lifecycle.stderr
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,29 @@ | ||
error: #[init] cannot have a guard function. | ||
--> tests/compile_fail/no_guard_function_for_lifecycle.rs:7:8 | ||
| | ||
7 | #[init(guard = "guard_function")] | ||
| ^^^^^ | ||
|
||
error: #[pre_upgrade] cannot have a guard function. | ||
--> tests/compile_fail/no_guard_function_for_lifecycle.rs:10:15 | ||
| | ||
10 | #[pre_upgrade(guard = "guard_function")] | ||
| ^^^^^ | ||
|
||
error: #[post_upgrade] cannot have a guard function. | ||
--> tests/compile_fail/no_guard_function_for_lifecycle.rs:13:16 | ||
| | ||
13 | #[post_upgrade(guard = "guard_function")] | ||
| ^^^^^ | ||
|
||
error: #[heartbeat] cannot have a guard function. | ||
--> tests/compile_fail/no_guard_function_for_lifecycle.rs:16:13 | ||
| | ||
16 | #[heartbeat(guard = "guard_function")] | ||
| ^^^^^ | ||
|
||
error: #[inspect_message] cannot have a guard function. | ||
--> tests/compile_fail/no_guard_function_for_lifecycle.rs:19:19 | ||
| | ||
19 | #[inspect_message(guard = "guard_function")] | ||
| ^^^^^ |