Merge visitors in AST validation by Zoxc · Pull Request #57730 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation12 Commits2 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

Zoxc

Cuts runtime for AST validation on syntex_syntax from 31.5 ms to 17 ms.

@rust-highfive

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@Zoxc

Centril

// Used to ban nested `impl Trait`, e.g., `impl Into`.
// Nested `impl Trait` _is_ allowed in associated type position,
// e.g `impl Iterator<Item=impl Debug>`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a note about why we do this (cause we are not sure whether we want it to be higher rank: impl for<T: Debug> Into<T>, or rank-1).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why we do this. I just copied this comment. Feel free to suggest the exact change you'd like.

}
impl<'a> AstValidator<'a> {
fn with_banned_impl_trait(&mut self, f: F)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use f: impl FnOnce(&mut Self) for increased readability?

self.is_impl_trait_banned = old_is_impl_trait_banned;
}
fn with_impl_trait(&mut self, outer_impl_trait: Option, f: F)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.. f: impl FnOnce(&mut Self).

fn with_banned_impl_trait(&mut self, f: F)
where F: FnOnce(&mut Self)
{
let old_is_impl_trait_banned = self.is_impl_trait_banned;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use mem::replace?

fn with_impl_trait(&mut self, outer_impl_trait: Option, f: F)
where F: FnOnce(&mut Self)
{
let old_outer_impl_trait = self.outer_impl_trait;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use mem::replace here also?

@cramertj

@Zoxc

Zoxc

fn visit_ty(&mut self, t: &'a Ty) {
match t.node {
TyKind::ImplTrait(..) => {
if self.is_banned {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will give errors about nested impl traits being banned in path parameters, unlike the old code, which doesn't visit inside impl Trait. So we'd get 3 errors then, one for nested impl Trait and one for each instance of impl Trait in a path parameter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM.

@cramertj

@bors

📌 Commit a5d4aed has been approved by cramertj

@bors bors 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-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jan 21, 2019

Centril added a commit to Centril/rust that referenced this pull request

Jan 21, 2019

@Centril

…ertj

Merge visitors in AST validation

Cuts runtime for AST validation on syntex_syntax from 31.5 ms to 17 ms.

Centril added a commit to Centril/rust that referenced this pull request

Jan 23, 2019

@Centril

…ertj

Merge visitors in AST validation

Cuts runtime for AST validation on syntex_syntax from 31.5 ms to 17 ms.

Centril added a commit to Centril/rust that referenced this pull request

Jan 23, 2019

@Centril

…ertj

Merge visitors in AST validation

Cuts runtime for AST validation on syntex_syntax from 31.5 ms to 17 ms.

bors added a commit that referenced this pull request

Jan 24, 2019

@bors

Rollup of 11 pull requests

Successful merges:

Failed merges:

r? @ghost

@Zoxc Zoxc deleted the combined-ast-validator branch

January 24, 2019 08:38

Zoxc added a commit to Zoxc/rust that referenced this pull request

Jan 30, 2019

@Zoxc

@Zoxc Zoxc mentioned this pull request

Jan 30, 2019

Centril added a commit to Centril/rust that referenced this pull request

Feb 14, 2019

@Centril

kennytm added a commit to kennytm/rust that referenced this pull request

Feb 16, 2019

@kennytm

bors added a commit that referenced this pull request

Feb 16, 2019

@bors

Rollup of 19 pull requests

Successful merges:

bors added a commit that referenced this pull request

Feb 17, 2019

@bors

Rollup of 19 pull requests

Successful merges:

bors added a commit that referenced this pull request

Mar 12, 2019

@bors

…mpl-trait, r=zoxc

Warning period for detecting nested impl trait

Here is some proposed code for making a warning period for the new checking of nested impl trait.

It undoes some of the corrective effects of PR #57730, by using boolean flags to track parts of the analysis that were previously skipped prior to PRs #57730 and #57981 landing.

Cc #57979

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.