about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-13 15:42:45 +0000
committerbors <bors@rust-lang.org>2015-05-13 15:42:45 +0000
commit222cd73b8a422d2c4124375f6aaffd2663bb9718 (patch)
tree47922b9cae608808b0aea070e8a1367381d4af74 /src/test
parentaf41097b4906fdbd395b74f7de17f84f1666fe7a (diff)
parent36eb09f356ef49e94dc367467325fce6048273c8 (diff)
downloadrust-222cd73b8a422d2c4124375f6aaffd2663bb9718.tar.gz
rust-222cd73b8a422d2c4124375f6aaffd2663bb9718.zip
Auto merge of #25344 - arielb1:fresh-float, r=nikomatsakis
There is no subtyping relationship between the types (or their non-freshened
variants), so they can not be merged.

Fixes #22645
Fixes #24352
Fixes #23825

Should fix #25235 (no test in issue).
Should fix #19976 (test is outdated).
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-22645.rs29
-rw-r--r--src/test/compile-fail/issue-24352.rs15
-rw-r--r--src/test/run-pass/issue-23825.rs30
3 files changed, 74 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-22645.rs b/src/test/compile-fail/issue-22645.rs
new file mode 100644
index 00000000000..8677934fd64
--- /dev/null
+++ b/src/test/compile-fail/issue-22645.rs
@@ -0,0 +1,29 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::ops::Add;
+
+trait Scalar {}
+impl Scalar for f64 {}
+
+struct Bob;
+
+impl<RHS: Scalar> Add <RHS> for Bob {
+  type Output = Bob;
+  fn add(self, rhs : RHS) -> Bob {}
+}
+
+fn main() {
+  let b = Bob + 3.5;
+  b + 3 //~ ERROR: is not implemented
+  //~^ ERROR: is not implemented
+  //~^^ ERROR: is not implemented
+  //~^^^ ERROR: mismatched types
+}
diff --git a/src/test/compile-fail/issue-24352.rs b/src/test/compile-fail/issue-24352.rs
new file mode 100644
index 00000000000..0fbc634826b
--- /dev/null
+++ b/src/test/compile-fail/issue-24352.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    1.0f64 - 1.0;
+    1.0f64 - 1 //~ ERROR: is not implemented
+    //~^ ERROR: is not implemented
+}
diff --git a/src/test/run-pass/issue-23825.rs b/src/test/run-pass/issue-23825.rs
new file mode 100644
index 00000000000..1b857d94c72
--- /dev/null
+++ b/src/test/run-pass/issue-23825.rs
@@ -0,0 +1,30 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+trait Stringify {
+    fn to_string(&self) -> String;
+}
+
+impl Stringify for u32 {
+    fn to_string(&self) -> String { format!("u32: {}", *self) }
+}
+
+impl Stringify for f32 {
+    fn to_string(&self) -> String { format!("f32: {}", *self) }
+}
+
+fn print<T: Stringify>(x: T) -> String {
+    x.to_string()
+}
+
+fn main() {
+    assert_eq!(&print(5), "u32: 5");
+    assert_eq!(&print(5.0), "f32: 5");
+}