1
Fork 0

Rollup merge of #86450 - tmiasko:move-size-limit, r=pnkfelix

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 #83518.
This commit is contained in:
Yuki Okushi 2021-07-27 19:52:40 +09:00 committed by GitHub
commit 99a6474bc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 6 deletions

View file

@ -21,7 +21,12 @@ use std::num::IntErrorKind;
pub fn provide(providers: &mut ty::query::Providers) {
providers.limits = |tcx, ()| Limits {
recursion_limit: get_recursion_limit(tcx.hir().krate_attrs(), tcx.sess),
move_size_limit: get_limit(tcx.hir().krate_attrs(), tcx.sess, sym::move_size_limit, 0),
move_size_limit: get_limit(
tcx.hir().krate_attrs(),
tcx.sess,
sym::move_size_limit,
tcx.sess.opts.debugging_opts.move_size_limit.unwrap_or(0),
),
type_length_limit: get_limit(
tcx.hir().krate_attrs(),
tcx.sess,