diff --git a/tests/crashes/147719.rs b/tests/crashes/147719.rs new file mode 100644 index 0000000000000..d9595b8ead565 --- /dev/null +++ b/tests/crashes/147719.rs @@ -0,0 +1,16 @@ +//@ known-bug: #147719 +//@ edition: 2024 +trait NodeImpl {} +struct Wrap(F, P); +impl Wrap { + fn new(_: F) -> Self { + loop {} + } +} +trait Arg {} +impl NodeImpl for Wrap where A: Arg {} +impl NodeImpl for Wrap where F: Fn(&(), A) -> Fut {} +fn trigger_ice() { + let _: &dyn NodeImpl = &Wrap::<_, (i128,)>::new(async |_: &(), i128| 0); +} +fn main() {} diff --git a/tests/crashes/148511.rs b/tests/crashes/148511.rs new file mode 100644 index 0000000000000..69203ebeb2d21 --- /dev/null +++ b/tests/crashes/148511.rs @@ -0,0 +1,42 @@ +//@ known-bug: #148511 +//@ edition: 2021 +use std::any::Any; + +fn main() { + use_service(make_service()); + let _future = async {}; +} + +fn make_service() -> impl FooService, Response: Body> {} + +fn use_service(_service: S) +where + S: FooService, + ::Data: Any, +{ +} + +trait Service { + type Response: Body; +} + +impl Service for T { + type Response = (); +} + +trait FooService: Service {} + +impl FooService for T +where + T: Service, + Resp: Body, +{ +} + +trait Body { + type Data; +} + +impl Body for T { + type Data = (); +} diff --git a/tests/crashes/148629.rs b/tests/crashes/148629.rs new file mode 100644 index 0000000000000..926b4cc75c952 --- /dev/null +++ b/tests/crashes/148629.rs @@ -0,0 +1,13 @@ +//@ known-bug: #148629 +#![feature(with_negative_coherence)] +trait Foo { + type AssociatedType; +} + +impl Foo for [(); N] {} + +pub struct Happy; + +impl Foo for Happy {} + +impl Foo for Happy where <[(); N] as Foo>::AssociatedType: Clone {} diff --git a/tests/crashes/148630.rs b/tests/crashes/148630.rs new file mode 100644 index 0000000000000..7b857bbb408a1 --- /dev/null +++ b/tests/crashes/148630.rs @@ -0,0 +1,13 @@ +//@ known-bug: #148630 +#![feature(unboxed_closures)] + +trait Tr {} +trait Foo { + fn foo() -> impl Sized + where + for<'a> <() as FnOnce<&'a i32>>::Output: Tr, + { + } +} + +fn main() {} diff --git a/tests/crashes/148632.rs b/tests/crashes/148632.rs new file mode 100644 index 0000000000000..c77ff5e8d7954 --- /dev/null +++ b/tests/crashes/148632.rs @@ -0,0 +1,10 @@ +//@ known-bug: #148632 +trait D {} + +trait Project { + const SELF: dyn D; +} + +fn main() { + let _: &dyn Project; +} diff --git a/tests/crashes/148890.rs b/tests/crashes/148890.rs new file mode 100644 index 0000000000000..6e78ca6717f15 --- /dev/null +++ b/tests/crashes/148890.rs @@ -0,0 +1,6 @@ +//@ known-bug: #148890 +impl std::ops::Neg for u128 {} + +fn foo(-128..=127: u128) {} + +fn main() {} diff --git a/tests/crashes/148891.rs b/tests/crashes/148891.rs new file mode 100644 index 0000000000000..75534440d4902 --- /dev/null +++ b/tests/crashes/148891.rs @@ -0,0 +1,14 @@ +//@ known-bug: #148891 +macro_rules! values { + ($inner:ty) => { + #[derive(Debug)] + pub enum TokenKind { + #[cfg(test)] + STRING ([u8; $inner]), + } + }; +} + +values!(String); + +pub fn main() {} diff --git a/tests/crashes/149162.rs b/tests/crashes/149162.rs new file mode 100644 index 0000000000000..33532fe365ba4 --- /dev/null +++ b/tests/crashes/149162.rs @@ -0,0 +1,30 @@ +//@ known-bug: #149162 +use std::marker::PhantomData; +pub trait ViewArgument { + type Params<'a>; +} + +impl ViewArgument for () { + type Params<'a> = (); +} + +pub trait View {} + +pub fn buttons() -> Option { + Some(()).map(|()| text_button(|()| {})) +} +pub fn text_button( + _: impl Fn(::Params<'_>), +) -> Button { + Button { + callback: || (), + phantom: PhantomData, + } +} +pub struct Button { + pub callback: F, + pub phantom: PhantomData, +} + +impl View for Button<(), F> {} +fn main() {} diff --git a/tests/crashes/149703.rs b/tests/crashes/149703.rs new file mode 100644 index 0000000000000..40d78484307a6 --- /dev/null +++ b/tests/crashes/149703.rs @@ -0,0 +1,12 @@ +//@ known-bug: #149703 +#![feature(const_trait_impl)] +trait Z { + type Assoc; +} +struct A; +impl Z for T { + type Assoc = (); +} +impl From<::Assoc> for T {} + +fn main() {} diff --git a/tests/crashes/152205.rs b/tests/crashes/152205.rs new file mode 100644 index 0000000000000..d6e5a92df5d7a --- /dev/null +++ b/tests/crashes/152205.rs @@ -0,0 +1,20 @@ +//@ known-bug: #152205 +#![deny(rust_2021_incompatible_closure_captures)] +struct Foo; +struct S; +impl Drop for S { + fn drop(&mut self) {} +} +struct U(::Assoc); +fn test_precise_analysis_long_path(u: U) { + let _ = || { + let _x = u.0.0; + }; +} +trait NewTrait { + type Assoc; +} +impl NewTrait for Foo { + type Assoc = (S,); +} +fn main(){} diff --git a/tests/crashes/152295.rs b/tests/crashes/152295.rs new file mode 100644 index 0000000000000..85e23f0f41037 --- /dev/null +++ b/tests/crashes/152295.rs @@ -0,0 +1,11 @@ +//@ known-bug: #152295 +#![feature(type_alias_impl_trait)] +type Tait = impl Sized; +trait Foo: Bar {} +trait Bar { + fn bar(&self); +} +fn test_correct2(x: &dyn Foo) { + x.bar(); +} +fn main() {} diff --git a/tests/crashes/154556.rs b/tests/crashes/154556.rs new file mode 100644 index 0000000000000..d858588c11ec2 --- /dev/null +++ b/tests/crashes/154556.rs @@ -0,0 +1,25 @@ +//@ known-bug: #154556 +#![feature(generic_const_exprs)] + +pub trait Foo { + // Has to take self or a reference to self to ICE. + fn eq(self); +} + +pub trait Bar { + const NUMBER: usize; +} + +impl Foo for T +where + [(); T::NUMBER]: Sized, // Bound required for ICE +{ + fn eq(self) {} +} + +// As long as the method called below has the same name as the one defined in Foo, the ICE happens. +fn baz() { + ().eq(&()); +} + +fn main() {} diff --git a/tests/crashes/154964.rs b/tests/crashes/154964.rs new file mode 100644 index 0000000000000..d44700f5a92b3 --- /dev/null +++ b/tests/crashes/154964.rs @@ -0,0 +1,9 @@ +//@ known-bug: #154964 +//@ edition: 2021 +//@ compile-flags: -Zprint-type-sizes +fn main() { + |foo: Foo<_>| async { foo.bar }; +} +struct Foo { + bar: (), +} diff --git a/tests/crashes/157568.rs b/tests/crashes/157568.rs new file mode 100644 index 0000000000000..627bfbadf6bc4 --- /dev/null +++ b/tests/crashes/157568.rs @@ -0,0 +1,10 @@ +//@ known-bug: #157568 +//@ compile-flags: -Zpolonius +#![warn(rust_2024_compatibility)] +pub struct F; +impl std::fmt::Debug for F { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("F").finish_non_exhaustive() + } +} +fn main() {}