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

[Merged by Bors] - General code clean-up and new lint addition #1809

Closed
wants to merge 4 commits into from

Conversation

Razican
Copy link
Member

@Razican Razican commented Jan 29, 2022

This PR adds some Clippy lints. Mainly, it adds the list of pedantic lints excluding some lints that were causing too many warnings. I also denied some useful restriction and pedantic lints, to make sure we use Self all the possible times (for better maintainability), and that we pass elements by reference where possible, for example, or that the documentation is properly written.

This might even have some small performance gains.

I also added a perfect hash function for the CLI keywords, which should be more efficient than a HashSet. This is something we could use elsewhere too.

@Razican Razican added the Internal Category for changelog label Jan 29, 2022
@Razican Razican added this to the v0.14.0 milestone Jan 29, 2022
@github-actions
Copy link

Test262 conformance changes

VM implementation

Test result main count PR count difference
Total 87,650 87,650 0
Passed 40,892 40,892 0
Ignored 19,675 19,675 0
Failed 27,083 27,083 0
Panics 0 0 0
Conformance 46.65% 46.65% 0.00%

@github-actions
Copy link

Benchmark for 523a566

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 404.6±11.64ns 402.3±4.65ns -0.57%
Arithmetic operations (Execution) 1974.7±2.52ns 1990.7±1.72ns +0.81%
Arithmetic operations (Parser) 5.8±0.01µs 5.7±0.02µs -1.72%
Array access (Compiler) 826.1±2.58ns 847.0±3.23ns +2.53%
Array access (Execution) 10.4±0.03µs 10.3±0.03µs -0.96%
Array access (Parser) 12.2±0.03µs 12.3±0.07µs +0.82%
Array creation (Compiler) 1159.8±3.64ns 1167.7±3.33ns +0.68%
Array creation (Execution) 3.1±0.01ms 3.1±0.01ms 0.00%
Array creation (Parser) 13.6±0.02µs 13.7±0.04µs +0.74%
Array pop (Compiler) 2.8±0.00µs 2.8±0.00µs 0.00%
Array pop (Execution) 1309.9±24.69µs 1310.2±4.62µs +0.02%
Array pop (Parser) 145.0±0.18µs 142.7±0.64µs -1.59%
Boolean Object Access (Compiler) 684.2±1.21ns 685.5±1.15ns +0.19%
Boolean Object Access (Execution) 6.9±0.02µs 6.9±0.02µs 0.00%
Boolean Object Access (Parser) 14.1±0.02µs 14.5±0.09µs +2.84%
Clean js (Compiler) 2.2±0.00µs 2.3±0.01µs +4.55%
Clean js (Execution) 1475.4±12.46µs 1469.8±11.22µs -0.38%
Clean js (Parser) 29.4±0.08µs 29.3±0.05µs -0.34%
Create Realm 340.1±0.21ns 341.8±0.32ns +0.50%
Dynamic Object Property Access (Compiler) 1164.0±3.49ns 1153.3±2.86ns -0.92%
Dynamic Object Property Access (Execution) 6.8±0.04µs 6.8±0.03µs 0.00%
Dynamic Object Property Access (Parser) 10.7±0.01µs 10.8±0.02µs +0.93%
Fibonacci (Compiler) 1520.4±17.38ns 1489.3±4.27ns -2.05%
Fibonacci (Execution) 2.7±0.01ms 2.7±0.00ms 0.00%
Fibonacci (Parser) 16.3±0.03µs 16.4±0.03µs +0.61%
For loop (Compiler) 1286.2±8.25ns 1303.2±3.61ns +1.32%
For loop (Execution) 43.9±0.15µs 43.7±0.15µs -0.46%
For loop (Parser) 14.2±0.03µs 14.2±0.07µs 0.00%
Mini js (Compiler) 2.2±0.01µs 2.2±0.01µs 0.00%
Mini js (Execution) 1370.5±10.08µs 1353.7±16.64µs -1.23%
Mini js (Parser) 25.9±0.09µs 25.8±0.03µs -0.39%
Number Object Access (Compiler) 639.4±0.96ns 643.6±1.39ns +0.66%
Number Object Access (Execution) 5.4±0.06µs 5.5±0.02µs +1.85%
Number Object Access (Parser) 11.2±0.02µs 11.3±0.01µs +0.89%
Object Creation (Compiler) 965.7±2.34ns 964.7±3.04ns -0.10%
Object Creation (Execution) 6.1±0.02µs 6.2±0.02µs +1.64%
Object Creation (Parser) 9.3±0.02µs 9.5±0.01µs +2.15%
RegExp (Compiler) 1170.8±4.10ns 1147.1±2.18ns -2.02%
RegExp (Execution) 13.0±0.06µs 13.0±0.06µs 0.00%
RegExp (Parser) 10.2±0.01µs 10.4±0.01µs +1.96%
RegExp Creation (Compiler) 1052.7±2.02ns 1043.6±3.37ns -0.86%
RegExp Creation (Execution) 10.0±0.06µs 9.9±0.06µs -1.00%
RegExp Creation (Parser) 8.5±0.02µs 8.7±0.01µs +2.35%
RegExp Literal (Compiler) 1167.5±4.56ns 1145.0±5.28ns -1.93%
RegExp Literal (Execution) 13.1±0.04µs 13.0±0.04µs -0.76%
RegExp Literal (Parser) 8.2±0.01µs 8.4±0.02µs +2.44%
RegExp Literal Creation (Compiler) 1064.0±3.02ns 1040.3±3.36ns -2.23%
RegExp Literal Creation (Execution) 9.9±0.06µs 9.9±0.05µs 0.00%
RegExp Literal Creation (Parser) 6.4±0.01µs 6.6±0.01µs +3.12%
Static Object Property Access (Compiler) 979.2±2.56ns 987.0±2.83ns +0.80%
Static Object Property Access (Execution) 6.4±0.02µs 6.4±0.03µs 0.00%
Static Object Property Access (Parser) 9.9±0.01µs 10.2±0.01µs +3.03%
String Object Access (Compiler) 1029.9±6.37ns 1035.8±5.67ns +0.57%
String Object Access (Execution) 8.8±0.02µs 8.8±0.01µs 0.00%
String Object Access (Parser) 13.8±0.01µs 14.2±0.01µs +2.90%
String comparison (Compiler) 1315.0±3.28ns 1332.8±7.53ns +1.35%
String comparison (Execution) 7.1±0.02µs 7.2±0.03µs +1.41%
String comparison (Parser) 11.0±0.02µs 11.1±0.02µs +0.91%
String concatenation (Compiler) 1066.4±2.47ns 1067.9±2.30ns +0.14%
String concatenation (Execution) 6.0±0.01µs 6.1±0.01µs +1.67%
String concatenation (Parser) 7.6±0.03µs 7.7±0.01µs +1.32%
String copy (Compiler) 893.7±2.52ns 897.5±2.06ns +0.43%
String copy (Execution) 5.2±0.01µs 5.3±0.02µs +1.92%
String copy (Parser) 5.7±0.02µs 5.8±0.02µs +1.75%
Symbols (Compiler) 652.1±3.24ns 658.9±4.97ns +1.04%
Symbols (Execution) 5.0±0.02µs 4.9±0.01µs -2.00%
Symbols (Parser) 4.4±0.01µs 4.4±0.01µs 0.00%

