Skip to content

encode ; stmt without expr as StmtKind::Empty - #69506

Merged
bors merged 1 commit into
rust-lang:masterfrom
Centril:stmt-semi-none
Mar 3, 2020
Merged

encode ; stmt without expr as StmtKind::Empty#69506
bors merged 1 commit into
rust-lang:masterfrom
Centril:stmt-semi-none

Conversation

@Centril

@CentrilCentril commented Feb 27, 2020

Copy link
Copy Markdown
Contributor

Instead of encoding ; statements without a an expression as a tuple in AST, encode it as ast::StmtKind::Empty.

r? @petrochenkov

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

Let's see whether this happens to regress perf: @bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion

@bors

bors commented Feb 27, 2020

Copy link
Copy Markdown
Collaborator

⌛ Trying commit fcea184 with merge 1d82a25...

bors added a commit that referenced this pull request Feb 27, 2020
encode `;` stmt without expr as `StmtKind::Semi(None)`
Instead of encoding `;` statements without a an expression as a tuple in AST, we modify `ast::StmtKind::Semi` to accept an `Option<_>` and then encode the `;` with `StmtKind::Semi(None)`.
r? @petrochenkov
@bors

bors commented Feb 27, 2020

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-azure
Build commit: 1d82a25 (1d82a2587146bc8a4282105545cd257ba2e3647b)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 1d82a25 with parent 0c15adc, future comparison URL.

@Centril

Copy link
Copy Markdown
ContributorAuthor

Seems like this resulted in a perf win rather than a regression, ostensibly because we avoid span_to_snippet.

@petrochenkov

Copy link
Copy Markdown
Contributor

Let's make it a separate StmtKind instead.

The semicolon statement is subtly different from EXPR;, i.e. in the next example

macro_rules! empty {() => {}}fnfoo() -> u8{{0}empty!();}

