summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2015-05-12 21:44:05 +0300
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2015-05-12 21:45:56 +0300
commit36eb09f356ef49e94dc367467325fce6048273c8 (patch)
treeebbdf2e62d07854476ca237140f49eec14d67ff0 /src/test
parent2a5a320babdf000bc9cf719ccd9d95d250f83a02 (diff)
downloadrust-36eb09f356ef49e94dc367467325fce6048273c8.tar.gz
rust-36eb09f356ef49e94dc367467325fce6048273c8.zip
Create a FreshFloatTy separate from FreshIntTy
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");
+}