@github-actions
Copy link

Benchmark for bb0c71d

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 508.6±5.04ns 500.5±2.01ns -1.59%
Arithmetic operations (Execution) 2.5±0.00µs 2.5±0.00µs 0.00%
Arithmetic operations (Parser) 6.7±0.01µs 6.6±0.02µs -1.49%
Array access (Compiler) 1030.6±3.50ns 1021.0±3.42ns -0.93%
Array access (Execution) 13.0±0.04µs 12.9±0.05µs -0.77%
Array access (Parser) 14.3±0.03µs 14.2±0.01µs -0.70%
Array creation (Compiler) 1465.4±4.37ns 1460.9±4.41ns -0.31%
Array creation (Execution) 3.8±0.01ms 3.9±0.01ms +2.63%
Array creation (Parser) 15.9±0.03µs 15.8±0.02µs -0.63%
Array pop (Compiler) 3.5±0.02µs 3.5±0.02µs 0.00%
Array pop (Execution) 1639.4±8.49µs 1654.7±8.08µs +0.93%
Array pop (Parser) 176.4±0.16µs 174.2±0.17µs -1.25%
Boolean Object Access (Compiler) 824.5±2.47ns 831.3±2.41ns +0.82%
Boolean Object Access (Execution) 8.6±0.04µs 8.7±0.02µs +1.16%
Boolean Object Access (Parser) 16.6±0.02µs 17.0±0.03µs +2.41%
Clean js (Compiler) 2.8±0.02µs 2.7±0.02µs -3.57%
Clean js (Execution) 1823.1±10.37µs 1827.6±10.45µs +0.25%
Clean js (Parser) 34.0±0.06µs 33.9±0.13µs -0.29%
Create Realm 422.5±0.74ns 421.3±2.11ns -0.28%
Dynamic Object Property Access (Compiler) 1444.7±4.46ns 1440.4±3.45ns -0.30%
Dynamic Object Property Access (Execution) 8.5±0.04µs 8.7±0.04µs +2.35%
Dynamic Object Property Access (Parser) 12.4±0.02µs 12.3±0.02µs -0.81%
Fibonacci (Compiler) 1845.2±5.65ns 1851.6±5.77ns +0.35%
Fibonacci (Execution) 3.4±0.01ms 3.4±0.00ms 0.00%
Fibonacci (Parser) 19.1±0.04µs 19.2±0.02µs +0.52%
For loop (Compiler) 1588.6±6.55ns 1616.7±6.07ns +1.77%
For loop (Execution) 54.7±0.15µs 54.6±0.11µs -0.18%
For loop (Parser) 16.7±0.20µs 16.6±0.02µs -0.60%
Mini js (Compiler) 2.7±0.02µs 2.7±0.02µs 0.00%
Mini js (Execution) 1698.3±19.99µs 1699.3±12.22µs +0.06%
Mini js (Parser) 29.9±0.03µs 29.8±0.03µs -0.33%
Number Object Access (Compiler) 802.1±14.57ns 786.3±3.03ns -1.97%
Number Object Access (Execution) 6.8±0.04µs 6.8±0.07µs 0.00%
Number Object Access (Parser) 13.0±0.02µs 13.3±0.10µs +2.31%
Object Creation (Compiler) 1209.4±6.56ns 1213.0±6.57ns +0.30%
Object Creation (Execution) 7.6±0.02µs 7.8±0.10µs +2.63%
Object Creation (Parser) 10.8±0.01µs 10.8±0.01µs 0.00%
RegExp (Compiler) 1420.7±1.67ns 1443.3±3.29ns +1.59%
RegExp (Execution) 15.9±0.08µs 16.1±0.07µs +1.26%
RegExp (Parser) 11.9±0.03µs 11.9±0.03µs 0.00%
RegExp Creation (Compiler) 1287.1±4.30ns 1311.6±3.33ns +1.90%
RegExp Creation (Execution) 12.2±0.06µs 12.3±0.10µs +0.82%
RegExp Creation (Parser) 9.9±0.01µs 9.9±0.08µs 0.00%
RegExp Literal (Compiler) 1455.6±4.55ns 1430.8±5.17ns -1.70%
RegExp Literal (Execution) 16.0±0.09µs 16.0±0.06µs 0.00%
RegExp Literal (Parser) 9.5±0.01µs 9.5±0.01µs 0.00%
RegExp Literal Creation (Compiler) 1292.4±2.91ns 1295.9±3.74ns +0.27%
RegExp Literal Creation (Execution) 12.2±0.10µs 12.3±0.04µs +0.82%
RegExp Literal Creation (Parser) 7.5±0.01µs 7.5±0.02µs 0.00%
Static Object Property Access (Compiler) 1212.2±5.57ns 1216.5±5.71ns +0.35%
Static Object Property Access (Execution) 8.0±0.03µs 8.1±0.04µs +1.25%
Static Object Property Access (Parser) 11.6±0.09µs 11.6±0.01µs 0.00%
String Object Access (Compiler) 1267.5±4.92ns 1275.3±4.67ns +0.62%
String Object Access (Execution) 10.9±0.06µs 11.2±0.09µs +2.75%
String Object Access (Parser) 16.5±0.01µs 16.7±0.02µs +1.21%
String comparison (Compiler) 1637.9±17.14ns 1636.1±8.88ns -0.11%
String comparison (Execution) 9.0±0.02µs 9.2±0.02µs +2.22%
String comparison (Parser) 13.2±0.03µs 13.0±0.02µs -1.52%
String concatenation (Compiler) 1328.3±4.94ns 1329.7±5.52ns +0.11%
String concatenation (Execution) 7.6±0.03µs 7.7±0.02µs +1.32%
String concatenation (Parser) 9.0±0.01µs 8.8±0.03µs -2.22%
String copy (Compiler) 1104.2±2.92ns 1103.7±11.93ns -0.05%
String copy (Execution) 6.5±0.03µs 6.6±0.04µs +1.54%
String copy (Parser) 6.6±0.01µs 6.6±0.02µs 0.00%
Symbols (Compiler) 819.7±1.30ns 824.7±2.10ns +0.61%
Symbols (Execution) 6.3±0.01µs 6.3±0.02µs 0.00%
Symbols (Parser) 5.0±0.02µs 5.0±0.01µs 0.00%

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #1809 (e1c345b) into main (98faa73) will increase coverage by 0.23%.
The diff coverage is 60.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1809      +/-   ##
==========================================
+ Coverage   55.49%   55.73%   +0.23%     
==========================================
  Files         201      201              
  Lines       17390    17326      -64     
