diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/associated-types/associated-types-ref-in-struct-literal.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/associated-types-ref-in-struct-literal.rs b/src/test/ui/associated-types/associated-types-ref-in-struct-literal.rs new file mode 100644 index 000000000..4a490ed03 --- /dev/null +++ b/src/test/ui/associated-types/associated-types-ref-in-struct-literal.rs @@ -0,0 +1,23 @@ +// run-pass +// Test associated type references in a struct literal. Issue #20535. + + +pub trait Foo { + type Bar; + + fn dummy(&self) { } +} + +impl Foo for isize { + type Bar = isize; +} + +struct Thing<F: Foo> { + a: F, + b: F::Bar, +} + +fn main() { + let thing = Thing{a: 1, b: 2}; + assert_eq!(thing.a + 1, thing.b); +} |