Closed tomjakubowski closed 10 years ago
Similar code without the overloaded_calls
feature does not cause a compiler error:
struct Adder<T> {
x: T
}
impl<A, R, T: Add<A, R>> Adder<T> {
fn call(&self, args: (A, )) -> R {
let (y, ) = args;
self.x + y
}
}
fn make_adder<T>(x: T) -> Adder<T> {
Adder {
x: x
}
}
pub fn main() {
let add3 = make_adder(3i);
let y: int = add3.call((17, ));
println!("{}", y);
}
A smaller test case:
#![feature(overloaded_calls)]
use std::{fmt, ops};
struct Shower<T> {
x: T
}
impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
fn call(&self, _args: ()) {
println!("{}", self.x);
}
}
fn make_shower<T>(x: T) -> Shower<T> {
Shower { x: x }
}
pub fn main() {
let show3 = make_shower(3i);
show3();
}
Neither of the test cases are ICEing for me today, I'm seeing the following:
scratch$ rustc -v
rustc 0.12.0-pre-nightly (a4553453a 2014-07-25 00:36:11 +0000)
scratch$ rustc r15094.rs
r15094.rs:33:5: 36:6 error: method `call` has an incompatible type for trait: expected "rust-call" fn but found "Rust" fn [E0053]
r15094.rs:33 fn call(&self, args: (A, )) -> R {
r15094.rs:34 let (y, ) = args;
r15094.rs:35 self.x + y
r15094.rs:36 }
error: aborting due to previous error
scratch$ rustc r15094.rs
r15094.rs:10:5: 12:6 error: method `call` has an incompatible type for trait: expected "rust-call" fn but found "Rust" fn [E0053]
r15094.rs:10 fn call(&self, _args: ()) {
r15094.rs:11 println!("{}", self.x);
r15094.rs:12 }
error: aborting due to previous error
Flagging as needstest
Code sample:
Backtrace and debug log: