Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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).
- Loading branch information
Showing
8 changed files
with
90 additions
and
11 deletions.
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
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
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,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 | ||
} |
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,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 | ||
} |
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,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"); | ||
} |