]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-35570.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / issues / issue-35570.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(rustc_attrs)]
12
13 use std::mem;
14
15 trait Trait1<T> {}
16 trait Trait2<'a> {
17   type Ty;
18 }
19
20 fn _ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
21     let _e: (usize, usize) = unsafe{mem::transmute(param)};
22 }
23
24 trait Lifetime<'a> {
25     type Out;
26 }
27 impl<'a> Lifetime<'a> for () {
28     type Out = &'a ();
29 }
30 fn foo<'a>(x: &'a ()) -> <() as Lifetime<'a>>::Out {
31     x
32 }
33
34 fn takes_lifetime(_f: for<'a> fn(&'a ()) -> <() as Lifetime<'a>>::Out) {
35 }
36
37 #[rustc_error]
38 fn main() { //~ ERROR compilation successful
39     takes_lifetime(foo);
40 }