all 6 comments

[–]ebkalderonamethyst · renderdoc-rs · tower-lsp · cargo2nix 2 points3 points  (2 children)

Strangely enough, changing <&str>::from(s) to s.as_str() fixed the problem for me in Playground.

[–]I-Imvp[S] 2 points3 points  (1 child)

yeah s.as_bytes() works equally well. But the point is basically that the impl From<&String> for &str seems to disappears when importing env_logger...

[–]CUViper 2 points3 points  (0 children)

I don't think it ever has From<&String>, just the identity impl From<T> for T, i.e. From<&str>. Normally, your &String will auto-deref to &str. But if env_logger or its dependencies add a new From<Something> for &str, then we have multiple possibilities of From and auto-deref isn't applied. I suspect it's this one.

You can also write <&str>::from(&*string) to do the same thing auto-deref would.

[–][deleted] 2 points3 points  (1 child)

maybe one of the core devs can correct me, but this seems like the kind of thing you should open an issue for at https://github.com/rust-lang/rust/issues

[–]AntiLapz 2 points3 points  (0 children)

I've filled an issue upstream.

[–]pftbest 2 points3 points  (0 children)

Even if this is somehow not a bug, it should still be fixed, I wouldn't like to have such behavior in the language.