Skip to content

Commit fd548b2

Browse files
Rollup merge of rust-lang#108445 - gburgessiv:add-known-bug, r=compiler-errors
Add known-bug tests for a few I-unsound issues Just a few commits to push rust-lang#105107 forward. r? `@jackh726`
2 parents c894630 + 6adc76d commit fd548b2

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

Diff for: tests/ui/codegen/issue-107975-pointer-inequality.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// run-pass
2+
// known-bug: #107975
3+
fn main() {
4+
let a: *const u8;
5+
let b: *const u8;
6+
{
7+
let v: [u8; 16] = [core::hint::black_box(0); 16];
8+
a = &(v[0]);
9+
}
10+
{
11+
let v: [u8; 16] = [core::hint::black_box(0); 16];
12+
b = &(v[0]);
13+
}
14+
assert_ne!(a, b);
15+
println!("{a:?} {b:?}");
16+
assert_eq!(a, b);
17+
}

Diff for: tests/ui/specialization/issue-105787.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
// known-bug: #105787
3+
trait ToUnit<'a> {
4+
type Unit;
5+
}
6+
7+
struct LocalTy;
8+
impl<'a> ToUnit<'a> for *const LocalTy {
9+
type Unit = ();
10+
}
11+
12+
impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T {
13+
type Unit = ();
14+
}
15+
16+
trait Overlap<T> {
17+
type Assoc;
18+
}
19+
20+
type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;
21+
22+
impl<T> Overlap<T> for T {
23+
type Assoc = usize;
24+
}
25+
26+
impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T
27+
where
28+
for<'a> *const T: ToUnit<'a>,
29+
{
30+
type Assoc = Box<usize>;
31+
}
32+
33+
fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc {
34+
x
35+
}
36+
37+
fn main() {
38+
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// known-bug: #108425
2+
// check-pass
3+
#![feature(type_alias_impl_trait)]
4+
use std::fmt::Display;
5+
6+
type Opaque<'a> = impl Sized + 'static;
7+
fn define<'a>() -> Opaque<'a> {}
8+
9+
trait Trait {
10+
type Assoc: Display;
11+
}
12+
impl<'a> Trait for Opaque<'a> {
13+
type Assoc = &'a str;
14+
}
15+
16+
// ======= Exploit =======
17+
18+
fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
19+
Box::new(s)
20+
}
21+
22+
fn main() {
23+
let val = extend::<Opaque<'_>>(&String::from("blah blah blah"));
24+
println!("{}", val);
25+
}

0 commit comments

Comments
 (0)