-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Make processing of entrypoints more efficient #4513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
508959c
Make processing of entrypoints more efficient
udoprog b520907
Abide by minimum Rust requirement
udoprog b593c90
Fix clippy lints
udoprog 61ea5f9
Make sure to test for missing runtime
udoprog 59e648f
Skip over angle brackets and treat last braced block seen as body
udoprog 5369043
rustfmt
udoprog 6122d6d
fix trybuild output
udoprog ce27bec
Trim more stuff from patterns
udoprog 439841d
Bump async-stream dependency to 0.3.2 to avoid minimal-versions issue
udoprog dcc8a7a
Perform return type heuristics to determine when to return and not
udoprog 04e95aa
Actually implement heuristics
udoprog 5824c57
Update tokio-macros/src/select.rs
udoprog b78862f
Improve return heuristics by checking for `where`
udoprog 5c97ae4
Only do find_last_stmt_range for last block found
udoprog 9d83d83
Ensure that skip_angle_brackets skips over composite tokens that cont…
udoprog 27ea4b8
rustfmt
udoprog 7d74def
Fix logic for determining continutations in skip_angle_brackets
udoprog 3de31aa
Ensure we're always reporting some error about failing to process
udoprog d924545
Ensure we always print some error when failing to expand
udoprog fd293b7
Add groups_in_return_position test
udoprog 4e3c5b6
Merge remote-tracking branch 'upstream/master' into entrypoints
udoprog c71a888
Regenerate trybuild with -Dwarnings
udoprog df3cbb6
deny duplicate_macro_attributes
udoprog d48f452
Merge remote-tracking branch 'upstream/master' into entrypoints
udoprog e314165
bump tracing dependency to abide by minimal-versions
udoprog 59d49ff
bump tracing in tokio-util
udoprog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,3 +1,5 @@ | ||
#![deny(duplicate_macro_attributes)] | ||
|
||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
|
This file contains hidden or 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,79 +1,65 @@ | ||
error: the `async` keyword is missing from the function declaration | ||
--> $DIR/macros_invalid_input.rs:4:1 | ||
error: functions marked with `#[tokio::main]` must be `async` | ||
--> tests/fail/macros_invalid_input.rs:6:1 | ||
| | ||
4 | fn main_is_not_async() {} | ||
6 | fn main_is_not_async() {} | ||
| ^^ | ||
|
||
error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> $DIR/macros_invalid_input.rs:6:15 | ||
error: unknown option `foo`, expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> tests/fail/macros_invalid_input.rs:8:15 | ||
| | ||
6 | #[tokio::main(foo)] | ||
8 | #[tokio::main(foo)] | ||
| ^^^ | ||
|
||
error: Must have specified ident | ||
--> $DIR/macros_invalid_input.rs:9:15 | ||
| | ||
9 | #[tokio::main(threadpool::bar)] | ||
| ^^^^^^^^^^^^^^^ | ||
error: unknown option `threadpool`, expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> tests/fail/macros_invalid_input.rs:11:15 | ||
| | ||
11 | #[tokio::main(threadpool::bar)] | ||
| ^^^^^^^^^^ | ||
|
||
error: the `async` keyword is missing from the function declaration | ||
--> $DIR/macros_invalid_input.rs:13:1 | ||
error: functions marked with `#[tokio::test]` must be `async` | ||
--> tests/fail/macros_invalid_input.rs:15:1 | ||
| | ||
13 | fn test_is_not_async() {} | ||
15 | fn test_is_not_async() {} | ||
| ^^ | ||
|
||
error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> $DIR/macros_invalid_input.rs:15:15 | ||
error: unknown option `foo`, expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> tests/fail/macros_invalid_input.rs:17:15 | ||
| | ||
15 | #[tokio::test(foo)] | ||
17 | #[tokio::test(foo)] | ||
| ^^^ | ||
|
||
error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> $DIR/macros_invalid_input.rs:18:15 | ||
error: unknown option `foo`, expected one of: `flavor`, `worker_threads`, `start_paused` | ||
--> tests/fail/macros_invalid_input.rs:20:15 | ||
| | ||
18 | #[tokio::test(foo = 123)] | ||
| ^^^^^^^^^ | ||
20 | #[tokio::test(foo = 123)] | ||
| ^^^ | ||
|
||
error: Failed to parse value of `flavor` as string. | ||
--> $DIR/macros_invalid_input.rs:21:24 | ||
error: no such runtime flavor, the runtime flavors are: "current_thread", "multi_thread" | ||
--> tests/fail/macros_invalid_input.rs:23:24 | ||
| | ||
21 | #[tokio::test(flavor = 123)] | ||
23 | #[tokio::test(flavor = 123)] | ||
| ^^^ | ||
|
||
error: No such runtime flavor `foo`. The runtime flavors are `current_thread` and `multi_thread`. | ||
--> $DIR/macros_invalid_input.rs:24:24 | ||
error: no such runtime flavor, the runtime flavors are: "current_thread", "multi_thread" | ||
--> tests/fail/macros_invalid_input.rs:26:24 | ||
| | ||
24 | #[tokio::test(flavor = "foo")] | ||
26 | #[tokio::test(flavor = "foo")] | ||
| ^^^^^ | ||
|
||
error: The `start_paused` option requires the `current_thread` runtime flavor. Use `#[tokio::test(flavor = "current_thread")]` | ||
--> $DIR/macros_invalid_input.rs:27:55 | ||
error: the `worker_threads` option requires the "multi_thread" runtime flavor. Use `#[tokio::test(flavor = "multi_thread")]` | ||
--> tests/fail/macros_invalid_input.rs:35:59 | ||
| | ||
27 | #[tokio::test(flavor = "multi_thread", start_paused = false)] | ||
| ^^^^^ | ||
|
||
error: Failed to parse value of `worker_threads` as integer. | ||
--> $DIR/macros_invalid_input.rs:30:57 | ||
| | ||
30 | #[tokio::test(flavor = "multi_thread", worker_threads = "foo")] | ||
| ^^^^^ | ||
|
||
error: The `worker_threads` option requires the `multi_thread` runtime flavor. Use `#[tokio::test(flavor = "multi_thread")]` | ||
--> $DIR/macros_invalid_input.rs:33:59 | ||
| | ||
33 | #[tokio::test(flavor = "current_thread", worker_threads = 4)] | ||
35 | #[tokio::test(flavor = "current_thread", worker_threads = 4)] | ||
| ^ | ||
|
||
error: second test attribute is supplied | ||
--> $DIR/macros_invalid_input.rs:37:1 | ||
| | ||
37 | #[test] | ||
| ^^^^^^^ | ||
|
||
error: duplicated attribute | ||
--> $DIR/macros_invalid_input.rs:37:1 | ||
--> tests/fail/macros_invalid_input.rs:39:1 | ||
| | ||
37 | #[test] | ||
39 | #[test] | ||
| ^^^^^^^ | ||
| | ||
= note: `-D duplicate-macro-attributes` implied by `-D warnings` | ||
note: the lint level is defined here | ||
--> tests/fail/macros_invalid_input.rs:1:9 | ||
| | ||
1 | #![deny(duplicate_macro_attributes)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
This file contains hidden or 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 tests_build::tokio; | ||
|
||
// This should parse but fail since default values for const generic parameters | ||
// are experimental. | ||
// | ||
// TODO(udoprog): might want to version constrain this check with `rustversion` | ||
// since this won't always be experimental moving forward (!). | ||
#[tokio::main] | ||
async fn where_clause_const_generics<const T: usize = { 1 + 1 }>() {} | ||
udoprog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
fn main() {} |
This file contains hidden or 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: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions | ||
--> tests/fail/macros_main_generics.rs:9:44 | ||
| | ||
9 | async fn where_clause_const_generics<const T: usize = { 1 + 1 }>() {} | ||
| ^ |
This file contains hidden or 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,6 @@ | ||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
fn test_missing_async() {} | ||
|
||
fn main() {} |
This file contains hidden or 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: functions marked with `#[tokio::main]` must be `async` | ||
--> tests/fail/macros_main_missing_async.rs:4:1 | ||
| | ||
4 | fn test_missing_async() {} | ||
| ^^ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
use tests_build::tokio; | ||
|
||
// This ensures that `'static>>` is not being incorrectly consumed as one | ||
// sequence of joint tokens while parsing the angle bracket group. | ||
#[tokio::main] | ||
async fn ensure_proper_continuation() -> Result<(), Box<dyn std::error::Error + 'static>> { | ||
todo!() | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,36 @@ | ||
use tests_build::tokio; | ||
|
||
use std::fmt::Debug; | ||
|
||
#[tokio::main] | ||
async fn single_parameter<T>() {} | ||
|
||
// This should parse since we treat angle brackets as groups during parsing and | ||
// simply skip over them. | ||
#[tokio::main] | ||
async fn where_clause<T>() | ||
where | ||
T: Iterator, | ||
<T as Iterator>::Item: Debug, | ||
{ | ||
} | ||
|
||
#[tokio::main] | ||
async fn join_bracket_in_return() -> Option<fn() -> ()> { | ||
todo!() | ||
} | ||
|
||
#[tokio::main] | ||
async fn joint_bracket_in_generic<T: Iterator<Item = Option<fn() -> ()>>>(_: T) {} | ||
|
||
struct GroupsInReturnPosition<const N: usize, const U: usize>; | ||
|
||
// Tests both bracket groups `<{inner}>` and braces `{<inner>}` in the return | ||
// position. The latter which should already be skipped over as part of the | ||
// angle bracket processing. | ||
#[tokio::main] | ||
async fn groups_in_return_position() -> GroupsInReturnPosition<1, { 2 + 1 }> { | ||
todo!() | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.