Skip to content

Commit 2039d7e

Browse files
authored
Rollup merge of rust-lang#68236 - JohnTitor:ice-tests, r=Centril
Add some regression tests Closes rust-lang#64848 (fixed by rust-lang#67631) Closes rust-lang#65918 (ICE is hidden by rust-lang#67000, no longer ICE) Closes rust-lang#66473 (fixed by rust-lang#68084) Closes rust-lang#67550 (set mir-opt-level to 3) r? @Centril
2 parents 6270e49 + 3ba15bd commit 2039d7e

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

src/test/mir-opt/inline/inline-into-box-place.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// ignore-tidy-linelength
22
// ignore-wasm32-bare compiled with panic=abort by default
3+
// compile-flags: -Z mir-opt-level=3
34
#![feature(box_syntax)]
45

56
fn main() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// build-pass
2+
3+
trait AssociatedConstant {
4+
const DATA: ();
5+
}
6+
7+
impl<F, T> AssociatedConstant for F
8+
where
9+
F: FnOnce() -> T,
10+
T: AssociatedConstant,
11+
{
12+
const DATA: () = T::DATA;
13+
}
14+
15+
impl AssociatedConstant for () {
16+
const DATA: () = ();
17+
}
18+
19+
fn foo() -> impl AssociatedConstant {
20+
()
21+
}
22+
23+
fn get_data<T: AssociatedConstant>(_: T) -> &'static () {
24+
&T::DATA
25+
}
26+
27+
fn main() {
28+
get_data(foo);
29+
}

src/test/ui/issues/issue-66473.rs

113 Bytes
Binary file not shown.

src/test/ui/issues/issue-66473.stderr

2.57 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// build-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
use std::marker::PhantomData;
6+
7+
/* copied Index and TryFrom for convinience (and simplicity) */
8+
trait MyIndex<T> {
9+
type O;
10+
fn my_index(self) -> Self::O;
11+
}
12+
trait MyFrom<T>: Sized {
13+
type Error;
14+
fn my_from(value: T) -> Result<Self, Self::Error>;
15+
}
16+
17+
/* MCVE starts here */
18+
trait F {}
19+
impl F for () {}
20+
type DummyT<T> = impl F;
21+
fn _dummy_t<T>() -> DummyT<T> {}
22+
23+
struct Phantom1<T>(PhantomData<T>);
24+
struct Phantom2<T>(PhantomData<T>);
25+
struct Scope<T>(Phantom2<DummyT<T>>);
26+
27+
impl<T> Scope<T> {
28+
fn new() -> Self {
29+
unimplemented!()
30+
}
31+
}
32+
33+
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
34+
type Error = ();
35+
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
36+
unimplemented!()
37+
}
38+
}
39+
40+
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
41+
type O = T;
42+
fn my_index(self) -> Self::O {
43+
MyFrom::my_from(self.0).ok().unwrap()
44+
}
45+
}
46+
47+
fn main() {
48+
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
49+
}

0 commit comments

Comments
 (0)