-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(macros/msg): better go-to-definition via RA
Closes #141.
- Loading branch information
Showing
15 changed files
with
174 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[test] | ||
fn ui() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/ui/*.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,11 @@ | ||
use elfo::{messages::Terminate, msg, Envelope}; | ||
|
||
fn test(envelope: Envelope) { | ||
msg!(match envelope { | ||
Terminate => {} | ||
a => {} | ||
b => {} | ||
}); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: this branch will never be matched | ||
--> tests/ui/msg_double_wild.rs:7:9 | ||
| | ||
7 | b => {} | ||
| ^ |
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,15 @@ | ||
use elfo::{msg, Envelope}; | ||
|
||
// TODO: check more invalid patterns. | ||
fn test(envelope: Envelope) { | ||
msg!(match envelope { | ||
foo!() => {} | ||
"liternal" => {} | ||
10..20 => {} | ||
(A | B) => {} | ||
(SomeRequest, token, extra) => {} | ||
(SomeRequest, 20) => {} | ||
}); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error: macros in pattern position are forbidden | ||
--> tests/ui/msg_invalid_pattern.rs:6:9 | ||
| | ||
6 | foo!() => {} | ||
| ^^^ | ||
|
||
error: literal patterns are forbidden | ||
--> tests/ui/msg_invalid_pattern.rs:7:9 | ||
| | ||
7 | "liternal" => {} | ||
| ^^^^^^^^^^ | ||
|
||
error: range patterns are forbidden | ||
--> tests/ui/msg_invalid_pattern.rs:8:9 | ||
| | ||
8 | 10..20 => {} | ||
| ^^ | ||
|
||
error: parenthesized patterns are forbidden | ||
--> tests/ui/msg_invalid_pattern.rs:9:9 | ||
| | ||
9 | (A | B) => {} | ||
| ^^^^^^^ | ||
|
||
error: invalid request pattern | ||
--> tests/ui/msg_invalid_pattern.rs:10:9 | ||
| | ||
10 | (SomeRequest, token, extra) => {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: token must be identifier | ||
--> tests/ui/msg_invalid_pattern.rs:11:9 | ||
| | ||
11 | (SomeRequest, 20) => {} | ||
| ^^^^^^^^^^^^^^^^^ |
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,12 @@ | ||
use elfo::{message, msg, Envelope}; | ||
|
||
#[message(ret = u32)] | ||
struct SomeRequest; | ||
|
||
fn test(envelope: Envelope) { | ||
msg!(match envelope { | ||
SomeRequest => {} | ||
}); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0283]: type annotations needed | ||
--> tests/ui/msg_regular_syntax_for_request.rs:8:9 | ||
| | ||
8 | SomeRequest => {} | ||
| ^^^^^^^^^^^ cannot infer type | ||
| | ||
note: multiple `impl`s satisfying `SomeRequest: MustBeRegularNotRequest<_, Envelope>` found | ||
--> tests/ui/msg_regular_syntax_for_request.rs:7:5 | ||
| | ||
7 | / msg!(match envelope { | ||
8 | | SomeRequest => {} | ||
9 | | }); | ||
| |______^ | ||
= note: this error originates in the macro `msg` (in Nightly builds, run with -Z macro-backtrace for more info) |
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,12 @@ | ||
use elfo::{message, msg, Envelope}; | ||
|
||
#[message] | ||
struct SomeEvent; | ||
|
||
fn test(envelope: Envelope) { | ||
msg!(match envelope { | ||
(SomeEvent, token) => {} | ||
}); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0277]: the trait bound `SomeEvent: elfo::Request` is not satisfied | ||
--> tests/ui/msg_request_syntax_for_regular.rs:8:10 | ||
| | ||
8 | (SomeEvent, token) => {} | ||
| ^^^^^^^^^ the trait `elfo::Request` is not implemented for `SomeEvent` | ||
| | ||
= help: the following other types implement trait `elfo::Request`: | ||
Ping | ||
ReloadConfigs | ||
StartEntrypoint | ||
UpdateConfig | ||
ValidateConfig | ||
note: required by a bound in `must_be_request` | ||
--> tests/ui/msg_request_syntax_for_regular.rs:7:5 | ||
| | ||
7 | / msg!(match envelope { | ||
8 | | (SomeEvent, token) => {} | ||
9 | | }); | ||
| |______^ required by this bound in `must_be_request` | ||
= note: this error originates in the macro `msg` (in Nightly builds, run with -Z macro-backtrace for more info) |
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,12 @@ | ||
use elfo::{message, msg, Envelope}; | ||
|
||
#[message(ret = u32)] | ||
struct SomeRequest; | ||
|
||
fn test(envelope: Envelope) { | ||
msg!(match envelope { | ||
(SomeRequest, _token) => {} | ||
}); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: the token must be used, or call `drop(_)` explicitly | ||
--> tests/ui/msg_unused_token.rs:8:23 | ||
| | ||
8 | (SomeRequest, _token) => {} | ||
| ^^^^^^ |