Closed
Description
The following code has been working with stable compiler (rustc 1.34.2), but doesn't compile with nightly (rustc 1.36.0-nightly (963184b 2019-05-18)).
fn takes_string<S: Into<String>>(input: S) {
let s = input.into();
println!("{}", s);
}
fn main() {
let foo = String::from("Hello world");
takes_string(foo.as_ref());
}
Error the nightly compiler is given:
error[E0283]: type annotations required: cannot resolve `std::string::String: std::convert::AsRef<_>`
--> src/main.rs:10:22
|
10 | takes_string(foo.as_ref());
| ^^^^^^
error: aborting due to previous error
However, stable compiler is happy with the code and prints the expected hello world.
Stable compiler:
rustc 1.34.2 (6c2484dc3 2019-05-13)
binary: rustc
commit-hash: 6c2484dc3c532c052f159264e970278d8b77cdc9
commit-date: 2019-05-13
host: x86_64-apple-darwin
release: 1.34.2
LLVM version: 8.0
Nightly compiler:
rustc 1.36.0-nightly (963184bbb 2019-05-18)
binary: rustc
commit-hash: 963184bbb670c1ffa97fc28a98cd5e8473118859
commit-date: 2019-05-18
host: x86_64-apple-darwin
release: 1.36.0-nightly
LLVM version: 8.0