diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/wrong-mul-method-signature.rs | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/wrong-mul-method-signature.rs')
-rw-r--r-- | tests/ui/wrong-mul-method-signature.rs | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/tests/ui/wrong-mul-method-signature.rs b/tests/ui/wrong-mul-method-signature.rs deleted file mode 100644 index 1c2f86559..000000000 --- a/tests/ui/wrong-mul-method-signature.rs +++ /dev/null @@ -1,68 +0,0 @@ -// This test is to make sure we don't just ICE if the trait -// method for an operator is not implemented properly. -// (In this case the mul method should take &f64 and not f64) -// See: #11450 - -use std::ops::Mul; - -struct Vec1 { - x: f64 -} - -// Expecting value in input signature -impl Mul<f64> for Vec1 { - type Output = Vec1; - - fn mul(self, s: &f64) -> Vec1 { - //~^ ERROR method `mul` has an incompatible type for trait - Vec1 { - x: self.x * *s - } - } -} - -struct Vec2 { - x: f64, - y: f64 -} - -// Wrong type parameter ordering -impl Mul<Vec2> for Vec2 { - type Output = f64; - - fn mul(self, s: f64) -> Vec2 { - //~^ ERROR method `mul` has an incompatible type for trait - Vec2 { - x: self.x * s, - y: self.y * s - } - } -} - -struct Vec3 { - x: f64, - y: f64, - z: f64 -} - -// Unexpected return type -impl Mul<f64> for Vec3 { - type Output = i32; - - fn mul(self, s: f64) -> f64 { - //~^ ERROR method `mul` has an incompatible type for trait - s - } -} - -pub fn main() { - // Check that the usage goes from the trait declaration: - - let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK - - let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order - //~^ ERROR mismatched types - //~| ERROR mismatched types - - let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0; -} |