Debian Codegraph @

gcc/testsuite/rust/execute/torture/issue-2236.rs

raw
1 // { dg-options "-w" }
2 #[lang = "sized"]
3 pub trait Sized {}
4
5 mod core {
6 mod ops {
7 #[lang = "deref"]
8 trait Deref {
9 type Target;
10 fn deref(&self) -> &Self::Target;
11 }
12
13 impl<T> Deref for &T {
14 type Target = T;
15
16 fn deref(&self) -> &T {
17 *self
18 }
19 }
20 }
21 }
22
23 impl i32 {
24 fn max(self, other: i32) -> i32 {
25 if self > other {
26 self
27 } else {
28 other
29 }
30 }
31 }
32
33 fn foo<T: core::ops::Deref<Target = i32>>(t: T) -> i32 {
34 t.max(2)
35 }
36
37 fn main() -> i32 {
38 let a: i32 = 1;
39 foo(&a) - 2
40 }