-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot resolve std::borrow::Cow<'_, str>: std::borrow::Borrow<_>
#50954
Comments
probably caused by #50170, we didn't do a crater run for that one. In that PR we added: impl<'a> From<&'a String> for Cow<'a, str> But we already have: impl<'a> From<&'a str> for Cow<'a, str> This makes the following impl<'a, B> Borrow<B> for Cow<'a, B> where B: ToOwned It seems all impls (actually not all, see comment below) in that PR can cause the same problem, is it possible to see how many crates were broken by it? Hopefully crater can do that. |
Scheduled a check-only crater run. Should start in a few days. |
I think the only problematic impls added were The same error occurs with this CString case:
No code should be doing this one already, but it appears that the existence of |
Check-only crater run started. Should be finished in ~3 days. |
Hi @leodasvacas (crater requester)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/issue-50954/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file. (interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious) |
ogrep-0.2.1:
screen-api-0.4.1:
travis-0.1.1:
|
This also happens with impl<'a, T: ?Sized + ToOwned> AsRef<T> for Cow<'a, T> I'm not sure what the motivation for the problematic impls was, but if it was to improve functions that take |
All three of those look like a case of |
http://play.rust-lang.org/?gist=d540658d847fed9d6bcd5ca5c74828b8&version=nightly&mode=debug // #![feature(type_ascription)]
use std::borrow::Cow;
fn get_cow(string: &String) -> Cow<str> {
// Fails on nightly with "type annotations required:
// cannot resolve `std::borrow::Cow<'_, str>: std::convert::From<&_>`"
// https://github.com/rust-lang/rust/issues/50954
// This works fine in rust 1.27 and earlier
Cow::from(string.as_ref())
// In rust nightly-1.28 It is easy to fix as in examples below
// Cow::from(string.as_ref(): &str)
// Cow::from(string)
// But I found only these are acceptable in both cases
// Cow::from(string.as_str())
// Cow::Borrowed(string.as_ref())
// Cow::Borrowed(string)
}
fn main() {
let owned = String::from("Hello, world!");
let _cow = get_cow(&owned);
} This is a kind of breaking change, that form of |
Change `as_ref` to `as_str` (to fix `rustc` regression rust-lang/rust#50954).
cc @rust-lang/libs |
closing in favor of #51844 |
This code fails to compile on nightly 2018-05-20 (playground):
With this error:
This compiles fine on stable and beta, and probably on nightly as well until some time in the last week or so.
This is a simplified version of the code involved in rwf2/Rocket#643.
The text was updated successfully, but these errors were encountered: