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

Add flag to configure large_assignments lint #86450

Merged
merged 1 commit into from
Jul 27, 2021

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Jun 18, 2021

The large_assignments lints detects moves over specified limit. The
limit is configured through move_size_limit = "N" attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag -Zmove-size-limit=N. For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv

Lint tracking issue #83518.

@rust-highfive
Copy link
Collaborator

r? @LeSeulArtichaut

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 18, 2021
@tmiasko
Copy link
Contributor Author

tmiasko commented Jun 18, 2021

A few examples
warning: moving 16384 bytes
  --> ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/crc32fast-1.2.1/src/baseline.rs:38:19
   |
38 |             crc = CRC32_TABLE[0x0][buf[0xf] as usize]
   |                   ^^^^^^^^^^^ value moved from here
   |

warning: moving 16384 bytes
  --> ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/crc32fast-1.2.1/src/baseline.rs:39:19
   |
39 |                 ^ CRC32_TABLE[0x1][buf[0xe] as usize]
   |                   ^^^^^^^^^^^ value moved from here

...

warning: moving 65536 bytes
  --> ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/h2-0.3.3/src/hpack/huffman/mod.rs:92:35
   |
92 |         let (next, byte, flags) = DECODE_TABLE[self.state][input as usize];
   |                                   ^^^^^^^^^^^^ value moved from here
   |
   = note: `#[warn(large_assignments)]` on by default

warning: moving 4112 bytes
  --> ~/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/h2-0.3.3/src/hpack/huffman/mod.rs:50:29
   |
50 |         let (nbits, code) = ENCODE_TABLE[b as usize];
   |                             ^^^^^^^^^^^^ value moved from here

We should probably lint large consts by default.

cc @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Jun 19, 2021

r? @pnkfelix

@bors
Copy link
Contributor

bors commented Jul 5, 2021

☔ The latest upstream changes (presumably #86674) made this pull request unmergeable. Please resolve the merge conflicts.

The `large_assignments` lints detects moves over specified limit.  The
limit is configured through `move_size_limit = "N"` attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag `-Zmove-size-limit=N`.  For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

```
$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv
```
@tmiasko
Copy link
Contributor Author

tmiasko commented Jul 6, 2021

@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2021
@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 27, 2021

📌 Commit 9792179 has been approved by pnkfelix

@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 Jul 27, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 27, 2021
Add flag to configure `large_assignments` lint

The `large_assignments` lints detects moves over specified limit.  The
limit is configured through `move_size_limit = "N"` attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag `-Zmove-size-limit=N`.  For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

```
$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv
```

Lint tracking issue rust-lang#83518.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#86450 (Add flag to configure `large_assignments` lint)
 - rust-lang#86764 (Avoid ICE on type error recovery)
 - rust-lang#87354 (Update VxWork's UNIX support)
 - rust-lang#87427 (get rid of NoMirFor error variant)
 - rust-lang#87446 (macos current_exe using directly libc instead.)
 - rust-lang#87494 (fix typo: whenver -> whenever)
 - rust-lang#87497 (Add long explanation for E0544.)
 - rust-lang#87499 (Remove ASCII fast path from `rustc_lexer::{is_id_continue, is_id_start}`)
 - rust-lang#87502 (Update cargo)
 - rust-lang#87503 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 99a6474 into rust-lang:master Jul 27, 2021
@rustbot rustbot added this to the 1.56.0 milestone Jul 27, 2021
@tmiasko tmiasko deleted the move-size-limit branch July 27, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: 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.

8 participants