Open
Description
Code
I tried this code:
pub trait AsStr {
fn as_str(&self) -> &str;
}
fn foo(bar: &(dyn AsStr + '_)) -> &'_ str {
bar.as_str()
}
I expected to see this happen: code compiles successfully.
Instead, this happened:
error[E0106]: missing lifetime specifier
--> src/main.rs:5:36
|
5 | fn foo(bar: &(dyn AsStr + '_)) -> &'_ str {
| ----------------- ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but the signature does not say which one of `bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
|
5 | fn foo<'a>(bar: &'a (dyn AsStr + 'a)) -> &'a str {
| ++++ ++ ~~ ~~
For more information about this error, try `rustc --explain E0106`.
Version it worked on
It most recently worked on Rust 1.63.0.
Version with regression
It is broken on current stable, i.e. 1.64.0.
Here's the output by cargo-bisect-rustc
:
searched nightlies: from nightly-2022-06-24 to nightly-2022-08-05
regressed nightly: nightly-2022-07-15
searched commit range: 87588a2...c2f428d
regressed commit: f1a8854bisected with cargo-bisect-rustc v0.6.4
Host triple: x86_64-unknown-linux-gnu
Reproduce with:cargo bisect-rustc --end=1.64.0 -- check
It seems to have been found previously by gluon
developers and fixed in their own code in this commit, and today popped up also on URLO.
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged