Skip to content

Add flag to configure large_assignments lint - #86450

Merged
bors merged 1 commit into
rust-lang:masterfrom
tmiasko:move-size-limit
Jul 27, 2021
Merged

Add flag to configure large_assignments lint#86450
bors merged 1 commit into
rust-lang:masterfrom
tmiasko:move-size-limit

Conversation

@tmiasko

@tmiaskotmiasko commented Jun 18, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

r? @LeSeulArtichaut

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

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

tmiasko commented Jun 18, 2021

Copy link
Copy Markdown
ContributorAuthor
A few examples
warning: moving 16384 bytes
--> ~/.cargo/registry/src/github.com-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/github.com-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/github.com-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/github.com-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
Copy Markdown
Contributor

r? @pnkfelix

@bors

bors commented Jul 5, 2021

Copy link
Copy Markdown
Collaborator

☔ 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
Copy Markdown
ContributorAuthor

@camelidcamelid 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
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented Jul 27, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 9792179 has been approved by pnkfelix

@borsbors 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
@JohnTitorJohnTitor mentioned this pull request 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.
@JohnTitorJohnTitor mentioned this pull request Jul 27, 2021
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:masterJul 27, 2021
@rustbotrustbot 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: 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

@tmiasko@rust-highfive@oli-obk@bors@pnkfelix@camelid@LeSeulArtichaut@rustbot