empty!(); expands into a semicolon statement in the token-based expansion model (#61733), but { 0 } is still treated as a trailing return statement in this case.

The PR that turned redundant semicolons into statements in AST for diagnostics walked some dangerous road, I really hope it didn't introduce anything incompatible with the macro expansion plans.

Comment threadsrc/test/ui/consts/const_let_eq.rs Outdated
@petrochenkovpetrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 29, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

Let's make it a separate StmtKind instead.

Hmm... Do you have any naming suggestions?

@petrochenkov

Copy link
Copy Markdown
Contributor

I really hope it didn't introduce anything incompatible with the macro expansion plans.

It actually regressed some things, but it looks like it's possible to fix them backward-compatibly.

macro_rules! empty {() => {}}fnfoo() -> u8{{0}empty!();;// Works on 1.38, error on 1.39}

@petrochenkov

Copy link
Copy Markdown
Contributor

Hmm... Do you have any naming suggestions?

Well.
StmtKind::Empty?

In C++ it's officially known as null statement, but I can't say I like that naming.

@Centril

Copy link
Copy Markdown
ContributorAuthor

::Empty works for me; the other idea I had was ::Semi + ::SemiExpr(..) but ::Empty feels less like talking about lexical syntax, so it's nicer.

@CentrilCentril changed the title encode ; stmt without expr as StmtKind::Semi(None)encode ; stmt without expr as StmtKind::EmptyFeb 29, 2020
@CentrilCentril added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 29, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

Changed to ::Empty and fixed the lint naming.

Comment threadsrc/librustc_ast_lowering/lib.rs Outdated
Comment threadsrc/test/ui/consts/const_let_eq.rs Outdated
@petrochenkovpetrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 29, 2020
Comment threadsrc/librustc_ast_lowering/expr.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

r=me with the remaining nit addressed.

@Centril

Copy link
Copy Markdown
ContributorAuthor

@bors r=petrochenkov

@bors

bors commented Feb 29, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 6a5de134879c7781a713d9b0d23a22aa5fdd5131 has been approved by petrochenkov

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 29, 2020
@bors

This comment has been minimized.

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 1, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

@bors r=petrochenkov

@bors

bors commented Mar 1, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 176fe3f has been approved by petrochenkov

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2020
@bors

bors commented Mar 3, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 176fe3f with merge 4ad6248...

@bors

bors commented Mar 3, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure
Approved by: petrochenkov
Pushing 4ad6248 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Mar 3, 2020
@bors
bors merged commit 4ad6248 into rust-lang:masterMar 3, 2020
@rust-highfive

Copy link
Copy Markdown
Contributor

📣 Toolstate changed by #69506!

Tested on commit 4ad6248.
Direct link to PR: #69506

💔 clippy-driver on windows: test-pass → test-fail (cc @mcarton@oli-obk@Manishearth@flip1995@yaahc@phansch@llogiq).
💔 clippy-driver on linux: test-pass → test-fail (cc @mcarton@oli-obk@Manishearth@flip1995@yaahc@phansch@llogiq).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Mar 3, 2020
Tested on commit rust-lang/rust@4ad6248.
Direct link to PR: <rust-lang/rust#69506>
💔 clippy-driver on windows: test-pass → test-fail (cc @mcarton@oli-obk@Manishearth@flip1995@yaahc@phansch@llogiq).
💔 clippy-driver on linux: test-pass → test-fail (cc @mcarton@oli-obk@Manishearth@flip1995@yaahc@phansch@llogiq).
@Centril
Centril deleted the stmt-semi-none branch March 3, 2020 23:51
flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Mar 3, 2020
bors added a commit to rust-lang/rust-clippy that referenced this pull request Mar 4, 2020
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 4, 2020
Changes:
````
Rustup to rust-lang#69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for rust-lang#5238
````
bors added a commit that referenced this pull request Mar 4, 2020
submodules: update clippy from 8b7f7e6 to 74eae9d
Changes:
````
Rustup to #69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for #5238
````
Makes clippy tests pass again.
r? @oli-obk
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 4, 2020
Changes:
````
Apply suggestions from code review
Simplify if_chain.
Move NumericLiteral to its own module.
Included binary and octal cases.
Resolve false positives for hex int cast.
Test for unnecessary_cast of hex int literal.
run-rustfix
Lint `if let Some` in question_mark lint
Add restrictive pat use in full binded struct
Update test case answers to match cargo dev fmt
Ran cargo dev fmt
Rustup to rust-lang#69506
Recommended changes from flip1995
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
Fix one last test issue
Refactor suggested by krishna-veerareddy
Fixed compile error from merging
Changed test output to reflect cargo fmt
Run cargo dev fmt
Finished checking for cases of absolute values
add test for rust-lang#5238
Some bugfixing
Created floating point abs lint and test, but not yet run
````
bors added a commit that referenced this pull request Mar 5, 2020
submodules: update clippy from 8b7f7e6 to 74eae9d
Changes:
````
Rustup to #69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for #5238
````
Makes clippy tests pass again.
r? @oli-obk
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 5, 2020
Changes:
````
Apply suggestions from code review
Simplify if_chain.
Move NumericLiteral to its own module.
Included binary and octal cases.
Resolve false positives for hex int cast.
Test for unnecessary_cast of hex int literal.
run-rustfix
Lint `if let Some` in question_mark lint
Add restrictive pat use in full binded struct
Update test case answers to match cargo dev fmt
Ran cargo dev fmt
Rustup to rust-lang/rust#69506
Recommended changes from flip1995
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
Fix one last test issue
Refactor suggested by krishna-veerareddy
Fixed compile error from merging
Changed test output to reflect cargo fmt
Run cargo dev fmt
Finished checking for cases of absolute values
add test for rust-lang#5238
Some bugfixing
Created floating point abs lint and test, but not yet run
````
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@Centril@rust-timer@bors@petrochenkov@rust-highfive