diff options
| author | bors <bors@rust-lang.org> | 2024-02-11 17:43:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-11 17:43:51 +0000 |
| commit | a166af7729d6f4e6570918701f79dfae750a00c4 (patch) | |
| tree | 3d1a116ad7d2c6af70cd581af360a81d3f29494d /tests | |
| parent | 980cf089f48b3cab018808f509dbb716ecf8e314 (diff) | |
| parent | 870435b50bf1b80285be8e80cedb4cdeb5419874 (diff) | |
| download | rust-a166af7729d6f4e6570918701f79dfae750a00c4.tar.gz rust-a166af7729d6f4e6570918701f79dfae750a00c4.zip | |
Auto merge of #120903 - matthiaskrgr:rollup-tmsuzth, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #119213 (simd intrinsics: add simd_shuffle_generic and other missing intrinsics) - #120272 (Suppress suggestions in derive macro) - #120773 (large_assignments: Allow moves into functions) - #120874 (Take empty `where` bounds into account when suggesting predicates) - #120882 (interpret/write_discriminant: when encoding niched variant, ensure the stored value matches) - #120883 (interpret: rename ReadExternStatic → ExternStatic) - #120890 (Adapt `llvm-has-rust-patches` validation to take `llvm-config` into account.) - #120895 (don't skip coercions for types with errors) - #120896 (Print kind of coroutine closure) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
32 files changed, 308 insertions, 110 deletions
diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs index 40b0febbf06..81666cada31 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.rs +++ b/tests/ui/async-await/async-closures/is-not-fn.rs @@ -5,5 +5,5 @@ fn main() { fn needs_fn(x: impl FnOnce()) {} needs_fn(async || {}); - //~^ ERROR expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()` + //~^ ERROR expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()` } diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.stderr index 6169cee85fd..130746ece67 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` --> $DIR/is-not-fn.rs:7:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/async-closures/move-consuming-capture.stderr b/tests/ui/async-await/async-closures/move-consuming-capture.stderr index 2c2a0d1162d..45c1eac8f8f 100644 --- a/tests/ui/async-await/async-closures/move-consuming-capture.stderr +++ b/tests/ui/async-await/async-closures/move-consuming-capture.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/move-consuming-capture.rs:17:9 | LL | let x = async move || { - | - move occurs because `x` has type `{coroutine-closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait + | - move occurs because `x` has type `{async closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait ... LL | x().await; | --- `x` moved due to this method call diff --git a/tests/ui/coercion/type-errors.rs b/tests/ui/coercion/type-errors.rs new file mode 100644 index 00000000000..a2f0e55f1b9 --- /dev/null +++ b/tests/ui/coercion/type-errors.rs @@ -0,0 +1,15 @@ +// Regression test for an ICE: https://github.com/rust-lang/rust/issues/120884 +// We still need to properly go through coercions between types with errors instead of +// shortcutting and returning success, because we need the adjustments for building the MIR. + +pub fn has_error() -> TypeError {} +//~^ ERROR cannot find type `TypeError` in this scope + +pub fn cast() -> *const u8 { + // Casting a function item to a data pointer in valid in HIR, but invalid in MIR. + // We need an adjustment (ReifyFnPointer) to insert a cast from the function item + // to a function pointer as a separate MIR statement. + has_error as *const u8 +} + +fn main() {} diff --git a/tests/ui/coercion/type-errors.stderr b/tests/ui/coercion/type-errors.stderr new file mode 100644 index 00000000000..489cd9ddf13 --- /dev/null +++ b/tests/ui/coercion/type-errors.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/type-errors.rs:5:23 + | +LL | pub fn has_error() -> TypeError {} + | ^^^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/consts/miri_unleashed/extern-static.rs b/tests/ui/consts/miri_unleashed/extern-static.rs new file mode 100644 index 00000000000..81176b3d4e9 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.rs @@ -0,0 +1,24 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(thread_local)] +#![allow(static_mut_ref)] + +extern "C" { + static mut DATA: u8; +} + +// Make sure we catch accessing extern static. +static TEST_READ: () = { + unsafe { let _val = DATA; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; +static TEST_WRITE: () = { + unsafe { DATA = 0; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; + +// Just creating a reference is fine, as long as we are not reading or writing. +static TEST_REF: &u8 = unsafe { &DATA }; + +fn main() {} diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr new file mode 100644 index 00000000000..0979a5e4fb1 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -0,0 +1,15 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:11:25 + | +LL | unsafe { let _val = DATA; } + | ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:16:14 + | +LL | unsafe { DATA = 0; } + | ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/tls.rs b/tests/ui/consts/miri_unleashed/tls.rs index d06d7cf19f7..7319a5135d3 100644 --- a/tests/ui/consts/miri_unleashed/tls.rs +++ b/tests/ui/consts/miri_unleashed/tls.rs @@ -14,6 +14,8 @@ static TEST_BAD: () = { }; // Make sure we catch taking a reference to thread-local storage. +// The actual pointer depends on the thread, so even just taking a reference already does not make +// sense at compile-time. static TEST_BAD_REF: () = { unsafe { let _val = &A; } //~^ ERROR could not evaluate static initializer diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index ec24527d6c0..a00b7eb1312 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -5,7 +5,7 @@ LL | unsafe { let _val = A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) @@ -18,7 +18,7 @@ help: skipping check that does not even have a feature gate LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/tests/ui/error-codes/E0401.rs b/tests/ui/error-codes/E0401.rs index 8f8d6b87ef2..a120198b728 100644 --- a/tests/ui/error-codes/E0401.rs +++ b/tests/ui/error-codes/E0401.rs @@ -9,8 +9,6 @@ fn foo<T>(x: T) { (y: T) { //~ ERROR E0401 } bfnr(x); - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } diff --git a/tests/ui/error-codes/E0401.stderr b/tests/ui/error-codes/E0401.stderr index 754867061c7..5d6878620c8 100644 --- a/tests/ui/error-codes/E0401.stderr +++ b/tests/ui/error-codes/E0401.stderr @@ -21,7 +21,7 @@ LL | (y: T) { | ^ use of generic parameter from outer item error[E0401]: can't use `Self` from outer item - --> $DIR/E0401.rs:24:25 + --> $DIR/E0401.rs:22:25 | LL | impl<T> Iterator for A<T> { | ---- `Self` type implicitly declared here, by this `impl` @@ -32,45 +32,6 @@ LL | fn helper(sel: &Self) -> u8 { | use of `Self` from outer item | refer to the type directly here instead -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `V` declared on the function `bfnr` - | - = note: cannot satisfy `_: Baz<_>` -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:19 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `W` declared on the function `bfnr` - | - = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: - - impl<A, F> Fn<A> for &F - where A: Tuple, F: Fn<A>, F: ?Sized; - - impl<Args, F, A> Fn<Args> for Box<F, A> - where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized; -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:30 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0283, E0401. -For more information about an error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs deleted file mode 100644 index 33113642023..00000000000 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![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/copy_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs new file mode 100644 index 00000000000..866a4d10ff5 --- /dev/null +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=1 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + let data = [0; 9999]; + + // Looking at --emit mir, we can see that all parameters below are passed by + // copy. But it requires at least mir-opt-level=1. + let _ = Arc::new(data); // OK! + let _ = Box::new(data); // OK! + let _ = Rc::new(data); // OK! + + // Looking at --emit llvm-ir, we can see that a memcpy is involved in the + // parameter passing. So we want the lint to trigger here. + let _ = NotBox::new(data); //~ ERROR large_assignments +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + Self { //~ ERROR large_assignments + data, + } + } +} diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr index fefb3a9621b..6e42328a111 100644 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr @@ -1,21 +1,23 @@ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:16:25 + --> $DIR/copy_into_box_rc_arc.rs:23:25 | -LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^ value moved from here +LL | let _ = NotBox::new(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 = "..."]` note: the lint level is defined here - --> $DIR/box_rc_arc_allowed.rs:1:9 + --> $DIR/copy_into_box_rc_arc.rs:1:9 | LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:26:13 + --> $DIR/copy_into_box_rc_arc.rs:34:9 | -LL | data, - | ^^^^ value moved from here +LL | / Self { +LL | | data, +LL | | } + | |_________^ 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 = "..."]` diff --git a/tests/ui/lint/large_assignments/large_future.rs b/tests/ui/lint/large_assignments/large_future.rs index 834746fa97e..a69ff356c6b 100644 --- a/tests/ui/lint/large_assignments/large_future.rs +++ b/tests/ui/lint/large_assignments/large_future.rs @@ -2,7 +2,7 @@ #![cfg_attr(attribute, feature(large_assignments))] #![cfg_attr(attribute, move_size_limit = "1000")] // build-fail -// only-x86_64 +// only-64bit // revisions: attribute option // [option]compile-flags: -Zmove-size-limit=1000 diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs new file mode 100644 index 00000000000..b7a70dfdda0 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=0 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + // Looking at --emit mir, we can see that all parameters below are passed + // by move. + let _ = Arc::new([0; 9999]); // OK! + let _ = Box::new([0; 9999]); // OK! + let _ = Rc::new([0; 9999]); // OK! + + // Looking at --emit llvm-ir, we can see that no memcpy is involved in the + // parameter passing. Instead, a pointer is passed. This is typically what + // we get when moving parameter into functions. So we don't want the lint to + // trigger here. + let _ = NotBox::new([0; 9999]); // OK (compare with copy_into_box_rc_arc.rs) +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + data, //~ ERROR large_assignments + } + } +} diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr new file mode 100644 index 00000000000..a386de5e5e8 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_box_rc_arc.rs:35: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 = "..."]` +note: the lint level is defined here + --> $DIR/move_into_box_rc_arc.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/large_assignments/move_into_fn.rs b/tests/ui/lint/large_assignments/move_into_fn.rs new file mode 100644 index 00000000000..359705bfc03 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.rs @@ -0,0 +1,22 @@ +// build-fail + +#![feature(large_assignments)] +#![move_size_limit = "1000"] +#![deny(large_assignments)] +#![allow(unused)] + +// Note: This type does not implement Copy. +struct Data([u8; 9999]); + +fn main() { + // Looking at llvm-ir output, we can see a memcpy'd into Data, so we want + // the lint to trigger here. + let data = Data([100; 9999]); //~ ERROR large_assignments + + // Looking at llvm-ir output, we can see that there is no memcpy involved in + // this function call. Instead, just a pointer is passed to the function. So + // the lint shall not trigger here. + take_data(data); +} + +fn take_data(data: Data) {} diff --git a/tests/ui/lint/large_assignments/move_into_fn.stderr b/tests/ui/lint/large_assignments/move_into_fn.stderr new file mode 100644 index 00000000000..92a0489e472 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_fn.rs:14:16 + | +LL | let data = Data([100; 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/move_into_fn.rs:5:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/proc-macro/auxiliary/issue-118809.rs b/tests/ui/proc-macro/auxiliary/issue-118809.rs new file mode 100644 index 00000000000..029b58c6d0c --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/issue-118809.rs @@ -0,0 +1,20 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(Deserialize)] +pub fn deserialize_derive(input: TokenStream) -> TokenStream { + "impl Build { + fn deserialize() -> Option<u64> { + let x: Option<u32> = Some(0); + Some(x? + 1) + } + } + " + .parse() + .unwrap() +} diff --git a/tests/ui/proc-macro/issue-118809.rs b/tests/ui/proc-macro/issue-118809.rs new file mode 100644 index 00000000000..732bf19c173 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.rs @@ -0,0 +1,10 @@ +// aux-build: issue-118809.rs + +#[macro_use] +extern crate issue_118809; + +#[derive(Deserialize)] //~ ERROR mismatched types [E0308] +pub struct Build { +} + +fn main() {} diff --git a/tests/ui/proc-macro/issue-118809.stderr b/tests/ui/proc-macro/issue-118809.stderr new file mode 100644 index 00000000000..30b09fd4006 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ + | | + | expected `u64`, found `u32` + | arguments to this enum variant are incorrect + | +help: the type constructed contains `u32` due to the type of the argument passed + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ this argument influences the type of `Some` +note: tuple variant defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index dc4ec5d3ee2..ec9826819c0 100644 --- a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -18,16 +18,16 @@ help: use parentheses to call this function LL | bar(foo()); | ++ -error[E0277]: `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future +error[E0277]: `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | LL | bar(async_closure); - | --- ^^^^^^^^^^^^^ `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future + | --- ^^^^^^^^^^^^^ `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` - = note: {coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` + = note: {async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `bar` --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16 | diff --git a/tests/ui/trait-impl-bound-suggestions.fixed b/tests/ui/trait-impl-bound-suggestions.fixed index 744e7bef04e..fb11286a175 100644 --- a/tests/ui/trait-impl-bound-suggestions.fixed +++ b/tests/ui/trait-impl-bound-suggestions.fixed @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.rs b/tests/ui/trait-impl-bound-suggestions.rs index bf75175179e..46130a5e766 100644 --- a/tests/ui/trait-impl-bound-suggestions.rs +++ b/tests/ui/trait-impl-bound-suggestions.rs @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.stderr b/tests/ui/trait-impl-bound-suggestions.stderr index c1f31e2b32e..9883c5bda01 100644 --- a/tests/ui/trait-impl-bound-suggestions.stderr +++ b/tests/ui/trait-impl-bound-suggestions.stderr @@ -14,6 +14,22 @@ help: consider further restricting type parameter `X` LL | trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { | ++++++++++++++++++++++++++ -error: aborting due to 1 previous error +error[E0277]: the trait bound `X: Copy` is not satisfied + --> $DIR/trait-impl-bound-suggestions.rs:23:52 + | +LL | fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `X` + | +note: required by a bound in `ConstrainedStruct` + --> $DIR/trait-impl-bound-suggestions.rs:8:29 + | +LL | struct ConstrainedStruct<X: Copy> { + | ^^^^ required by this bound in `ConstrainedStruct` +help: consider further restricting type parameter `X` + | +LL | trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + | ++++++++++++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-104510-ice.rs b/tests/ui/typeck/issue-104510-ice.rs index 635cc8fad66..157bdf07e38 100644 --- a/tests/ui/typeck/issue-104510-ice.rs +++ b/tests/ui/typeck/issue-104510-ice.rs @@ -6,7 +6,7 @@ struct W<T: ?Sized>(Oops); unsafe fn test() { let j = W(()); - let pointer = &j as *const _; //~ ERROR type annotations needed + let pointer = &j as *const _; core::arch::asm!( "nop", in("eax") pointer, diff --git a/tests/ui/typeck/issue-104510-ice.stderr b/tests/ui/typeck/issue-104510-ice.stderr index 774e5268184..143139b2c08 100644 --- a/tests/ui/typeck/issue-104510-ice.stderr +++ b/tests/ui/typeck/issue-104510-ice.stderr @@ -4,18 +4,6 @@ error[E0412]: cannot find type `Oops` in this scope LL | struct W<T: ?Sized>(Oops); | ^^^^ not found in this scope -error[E0282]: type annotations needed for `*const W<T>` - --> $DIR/issue-104510-ice.rs:9:9 - | -LL | let pointer = &j as *const _; - | ^^^^^^^ - | -help: consider giving `pointer` an explicit type, where the type for type parameter `T` is specified - | -LL | let pointer: *const W<T> = &j as *const _; - | +++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0282, E0412. -For more information about an error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0412`. |
