From afdd468ab8f4b028ef2eb024b9f724e2feeac72f Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 21 Sep 2023 18:25:13 +0200 Subject: [PATCH 1/2] tests/ui: Fix large_moves attribute cfg We only want the attribute for the attribute revision. --- tests/ui/async-await/large_moves.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/async-await/large_moves.rs b/tests/ui/async-await/large_moves.rs index 62b1210469410..485ca92fb89f9 100644 --- a/tests/ui/async-await/large_moves.rs +++ b/tests/ui/async-await/large_moves.rs @@ -1,5 +1,5 @@ #![deny(large_assignments)] -#![feature(large_assignments)] +#![cfg_attr(attribute, feature(large_assignments))] #![cfg_attr(attribute, move_size_limit = "1000")] // build-fail // only-x86_64 From d016e9a68602199bc4bb7c6e4f00a31c7284b3d4 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 21 Sep 2023 18:28:08 +0200 Subject: [PATCH 2/2] tests/ui: Split large_moves.rs and move to lint/large_assignments To make failing tests easier to debug with --emit=mir, etc. --- .../async-await/large_moves.attribute.stderr | 39 ------------------- .../ui/async-await/large_moves.option.stderr | 39 ------------------- .../large_assignments/box_rc_arc_allowed.rs | 29 ++++++++++++++ .../box_rc_arc_allowed.stderr | 23 +++++++++++ .../large_future.attribute.stderr | 23 +++++++++++ .../large_future.option.stderr | 23 +++++++++++ .../large_assignments/large_future.rs} | 18 --------- 7 files changed, 98 insertions(+), 96 deletions(-) delete mode 100644 tests/ui/async-await/large_moves.attribute.stderr delete mode 100644 tests/ui/async-await/large_moves.option.stderr create mode 100644 tests/ui/lint/large_assignments/box_rc_arc_allowed.rs create mode 100644 tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr create mode 100644 tests/ui/lint/large_assignments/large_future.attribute.stderr create mode 100644 tests/ui/lint/large_assignments/large_future.option.stderr rename tests/ui/{async-await/large_moves.rs => lint/large_assignments/large_future.rs} (59%) diff --git a/tests/ui/async-await/large_moves.attribute.stderr b/tests/ui/async-await/large_moves.attribute.stderr deleted file mode 100644 index 1d1999462cedd..0000000000000 --- a/tests/ui/async-await/large_moves.attribute.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: moving 10024 bytes - --> $DIR/large_moves.rs:21:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -note: the lint level is defined here - --> $DIR/large_moves.rs:1:9 - | -LL | #![deny(large_assignments)] - | ^^^^^^^^^^^^^^^^^ - -error: moving 10024 bytes - --> $DIR/large_moves.rs:22:13 - | -LL | let a = z.0; - | ^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 9999 bytes - --> $DIR/large_moves.rs:27:13 - | -LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 9999 bytes - --> $DIR/large_moves.rs:41:13 - | -LL | data, - | ^^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: aborting due to 4 previous errors - diff --git a/tests/ui/async-await/large_moves.option.stderr b/tests/ui/async-await/large_moves.option.stderr deleted file mode 100644 index 1d1999462cedd..0000000000000 --- a/tests/ui/async-await/large_moves.option.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: moving 10024 bytes - --> $DIR/large_moves.rs:21:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -note: the lint level is defined here - --> $DIR/large_moves.rs:1:9 - | -LL | #![deny(large_assignments)] - | ^^^^^^^^^^^^^^^^^ - -error: moving 10024 bytes - --> $DIR/large_moves.rs:22:13 - | -LL | let a = z.0; - | ^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 9999 bytes - --> $DIR/large_moves.rs:27:13 - | -LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 9999 bytes - --> $DIR/large_moves.rs:41:13 - | -LL | data, - | ^^^^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: aborting due to 4 previous errors - diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs new file mode 100644 index 0000000000000..33113642023a2 --- /dev/null +++ b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs @@ -0,0 +1,29 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-x86_64 + +// edition:2018 +// compile-flags: -Zmir-opt-level=0 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + let _ = Arc::new([0; 9999]); // OK! + let _ = Box::new([0; 9999]); // OK! + let _ = Rc::new([0; 9999]); // OK! + let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + Self { + data, //~ ERROR large_assignments + } + } +} diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr new file mode 100644 index 0000000000000..b45cbe5da4dca --- /dev/null +++ b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr @@ -0,0 +1,23 @@ +error: moving 9999 bytes + --> $DIR/box_rc_arc_allowed.rs:16:13 + | +LL | let _ = NotBox::new([0; 9999]); + | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/box_rc_arc_allowed.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: moving 9999 bytes + --> $DIR/box_rc_arc_allowed.rs:26:13 + | +LL | data, + | ^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/large_assignments/large_future.attribute.stderr b/tests/ui/lint/large_assignments/large_future.attribute.stderr new file mode 100644 index 0000000000000..734b7ff7ba22f --- /dev/null +++ b/tests/ui/lint/large_assignments/large_future.attribute.stderr @@ -0,0 +1,23 @@ +error: moving 10024 bytes + --> $DIR/large_future.rs:19:14 + | +LL | let z = (x, 42); + | ^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/large_future.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: moving 10024 bytes + --> $DIR/large_future.rs:20:13 + | +LL | let a = z.0; + | ^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/large_assignments/large_future.option.stderr b/tests/ui/lint/large_assignments/large_future.option.stderr new file mode 100644 index 0000000000000..734b7ff7ba22f --- /dev/null +++ b/tests/ui/lint/large_assignments/large_future.option.stderr @@ -0,0 +1,23 @@ +error: moving 10024 bytes + --> $DIR/large_future.rs:19:14 + | +LL | let z = (x, 42); + | ^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/large_future.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: moving 10024 bytes + --> $DIR/large_future.rs:20:13 + | +LL | let a = z.0; + | ^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/async-await/large_moves.rs b/tests/ui/lint/large_assignments/large_future.rs similarity index 59% rename from tests/ui/async-await/large_moves.rs rename to tests/ui/lint/large_assignments/large_future.rs index 485ca92fb89f9..834746fa97e71 100644 --- a/tests/ui/async-await/large_moves.rs +++ b/tests/ui/lint/large_assignments/large_future.rs @@ -9,8 +9,6 @@ // edition:2018 // compile-flags: -Zmir-opt-level=0 -use std::{sync::Arc, rc::Rc}; - fn main() { let x = async { let y = [0; 9999]; @@ -21,24 +19,8 @@ fn main() { let z = (x, 42); //~ ERROR large_assignments let a = z.0; //~ ERROR large_assignments let b = z.1; - let _ = Arc::new([0; 9999]); // OK! - let _ = Box::new([0; 9999]); // OK! - let _ = Rc::new([0; 9999]); // OK! - let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments } async fn thing(y: &[u8]) { dbg!(y); } - -struct NotBox { - data: [u8; 9999], -} - -impl NotBox { - fn new(data: [u8; 9999]) -> Self { - Self { - data, //~ ERROR large_assignments - } - } -}