Skip to content

Commit

Permalink
Rollup merge of rust-lang#108445 - gburgessiv:add-known-bug, r=compil…
Browse files Browse the repository at this point in the history
…er-errors

Add known-bug tests for a few I-unsound issues

Just a few commits to push rust-lang#105107 forward.

r? ``@jackh726``
  • Loading branch information
compiler-errors authored Feb 25, 2023
2 parents cb58440 + 6adc76d commit 4b8a3a6
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/ui/codegen/issue-107975-pointer-inequality.rs
Original file line number Diff line number Diff line change
@@ -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);
}
39 changes: 39 additions & 0 deletions tests/ui/specialization/issue-105787.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
type Assoc;
}

type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;

impl<T> Overlap<T> for T {
type Assoc = usize;
}

impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T
where
for<'a> *const T: ToUnit<'a>,
{
type Assoc = Box<usize>;
}

fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc {
x
}

fn main() {
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
}
Original file line number Diff line number Diff line change
@@ -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<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
Box::new(s)
}

fn main() {
let val = extend::<Opaque<'_>>(&String::from("blah blah blah"));
println!("{}", val);
}

0 comments on commit 4b8a3a6

Please sign in to comment.