Debian Codegraph @

gcc/testsuite/rust/execute/torture/issue-1720-2.rs

raw
1 #[lang = "sized"]
2 pub trait Sized {}
3
4 mod core {
5 mod ops {
6 #[lang = "add"]
7 pub trait Add<Rhs = Self> {
8 type Output;
9
10 fn add(self, rhs: Rhs) -> Self::Output;
11 }
12 }
13 }
14
15 struct Foo(i32);
16
17 impl core::ops::Add for Foo {
18 type Output = i32;
19
20 fn add(self, rhs: Foo) -> Self::Output {
21 self.0 + rhs.0
22 }
23 }
24
25 pub fn bar<T: core::ops::Add<Output = i32>>(a: T) -> i32 {
26 a + a
27 }
28
29 pub fn main() -> i32 {
30 let a = Foo(1);
31
32 bar(a) - 2
33 }