Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
librustc: Don't ICE when operator traits are not implemented properly. …
…Fixes #11450
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2014 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. | ||
|
||
// 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 | ||
|
||
struct Vec2 { | ||
x: f64, | ||
y: f64 | ||
} | ||
|
||
impl Mul<Vec2, f64> for Vec2 { | ||
fn mul(&self, s: f64) -> Vec2 { | ||
//~^ ERROR: method `mul` has an incompatible type: expected &-ptr but found f64 | ||
Vec2 { | ||
x: self.x * s, | ||
y: self.y * s | ||
} | ||
} | ||
} | ||
|
||
pub fn main() { | ||
Vec2 { x: 1.0, y: 2.0 } * 2.0; | ||
} |
a174941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at luqmana@a174941
a174941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging luqmana/rust/op-no-ref = a174941 into auto
a174941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luqmana/rust/op-no-ref = a174941 merged ok, testing candidate = d60e43d
a174941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/4548
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/2390
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/2391
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/4546
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/3646
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/3652
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/4561
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/3649
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/3655
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/4563
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/3649
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/3654
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/3723
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1541
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/4556
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/3657
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/3664
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/4322
a174941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = d60e43d