1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // This test is to make sure we don't just ICE if the trait
12 // method for an operator is not implemented properly.
13 // (In this case the mul method should take &f64 and not f64)
22 // Expecting value in input signature
23 impl Mul<f64> for Vec1 {
26 fn mul(self, s: &f64) -> Vec1 {
27 //~^ ERROR method `mul` has an incompatible type for trait
39 // Wrong type parameter ordering
40 impl Mul<Vec2> for Vec2 {
43 fn mul(self, s: f64) -> Vec2 {
44 //~^ ERROR method `mul` has an incompatible type for trait
58 // Unexpected return type
59 impl Mul<f64> for Vec3 {
62 fn mul(self, s: f64) -> f64 {
63 //~^ ERROR method `mul` has an incompatible type for trait
69 // Check that the usage goes from the trait declaration:
71 let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK
73 let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order
74 // (we no longer signal a compile error here, since the
75 // error in the trait signature will cause compilation to
76 // abort before we bother looking at function bodies.)
78 let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0;