From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../structs/structure-constructor-type-mismatch.rs | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/ui/structs/structure-constructor-type-mismatch.rs (limited to 'tests/ui/structs/structure-constructor-type-mismatch.rs') diff --git a/tests/ui/structs/structure-constructor-type-mismatch.rs b/tests/ui/structs/structure-constructor-type-mismatch.rs new file mode 100644 index 000000000..a03ef590c --- /dev/null +++ b/tests/ui/structs/structure-constructor-type-mismatch.rs @@ -0,0 +1,73 @@ +struct Point { + x: T, + y: T, +} + +type PointF = Point; + +struct Pair { + x: T, + y: U, +} + +type PairF = Pair; + +fn main() { + let pt = PointF { + x: 1, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + y: 2, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + }; + + let pt2 = Point:: { + x: 3, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + y: 4, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + }; + + let pair = PairF { + x: 5, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + y: 6, + }; + + let pair2 = PairF:: { + x: 7, + //~^ ERROR mismatched types + //~| expected `f32`, found integer + y: 8, + }; + + let pt3 = PointF:: { //~ ERROR this type alias takes 0 generic arguments but 1 generic argument + x: 9, //~ ERROR mismatched types + y: 10, //~ ERROR mismatched types + }; + + match (Point { x: 1, y: 2 }) { + PointF:: { .. } => {} //~ ERROR this type alias takes 0 generic arguments but 1 generic argument + //~^ ERROR mismatched types + } + + match (Point { x: 1, y: 2 }) { + PointF { .. } => {} //~ ERROR mismatched types + } + + match (Point { x: 1.0, y: 2.0 }) { + PointF { .. } => {} // ok + } + + match (Pair { x: 1, y: 2 }) { + PairF:: { .. } => {} //~ ERROR mismatched types + } + + match (Pair { x: 1.0, y: 2 }) { + PairF:: { .. } => {} // ok + } +} -- cgit v1.2.3