Skip to content

Commit 44b30ce

Browse files
committed
Set default move_size_limit to 4kB for large_assignments lint on nightly
Only enable it by default in the nightly compiler. The limit can be changed on a per-crate basis with: #![feature(large_assignments)] #![move_size_limit = "8192"] or with -Zmove-size-limit=8192
1 parent f06b7c5 commit 44b30ce

File tree

26 files changed

+210
-20
lines changed

26 files changed

+210
-20
lines changed

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ pub fn create_global_ctxt<'tcx>(
716716

717717
sess.time("setup_global_ctxt", || {
718718
gcx_cell.get_or_init(move || {
719+
#[allow(large_assignments)]
719720
TyCtxt::create_global_ctxt(
720721
sess,
721722
crate_types,

compiler/rustc_interface/src/queries.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub struct Queries<'tcx> {
9393

9494
impl<'tcx> Queries<'tcx> {
9595
pub fn new(compiler: &'tcx Compiler) -> Queries<'tcx> {
96+
#[allow(large_assignments)]
9697
Queries {
9798
compiler,
9899
gcx_cell: OnceLock::new(),

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(rustc::bad_opt_access)]
1+
#![allow(rustc::bad_opt_access, large_assignments)]
22
use crate::interface::parse_cfgspecs;
33

44
use rustc_data_structures::fx::FxHashSet;

compiler/rustc_interface/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub fn create_session(
126126
sess.parse_sess.config = cfg;
127127
sess.parse_sess.check_config = check_cfg;
128128

129+
#[allow(large_assignments)]
129130
(sess, codegen_backend)
130131
}
131132

compiler/rustc_middle/src/middle/limits.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ pub fn provide(providers: &mut Providers) {
2525
tcx.hir().krate_attrs(),
2626
tcx.sess,
2727
sym::move_size_limit,
28-
tcx.sess.opts.unstable_opts.move_size_limit.unwrap_or(0),
28+
// The check is enabled by default in nightly compilers without
29+
// needing `#![feature(large_assignments)]` with a limit of 4096
30+
// bytes. But if the user wants to use adjust `#![move_size_limit]`,
31+
// then `#![feature(large_assignments)]` is needed.
32+
tcx.sess.opts.unstable_opts.move_size_limit.unwrap_or(if tcx.sess.is_nightly_build() {
33+
4096
34+
} else {
35+
0
36+
}),
2937
),
3038
type_length_limit: get_limit(
3139
tcx.hir().krate_attrs(),

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ impl<'tcx> TyCtxt<'tcx> {
713713
let common_lifetimes = CommonLifetimes::new(&interners);
714714
let common_consts = CommonConsts::new(&interners, &common_types);
715715

716+
#[allow(large_assignments)]
716717
GlobalCtxt {
717718
sess: s,
718719
crate_types,

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ pub fn query_system<'tcx>(
209209
on_disk_cache: Option<OnDiskCache<'tcx>>,
210210
incremental: bool,
211211
) -> QuerySystem<'tcx> {
212+
#[allow(large_assignments)]
212213
QuerySystem {
213214
states: Default::default(),
214215
arenas: Default::default(),

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ fn default_emitter(
13121312
}
13131313

13141314
// JUSTIFICATION: literally session construction
1315-
#[allow(rustc::bad_opt_access)]
1315+
#[allow(rustc::bad_opt_access, large_assignments)]
13161316
pub fn build_session(
13171317
handler: &EarlyErrorHandler,
13181318
sopts: config::Options,

compiler/rustc_target/src/spec/apple/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(large_assignments)]
2+
13
use crate::spec::{
24
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
35
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,

library/alloc/benches/vec_deque.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(large_assignments)]
2+
13
use core::iter::Iterator;
24
use std::{
35
collections::{vec_deque, VecDeque},

0 commit comments

Comments
 (0)