==========================================
+ Hits         9650     9656       +6     
+ Misses       7740     7670      -70     
Impacted Files Coverage Δ
boa/src/builtins/array_buffer/mod.rs 6.91% <0.00%> (+0.14%) ⬆️
boa/src/builtins/dataview/mod.rs 6.81% <0.00%> (+0.03%) ⬆️
boa/src/builtins/error/syntax.rs 100.00% <ø> (ø)
boa/src/builtins/function/mod.rs 33.57% <0.00%> (ø)
boa/src/builtins/intl/mod.rs 19.35% <0.00%> (ø)
boa/src/builtins/iterable/mod.rs 65.38% <0.00%> (ø)
boa/src/builtins/reflect/mod.rs 78.49% <0.00%> (-2.82%) ⬇️
boa/src/builtins/symbol/mod.rs 52.74% <0.00%> (ø)
...src/builtins/typed_array/integer_indexed_object.rs 0.00% <ø> (ø)
boa/src/builtins/typed_array/mod.rs 3.81% <0.00%> (+0.02%) ⬆️
... and 126 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 98faa73...e1c345b. Read the comment docs.

@github-actions
Copy link

Benchmark for 4e5ea24

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 468.5±0.86ns 489.2±2.62ns +4.42%
Arithmetic operations (Execution) 2.4±0.01µs 2.5±0.02µs +4.17%
Arithmetic operations (Parser) 6.4±0.37µs 6.4±0.01µs 0.00%
Array access (Compiler) 974.5±3.27ns 986.3±2.97ns +1.21%
Array access (Execution) 12.4±0.05µs 12.3±0.05µs -0.81%
Array access (Parser) 13.5±0.04µs 13.7±0.06µs +1.48%
Array creation (Compiler) 1382.6±2.77ns 1414.9±5.01ns +2.34%
Array creation (Execution) 3.7±0.02ms 3.7±0.01ms 0.00%
Array creation (Parser) 15.0±0.03µs 15.0±0.02µs 0.00%
Array pop (Compiler) 3.4±0.02µs 3.4±0.01µs 0.00%
Array pop (Execution) 1570.2±6.66µs 1567.4±12.27µs -0.18%
Array pop (Parser) 169.0±0.29µs 170.0±0.20µs +0.59%
Boolean Object Access (Compiler) 792.3±2.80ns 796.5±7.85ns +0.53%
Boolean Object Access (Execution) 8.3±0.02µs 8.2±0.04µs -1.20%
Boolean Object Access (Parser) 15.8±0.03µs 16.4±0.05µs +3.80%
Clean js (Compiler) 2.6±0.01µs 2.7±0.02µs +3.85%
Clean js (Execution) 1766.6±9.90µs 1760.6±13.12µs -0.34%
Clean js (Parser) 32.2±0.10µs 32.5±0.14µs +0.93%
Create Realm 407.5±7.81ns 411.8±2.31ns +1.06%
Dynamic Object Property Access (Compiler) 1385.5±5.55ns 1392.8±5.84ns +0.53%
Dynamic Object Property Access (Execution) 8.2±0.04µs 8.2±0.06µs 0.00%
Dynamic Object Property Access (Parser) 11.7±0.03µs 11.9±0.02µs +1.71%
Fibonacci (Compiler) 1802.9±17.38ns 1805.0±6.33ns +0.12%
Fibonacci (Execution) 3.2±0.01ms 3.3±0.01ms +3.13%
Fibonacci (Parser) 17.9±0.23µs 18.4±0.05µs +2.79%
For loop (Compiler) 1530.6±5.11ns 1540.3±5.13ns +0.63%
For loop (Execution) 52.5±0.26µs 52.6±0.23µs +0.19%
For loop (Parser) 15.7±0.03µs 15.8±0.02µs +0.64%
Mini js (Compiler) 2.6±0.02µs 2.6±0.02µs 0.00%
Mini js (Execution) 1633.5±19.05µs 1626.0±14.36µs -0.46%
Mini js (Parser) 28.3±0.04µs 28.7±0.08µs +1.41%
Number Object Access (Compiler) 744.5±3.60ns 756.5±2.45ns +1.61%
Number Object Access (Execution) 6.4±0.03µs 6.5±0.10µs +1.56%
Number Object Access (Parser) 12.3±0.04µs 12.6±0.11µs +2.44%
Object Creation (Compiler) 1164.0±3.94ns 1174.2±8.22ns +0.88%
Object Creation (Execution) 7.4±0.04µs 7.4±0.02µs 0.00%
Object Creation (Parser) 10.2±0.04µs 10.5±0.03µs +2.94%
RegExp (Compiler) 1380.1±3.14ns 1373.1±3.72ns -0.51%
RegExp (Execution) 15.3±0.09µs 15.4±0.11µs +0.65%
RegExp (Parser) 11.0±0.03µs 11.4±0.02µs +3.64%
RegExp Creation (Compiler) 1241.0±6.23ns 1252.6±4.35ns +0.93%
RegExp Creation (Execution) 11.7±0.05µs 11.9±0.07µs +1.71%
RegExp Creation (Parser) 9.2±0.04µs 9.5±0.03µs +3.26%
RegExp Literal (Compiler) 1359.8±7.06ns 1397.8±6.31ns +2.79%
RegExp Literal (Execution) 15.3±0.08µs 15.4±0.05µs +0.65%
RegExp Literal (Parser) 8.9±0.04µs 9.1±0.04µs +2.25%
RegExp Literal Creation (Compiler) 1237.2±8.63ns 1253.4±8.04ns +1.31%
RegExp Literal Creation (Execution) 11.7±0.09µs 11.8±0.04µs +0.85%
RegExp Literal Creation (Parser) 7.0±0.02µs 7.2±0.02µs +2.86%
Static Object Property Access (Compiler) 1191.2±6.91ns 1177.7±3.14ns -1.13%
Static Object Property Access (Execution) 7.7±0.03µs 7.7±0.04µs 0.00%
Static Object Property Access (Parser) 10.9±0.06µs 11.2±0.04µs +2.75%
String Object Access (Compiler) 1205.8±6.28ns 1220.1±5.82ns +1.19%
String Object Access (Execution) 10.6±0.05µs 10.5±0.07µs -0.94%
String Object Access (Parser) 15.5±0.04µs 16.0±0.08µs +3.23%
String comparison (Compiler) 1579.8±8.48ns 1570.7±12.27ns -0.58%
String comparison (Execution) 8.6±0.04µs 8.6±0.03µs 0.00%
String comparison (Parser) 12.3±0.06µs 12.6±0.03µs +2.44%
String concatenation (Compiler) 1266.0±4.75ns 1282.7±3.77ns +1.32%
String concatenation (Execution) 7.3±0.05µs 7.4±0.02µs +1.37%
String concatenation (Parser) 8.3±0.04µs 8.6±0.02µs +3.61%
String copy (Compiler) 1055.7±3.66ns 1062.2±6.47ns +0.62%
String copy (Execution) 6.3±0.05µs 6.3±0.04µs 0.00%
String copy (Parser) 6.2±0.02µs 6.4±0.02µs +3.23%
Symbols (Compiler) 794.7±6.06ns 774.9±5.21ns -2.49%
Symbols (Execution) 5.9±0.02µs 6.0±0.03µs +1.69%
Symbols (Parser) 4.6±0.04µs 4.7±0.01µs +2.17%

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

Looks really good!

I think enforcing a more consistent style across the codebase is a good idea.

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@HalidOdat
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Feb 3, 2022
This PR adds some Clippy lints. Mainly, it adds the list of pedantic lints excluding some lints that were causing too many warnings. I also denied some useful restriction and pedantic lints, to make sure we use `Self` all the possible times (for better maintainability), and that we pass elements by reference where possible, for example, or that the documentation is properly written.

This might even have some small performance gains.

I also added a perfect hash function for the CLI keywords, which should be more efficient than a `HashSet`. This is something we could use elsewhere too.
@bors
Copy link

bors bot commented Feb 3, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title General code clean-up and new lint addition [Merged by Bors] - General code clean-up and new lint addition Feb 3, 2022
@bors bors bot closed this Feb 3, 2022
@bors bors bot deleted the cleanup branch February 3, 2022 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants