]> git.proxmox.com Git - rustc.git/blob - src/test/ui/inference/type-infer-generalize-ty-var.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / inference / type-infer-generalize-ty-var.rs
1 // run-pass
2
3 #![allow(non_upper_case_globals)]
4 #![allow(dead_code)]
5 #![allow(unused_assignments)]
6 #![allow(unused_variables)]
7 // Test a scenario where we generate a constraint like `?1 <: &?2`.
8 // In such a case, it is important that we instantiate `?1` with `&?3`
9 // where `?3 <: ?2`, and not with `&?2`. This is a regression test for
10 // #18653. The important thing is that we build.
11
12 use std::cell::RefCell;
13
14 enum Wrap<A> {
15 WrapSome(A),
16 WrapNone
17 }
18
19 use Wrap::*;
20
21 struct T;
22 struct U;
23
24 trait Get<T: ?Sized> {
25 fn get(&self) -> &T;
26 }
27
28 impl Get<dyn MyShow + 'static> for Wrap<T> {
29 fn get(&self) -> &(dyn MyShow + 'static) {
30 static x: usize = 42;
31 &x
32 }
33 }
34
35 impl Get<usize> for Wrap<U> {
36 fn get(&self) -> &usize {
37 static x: usize = 55;
38 &x
39 }
40 }
41
42 trait MyShow { fn dummy(&self) { } }
43 impl<'a> MyShow for &'a (dyn MyShow + 'a) { }
44 impl MyShow for usize { }
45 fn constrain<'a>(rc: RefCell<&'a (dyn MyShow + 'a)>) { }
46
47 fn main() {
48 let mut collection: Wrap<_> = WrapNone;
49
50 {
51 let __arg0 = Get::get(&collection);
52 let __args_cell = RefCell::new(__arg0);
53 constrain(__args_cell);
54 }
55 collection = WrapSome(T);
56 }