]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/hrtb-opt-in-copy.rs
Auto merge of #22541 - Manishearth:rollup, r=Gankro
[rust.git] / src / test / run-pass / hrtb-opt-in-copy.rs
1 // Copyright 2014 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 // Test that we handle binder levels correctly when checking whether a
12 // type can implement `Copy`. In particular, we had a bug where we failed to
13 // liberate the late-bound regions from the impl, and thus wound up
14 // searching for an impl of `for<'tcx> Foo<&'tcx T>`. The impl that
15 // exists however is `impl<T> Copy for Foo<T>` and the current rules
16 // did not consider that a match (something I would like to revise in
17 // a later PR).
18
19 #![allow(dead_code)]
20
21 use std::marker::PhantomData;
22
23 #[derive(Copy)]
24 struct Foo<T> { x: T }
25
26 type Ty<'tcx> = &'tcx TyS<'tcx>;
27
28 enum TyS<'tcx> {
29     Boop(PhantomData<*mut &'tcx ()>)
30 }
31
32 #[derive(Copy)]
33 enum Bar<'tcx> {
34     Baz(Foo<Ty<'tcx>>)
35 }
36
37 fn main() { }