summaryrefslogtreecommitdiffstats
path: root/tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs b/tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs
new file mode 100644
index 000000000..ba5b9f542
--- /dev/null
+++ b/tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs
@@ -0,0 +1,28 @@
+fn function<T>(x: T, y: bool) -> T {
+ x
+}
+
+struct S {}
+impl S {
+ fn method<T>(&self, x: T) -> T {
+ x
+ }
+}
+
+fn wrong_arg_type(x: u32) -> u32 {
+ x
+}
+
+fn main() {
+ // Should not trigger.
+ let x = wrong_arg_type(0u16); //~ ERROR mismatched types
+ let x: u16 = function(0, 0u8); //~ ERROR mismatched types
+
+ // Should trigger exactly once for the first argument.
+ let x: u16 = function(0u32, 0u8); //~ ERROR arguments to this function are incorrect
+
+ // Should trigger.
+ let x: u16 = function(0u32, true); //~ ERROR mismatched types
+ let x: u16 = (S {}).method(0u32); //~ ERROR mismatched types
+ function(0u32, 8u8) //~ ERROR arguments to this function are incorrect
+}