Skip to content
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

[rust 2021] migrate to rust 2021 #1159

Merged
merged 10 commits into from
Aug 3, 2021
Merged

Conversation

PsiACE
Copy link
Member

@PsiACE PsiACE commented Jul 22, 2021

Signed-off-by: Chojan Shang psiace@outlook.com

I hereby agree to the terms of the CLA available at: https://datafuse.rs/policies/cla/

Summary

Migrate to rust 2021

cargo fmt fails with error "Invalid value for `--edition`", see:

Changelog

  • Improvement
  • Build/Testing/CI

Related Issues

Fixes #1149

Test Plan

Unit Tests

Stateless Tests

Signed-off-by: Chojan Shang <psiace@outlook.com>
@databend-bot databend-bot added pr-build this PR changes build/testing/ci steps pr-improvement labels Jul 22, 2021
@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@@ -87,7 +87,10 @@ impl DataBlock {
.columns()
.iter()
.zip(rhs.columns().iter())
.map(|(a, b)| DataColumnCommon::merge_columns(a, b, indices))
.map(|(a, b)| {
let _ = &indices;
Copy link
Member

Choose a reason for hiding this comment

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

This line used for?

Copy link
Member Author

Choose a reason for hiding this comment

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

This line used for?

see https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html

Auto gen by cargo fix. This is a conservative analysis: in many cases, these dummy lets can be safely removed and your program will work fine.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like a good style : (

Copy link
Member

@zhang2014 zhang2014 Jul 22, 2021

Choose a reason for hiding this comment

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

Maybe we can do it with macros? similar to '[&captures_var] (args) {} in C++`.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we can do it with macros? similar to '[&captures_var] (args) {} in C++`.

We can try to remove these dummy let manually. If it is really necessary, consider other options.

.map(|opt_idx| opt_idx.map(|idx| *array_values.get_unchecked(idx)));
let iter = indices.into_iter().map(|opt_idx| {
opt_idx.map(|idx| {
let _ = &array_values;
Copy link
Member

@sundy-li sundy-li Jul 22, 2021

Choose a reason for hiding this comment

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

Why rust 2021 turns to be more complicated.

Copy link
Member

Choose a reason for hiding this comment

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

😭

Copy link
Member Author

Choose a reason for hiding this comment

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

Why rust 2021 turns to be more complicated.

I don't think it becomes more complicated.

This is a conservative analysis: in many cases, these dummy lets can be safely removed and your program will work fine.

Starting in Rust 2021, closures captures are more precise. Typically they will only capture the fields they use (in some cases, they might capture more than just what they use, see the Rust reference for full details).

@PsiACE
Copy link
Member Author

PsiACE commented Jul 22, 2021

We can try to adjust these codes later. Just announcing that we are moving towards Rust 2021.

@ariesdevil
Copy link
Contributor

Since the Rust official says:

Note that Rust 2021 is still unstable, so you can expect bugs and other changes! We recommend migrating your crates in a temporary copy of your code versus your main branch. If you do encounter problems, or find areas where quality could be improved (missing documentation, confusing error messages, etc) please file an issue and tell us about it! Thank you!

We'd better make this PR commit to an independent branch likes rust-2021 instead of direct to master.
@PsiACE

@PsiACE PsiACE changed the base branch from master to rust-2021 July 22, 2021 09:15
@PsiACE
Copy link
Member Author

PsiACE commented Jul 22, 2021

We'd better make this PR commit to an independent branch likes rust-2021 instead of direct to master.

Okay, thanks.

@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2021

Codecov Report

Merging #1159 (a694e36) into master (62603da) will decrease coverage by 11%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1159      +/-   ##
=========================================
- Coverage      71%     59%     -12%     
=========================================
  Files         446       6     -440     
  Lines       26330      96   -26234     
=========================================
- Hits        18714      57   -18657     
+ Misses       7616      39    -7577     
Impacted Files Coverage Δ
common/management/src/user/user_api.rs 0% <0%> (-80%) ⬇️
common/management/src/user/utils.rs 0% <0%> (-76%) ⬇️
common/progress/src/progress.rs 54% <0%> (-25%) ⬇️
fusequery/query/src/api/rpc/flight_actions.rs
fusequery/query/src/interpreters/interpreter.rs
common/infallible/src/rwlock_test.rs
common/datavalues/src/series/comparison.rs
fusestore/store/src/executor/action_handler.rs
common/functions/src/scalars/udfs/exists.rs
fusestore/store/src/localfs/local_fs_test.rs
... and 410 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62603da...a694e36. Read the comment docs.

@BohuTANG
Copy link
Member

BohuTANG commented Jul 23, 2021

Since the Rust official says:

Note that Rust 2021 is still unstable, so you can expect bugs and other changes! We recommend migrating your crates in a temporary copy of your code versus your main branch. If you do encounter problems, or find areas where quality could be improved (missing documentation, confusing error messages, etc) please file an issue and tell us about it! Thank you!

We'd better make this PR commit to an independent branch likes rust-2021 instead of direct to master.
@PsiACE

If there are no major problems, merging to the maater branch is ok, we also want to help Rust 2021 mature faster, not simply testing, and Rust 2021 nightly will be released soon.
cc @PsiACE @ariesdevil

@PsiACE
Copy link
Member Author

PsiACE commented Jul 23, 2021

If there are no major problems, merging to the maater branch is ok, we also want to help Rust 2021 mature faster, not simply testing, and Rust 2021 nightly will be released soon.

There seems to be no problem, I will check if there is some room for improvement, and then merge before next Wednesday.

PsiACE added 2 commits July 26, 2021 08:58
Signed-off-by: Chojan Shang <psiace@outlook.com>
Signed-off-by: Chojan Shang <psiace@outlook.com>
@PsiACE PsiACE changed the base branch from rust-2021 to master July 26, 2021 02:07
PsiACE added 4 commits July 29, 2021 12:51
Signed-off-by: Chojan Shang <psiace@outlook.com>
Signed-off-by: Chojan Shang <psiace@outlook.com>
Signed-off-by: Chojan Shang <psiace@outlook.com>
@PsiACE PsiACE marked this pull request as ready for review July 29, 2021 05:23
@databend-bot
Copy link
Member

Hello @PsiACE, 🎉 Thank you for opening the pull request! 🎉
Your pull request state is not in Draft, please add Reviewers or Re-request review again!
FuseQuery: @BohuTANG @sundy-li @zhang2014
FuseStore: @drmingdrmer @dantengsky
Or visit datafuse roadmap for some clues.

@PsiACE
Copy link
Member Author

PsiACE commented Jul 29, 2021

Finally, I removed all useless dummy lets. I think we can announce a successful migration to Rust 2021. The only regret is that the cargo fmt is temporarily invalid.

@BohuTANG
Copy link
Member

Finally, I removed all useless dummy lets. I think we can announce a successful migration to Rust 2021. The only regret is that the cargo format is temporarily invalid.

Great, waiting for rust-lang/rust#87468 to merge.

@BohuTANG
Copy link
Member

BohuTANG commented Aug 2, 2021

Finally, I removed all useless dummy lets. I think we can announce a successful migration to Rust 2021. The only regret is that the cargo format is temporarily invalid.

Great, waiting for rust-lang/rust#87468 to merge.

87468 has merged, we could start this task again.
cc @PsiACE

@PsiACE
Copy link
Member Author

PsiACE commented Aug 2, 2021

87468 has merged, we could start this task again.
cc @PsiACE

Yes, but we still need to wait for the new nightly version. This PR may be completed later today.

PsiACE added 3 commits August 3, 2021 15:48
Signed-off-by: Chojan Shang <psiace@outlook.com>
Signed-off-by: Chojan Shang <psiace@outlook.com>
@PsiACE PsiACE requested a review from BohuTANG August 3, 2021 10:30
@PsiACE
Copy link
Member Author

PsiACE commented Aug 3, 2021

@BohuTANG Done. Once merged, we will enter the era of Rust 2021.

Copy link
Member

@BohuTANG BohuTANG left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot databend-bot merged commit db62e1e into databendlabs:master Aug 3, 2021
@PsiACE PsiACE deleted the rust-2021 branch August 3, 2021 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-build this PR changes build/testing/ci steps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rust] try Rust 2021
7 participants