diff options
Diffstat (limited to 'tests')
17 files changed, 212 insertions, 21 deletions
diff --git a/tests/crashes/130797.rs b/tests/crashes/130797.rs new file mode 100644 index 00000000000..e9c877d92a6 --- /dev/null +++ b/tests/crashes/130797.rs @@ -0,0 +1,23 @@ +//@ known-bug: #130797 + +trait Transform { + type Output<'a>; +} +trait Propagate<O> {} +trait AddChild<C> { + fn add_child(&self) {} +} + +pub struct Node<T>(T); +impl<T> AddChild<Box<dyn for<'b> Propagate<T::Output<'b>>>> for Node<T> where T: Transform {} + +fn make_graph_root() { + Node(Dummy).add_child() +} + +struct Dummy; +impl Transform for Dummy { + type Output<'a> = (); +} + +pub fn main() {} diff --git a/tests/crashes/132103.rs b/tests/crashes/132103.rs new file mode 100644 index 00000000000..5bf4792c44c --- /dev/null +++ b/tests/crashes/132103.rs @@ -0,0 +1,21 @@ +//@ known-bug: #132103 +//@compile-flags: -Zvalidate-mir --edition=2018 -Zinline-mir=yes +use core::future::{async_drop_in_place, Future}; +use core::mem::{self}; +use core::pin::pin; +use core::task::{Context, Waker}; + +async fn test_async_drop<T>(x: T) { + let mut x = mem::MaybeUninit::new(x); + pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) }); +} + +fn main() { + let waker = Waker::noop(); + let mut cx = Context::from_waker(&waker); + + let fut = pin!(async { + test_async_drop(test_async_drop(0)).await; + }); + fut.poll(&mut cx); +} diff --git a/tests/crashes/132960.rs b/tests/crashes/132960.rs new file mode 100644 index 00000000000..87d0ee7dede --- /dev/null +++ b/tests/crashes/132960.rs @@ -0,0 +1,36 @@ +//@ known-bug: #132960 + +#![feature(adt_const_params, const_ptr_read, generic_const_exprs)] + +const fn concat_strs<const A: &'static str, const B: &'static str>() -> &'static str +where + [(); A.len()]:, + [(); B.len()]:, + [(); A.len() + B.len()]:, +{ + #[repr(C)] + #[repr(C)] + + const fn concat_arr<const M: usize, const N: usize>(a: [u8; M], b: [u8; N]) -> [u8; M + N] {} + + struct Inner<const A: &'static str, const B: &'static str>; + impl<const A: &'static str, const B: &'static str> Inner<A, B> + where + [(); A.len()]:, + [(); B.len()]:, + [(); A.len() + B.len()]:, + { + const ABSTR: &'static str = unsafe { + std::str::from_utf8_unchecked(&concat_arr( + A.as_ptr().cast().read(), + B.as_ptr().cast().read(), + )) + }; + } + + Inner::<A, B>::ABSTR +} + +const FOO: &str = "foo"; +const BAR: &str = "bar"; +const FOOBAR: &str = concat_strs::<FOO, BAR>(); diff --git a/tests/crashes/133117.rs b/tests/crashes/133117.rs new file mode 100644 index 00000000000..751c82626d5 --- /dev/null +++ b/tests/crashes/133117.rs @@ -0,0 +1,8 @@ +//@ known-bug: #133117 + +fn main() { + match () { + (!|!) if true => {} + (!|!) if true => {} + } +} diff --git a/tests/crashes/133252.rs b/tests/crashes/133252.rs new file mode 100644 index 00000000000..3cecf448287 --- /dev/null +++ b/tests/crashes/133252.rs @@ -0,0 +1,43 @@ +//@ known-bug: #133252 +//@ edition:2021 +use std::future::Future; + +trait Owned: 'static {} +fn ice() -> impl Future<Output = &'static dyn Owned> { + async { + let not_static = 0; + force_send(async_load(¬_static)); + loop {} + } +} + +fn force_send<T: Send>(_: T) {} + +fn async_load<'a, T: LoadQuery<'a>>(this: T) -> impl Future { + async { + this.get_future().await; + } +} + +trait LoadQuery<'a>: Sized { + type LoadFuture: Future; + + fn get_future(self) -> Self::LoadFuture { + loop {} + } +} + +impl<'a> LoadQuery<'a> for &'a u8 { + type LoadFuture = SimpleFuture; +} + +struct SimpleFuture; +impl Future for SimpleFuture { + type Output = (); + fn poll( + self: std::pin::Pin<&mut Self>, + _: &mut std::task::Context<'_>, + ) -> std::task::Poll<Self::Output> { + loop {} + } +} diff --git a/tests/crashes/133613.rs b/tests/crashes/133613.rs new file mode 100644 index 00000000000..f01780d7cf4 --- /dev/null +++ b/tests/crashes/133613.rs @@ -0,0 +1,7 @@ +//@ known-bug: #133613 + +struct Wrapper<'a>(); + +trait IntFactory { + fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send>>; +} diff --git a/tests/crashes/134174.rs b/tests/crashes/134174.rs new file mode 100644 index 00000000000..899cdc6faf3 --- /dev/null +++ b/tests/crashes/134174.rs @@ -0,0 +1,17 @@ +//@ known-bug: #134175 +//@compile-flags: -Zvalidate-mir -Zinline-mir=yes +use std::vec::IntoIter; + +pub(crate) trait Foo: Iterator<Item = <Self as Foo>::Key> { + type Key; +} + +impl Foo for IntoIter<i16> {} + +fn sum_foo<F: Foo<Key = i32>>(f: F) -> i32 { + f.fold(0, |a, b| a + b) +} + +fn main() { + let x = sum_foo(vec![11, 10, 1].into_iter()); +} diff --git a/tests/crashes/134334.rs b/tests/crashes/134334.rs new file mode 100644 index 00000000000..d99df7bdc1e --- /dev/null +++ b/tests/crashes/134334.rs @@ -0,0 +1,9 @@ +//@ known-bug: #134334 +//@ only-x86_64 + +#[repr(simd)] +struct A(); + +fn main() { + std::arch::asm!("{}", in(xmm_reg) A()); +} diff --git a/tests/crashes/134335.rs b/tests/crashes/134335.rs new file mode 100644 index 00000000000..bee6686ff3f --- /dev/null +++ b/tests/crashes/134335.rs @@ -0,0 +1,12 @@ +//@ known-bug: #134335 +//@compile-flags: -Zunstable-options --edition=2024 --crate-type=lib +pub async fn async_closure(x: &mut i32) { + let c = async move || { + *x += 1; + }; + call_once(c).await; +} + +fn call_once<T>(f: impl FnOnce() -> T) -> T { + f() +} diff --git a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout index e9ee59abfae..e8c88d2dcdf 100644 --- a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout +++ b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout @@ -7,9 +7,7 @@ extern crate std; // issue#97006 macro_rules! m { ($attr_path: path) => { #[$attr_path] fn f() {} } } -#[ - -inline] +#[inline] fn f() { } fn main() { } diff --git a/tests/ui/structs/auxiliary/struct_field_default.rs b/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs index b315df5dba2..b315df5dba2 100644 --- a/tests/ui/structs/auxiliary/struct_field_default.rs +++ b/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs diff --git a/tests/ui/structs/default-field-values-failures.rs b/tests/ui/structs/default-field-values/failures.rs index 0ac071d91d6..0ac071d91d6 100644 --- a/tests/ui/structs/default-field-values-failures.rs +++ b/tests/ui/structs/default-field-values/failures.rs diff --git a/tests/ui/structs/default-field-values-failures.stderr b/tests/ui/structs/default-field-values/failures.stderr index 5b9d2df5a5d..65ec100fe2e 100644 --- a/tests/ui/structs/default-field-values-failures.stderr +++ b/tests/ui/structs/default-field-values/failures.stderr @@ -1,5 +1,5 @@ error: the `#[default]` attribute may only be used on unit enum variants or variants where every field has a default value - --> $DIR/default-field-values-failures.rs:47:5 + --> $DIR/failures.rs:47:5 | LL | Variant {} | ^^^^^^^ @@ -7,7 +7,7 @@ LL | Variant {} = help: consider a manual implementation of `Default` error: generic parameters may not be used in const operations - --> $DIR/default-field-values-failures.rs:22:23 + --> $DIR/failures.rs:22:23 | LL | bat: i32 = <Qux<{ C }> as T>::K, | ^ cannot perform const operation using `C` @@ -16,19 +16,19 @@ LL | bat: i32 = <Qux<{ C }> as T>::K, = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: default fields are not supported in tuple structs - --> $DIR/default-field-values-failures.rs:26:22 + --> $DIR/failures.rs:26:22 | LL | pub struct Rak(i32 = 42); | ^^ default fields are only supported on structs error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/default-field-values-failures.rs:20:14 + --> $DIR/failures.rs:20:14 | LL | bar: S = Self::S, | ^^^^ error[E0277]: the trait bound `S: Default` is not satisfied - --> $DIR/default-field-values-failures.rs:14:5 + --> $DIR/failures.rs:14:5 | LL | #[derive(Debug, Default)] | ------- in this derive macro expansion @@ -44,13 +44,13 @@ LL | pub struct S; | error: missing mandatory field `bar` - --> $DIR/default-field-values-failures.rs:53:21 + --> $DIR/failures.rs:53:21 | LL | let _ = Bar { .. }; | ^ error[E0308]: mismatched types - --> $DIR/default-field-values-failures.rs:57:17 + --> $DIR/failures.rs:57:17 | LL | let _ = Rak(..); | --- ^^ expected `i32`, found `RangeFull` @@ -58,29 +58,29 @@ LL | let _ = Rak(..); | arguments to this struct are incorrect | note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:57:17 + --> $DIR/failures.rs:57:17 | LL | let _ = Rak(..); | ^^ error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/default-field-values-failures.rs:59:13 + --> $DIR/failures.rs:59:13 | LL | let _ = Rak(0, ..); | ^^^ -- unexpected argument #2 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:59:20 + --> $DIR/failures.rs:59:20 | LL | let _ = Rak(0, ..); | ^^ note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ @@ -91,18 +91,18 @@ LL + let _ = Rak(0); | error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/default-field-values-failures.rs:61:13 + --> $DIR/failures.rs:61:13 | LL | let _ = Rak(.., 0); | ^^^ -- unexpected argument #1 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:61:17 + --> $DIR/failures.rs:61:17 | LL | let _ = Rak(.., 0); | ^^ note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ diff --git a/tests/ui/structs/default-field-values-invalid-const.rs b/tests/ui/structs/default-field-values/invalid-const.rs index 203a712868b..203a712868b 100644 --- a/tests/ui/structs/default-field-values-invalid-const.rs +++ b/tests/ui/structs/default-field-values/invalid-const.rs diff --git a/tests/ui/structs/default-field-values-invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr index 47f25a1f38e..f4a3437031b 100644 --- a/tests/ui/structs/default-field-values-invalid-const.stderr +++ b/tests/ui/structs/default-field-values/invalid-const.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> $DIR/default-field-values-invalid-const.rs:5:19 + --> $DIR/invalid-const.rs:5:19 | LL | pub bax: u8 = panic!("asdf"), - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:5:19 + | ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/invalid-const.rs:5:19 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of `Baz::<C>::bat::{constant#0}` failed - --> $DIR/default-field-values-invalid-const.rs:11:19 + --> $DIR/invalid-const.rs:11:19 | LL | pub bat: u8 = 130 + 130, | ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow diff --git a/tests/ui/structs/default-field-values-support.rs b/tests/ui/structs/default-field-values/support.rs index 8209d6dd4a0..8209d6dd4a0 100644 --- a/tests/ui/structs/default-field-values-support.rs +++ b/tests/ui/structs/default-field-values/support.rs diff --git a/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs b/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs new file mode 100644 index 00000000000..bb14524608d --- /dev/null +++ b/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs @@ -0,0 +1,17 @@ +//@ check-pass + +#![feature(default_field_values)] + +struct Value<const VALUE: u8>; + +impl<const VALUE: u8> Value<VALUE> { + pub const VALUE: Self = Self; +} + +pub struct WithUse { + _use: Value<{ 0 + 0 }> = Value::VALUE +} + +const _: WithUse = WithUse { .. }; + +fn main() {} |
