From 9792179648abb7bf38a9e54191cfe5a25436b8fb Mon Sep 17 00:00:00 2001 From: Tomasz Miąsko Date: Sat, 19 Jun 2021 00:00:00 +0000 Subject: 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 ``` --- compiler/rustc_middle/src/middle/limits.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_middle') diff --git a/compiler/rustc_middle/src/middle/limits.rs b/compiler/rustc_middle/src/middle/limits.rs index c4bfd0ebb2f..7ea4902f4bc 100644 --- a/compiler/rustc_middle/src/middle/limits.rs +++ b/compiler/rustc_middle/src/middle/limits.rs @@ -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, -- cgit 1.4.1-3-g733a5