diff --git a/tests/ui/codegen/issue-107975-pointer-inequality.rs b/tests/ui/codegen/issue-107975-pointer-inequality.rs new file mode 100644 index 0000000000000..b3c9d71a9bf70 --- /dev/null +++ b/tests/ui/codegen/issue-107975-pointer-inequality.rs @@ -0,0 +1,17 @@ +// run-pass +// known-bug: #107975 +fn main() { + let a: *const u8; + let b: *const u8; + { + let v: [u8; 16] = [core::hint::black_box(0); 16]; + a = &(v[0]); + } + { + let v: [u8; 16] = [core::hint::black_box(0); 16]; + b = &(v[0]); + } + assert_ne!(a, b); + println!("{a:?} {b:?}"); + assert_eq!(a, b); +} diff --git a/tests/ui/specialization/issue-105787.rs b/tests/ui/specialization/issue-105787.rs new file mode 100644 index 0000000000000..3cf655de2e5e1 --- /dev/null +++ b/tests/ui/specialization/issue-105787.rs @@ -0,0 +1,39 @@ +// check-pass +// known-bug: #105787 +trait ToUnit<'a> { + type Unit; +} + +struct LocalTy; +impl<'a> ToUnit<'a> for *const LocalTy { + type Unit = (); +} + +impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T { + type Unit = (); +} + +trait Overlap { + type Assoc; +} + +type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; + +impl Overlap for T { + type Assoc = usize; +} + +impl Overlap fn(&'a (), Assoc<'a, T>)> for T +where + for<'a> *const T: ToUnit<'a>, +{ + type Assoc = Box; +} + +fn foo, U>(x: T::Assoc) -> T::Assoc { + x +} + +fn main() { + foo:: fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize); +} diff --git a/tests/ui/type-alias-impl-trait/issue-108425-impl-generics-unsoundness.rs b/tests/ui/type-alias-impl-trait/issue-108425-impl-generics-unsoundness.rs new file mode 100644 index 0000000000000..b0dbc0a014b77 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-108425-impl-generics-unsoundness.rs @@ -0,0 +1,25 @@ +// known-bug: #108425 +// check-pass +#![feature(type_alias_impl_trait)] +use std::fmt::Display; + +type Opaque<'a> = impl Sized + 'static; +fn define<'a>() -> Opaque<'a> {} + +trait Trait { + type Assoc: Display; +} +impl<'a> Trait for Opaque<'a> { + type Assoc = &'a str; +} + +// ======= Exploit ======= + +fn extend(s: T::Assoc) -> Box { + Box::new(s) +} + +fn main() { + let val = extend::>(&String::from("blah blah blah")); + println!("{}", val); +}