Skip to content

Adds sort for RecordLit comparison in SSR #3765

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

Merged
merged 1 commit into from
Apr 1, 2020

Conversation

mikhail-m1
Copy link
Contributor

an item from #3186

Comment on lines 201 to 204
if pattern_fields.is_none() && code_fields.is_none() {
return Some(match_);
}

if pattern_fields.is_none() || code_fields.is_none() {
return None;
}

let mut pattern_fields = pattern_fields.unwrap().collect::<Vec<_>>();
let mut code_fields = code_fields.unwrap().collect::<Vec<_>>();

if pattern_fields.len() != code_fields.len() {
return None;
}
Copy link
Member

Choose a reason for hiding this comment

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

A single match might be better ? e.g.:

let (pattern_fields, code_fields) = match (pattern_fileds, code_fields) {
...

Copy link
Contributor Author

@mikhail-m1 mikhail-m1 Mar 30, 2020

Choose a reason for hiding this comment

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

I rewrote it little bit differently.

)
}

fn check_opt_nodes(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to use this functions for function call vs method call check.

@mikhail-m1 mikhail-m1 requested a review from edwin0cheng March 31, 2020 16:02

fn check_opt_nodes(
pattern: Option<impl AstNode>,
code: Option<impl AstNode>,
Copy link
Member

@edwin0cheng edwin0cheng Mar 31, 2020

Choose a reason for hiding this comment

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

Do we really need to pass these as Option here? Seem like the all call sites of it could change to :

check_opt_nodes(pattern.path()?, code.path()?, placeholders, match_);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed (None,None) arm, added

@edwin0cheng
Copy link
Member

LGTM with a nit, but personally I don't like multiple long inline functions in rust but we could refactor it later on.

@edwin0cheng
Copy link
Member

bors r+

Thanks @mikhail-m1

@bors
Copy link
Contributor

bors bot commented Apr 1, 2020

@bors bors bot merged commit e3a1f1c into rust-lang:master Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants