rust
rust copied to clipboard
E0477 triggered with current nightly
I discovered that some code I had previously been using no longer compiles with the current nightly. It gives E0477 which, as other issues have pointed out, is incorrectly described as "no longer emitted by the compiler".
Code
I expected to see this happen: The code compiles successfully
Instead, this happened: I get this compiler error:
error[E0477]: the type `PrettyCondo<'_>` does not fulfill the required lifetime
--> src/lib.rs:41:5
|
41 | fn add_building(&mut self, _building: &mut PrettyCondo<'_>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the anonymous lifetime as defined here
--> src/lib.rs:41:21
|
41 | fn add_building(&mut self, _building: &mut PrettyCondo<'_>) {
| ^
For more information about this error, try `rustc --explain E0477`.
error: could not compile `e0477-test` due to previous error
Result of cargo-bisect-rustc
searched nightlies: from nightly-2022-08-08 to nightly-2022-09-17 regressed nightly: nightly-2022-08-10 searched commit range: https://github.com/rust-lang/rust/compare/f03ce30962cf1b2a5158667eabae8bf6e8d1cb03...34a6cae28e7013ff0e640026a8e46f315426829d regressed commit: https://github.com/rust-lang/rust/commit/63e4312e6bd50ec9859c363402209809fb8155d5
bisected with cargo-bisect-rustc v0.6.4
Host triple: x86_64-unknown-linux-gnu Reproduce with:
cargo bisect-rustc
The error message behaves funny, too, with the type must outlive the anonymous lifetime as define here part. If you change the impl to use add_building<'s>(&'s self, ...) then it points to the next anonymous lifetime in the signature. If you change it to also use explitic &'t mut Pretty... in the second argument it points to the '_. Once you've eliminated all of the elided lifetimes, it points to the whole signature instead.
The problem seems to be related to the question whether or not there's an outlives-relation between the two elided lifetimes in &mut PrettyCondo<'_> or &mut <<T as ConstructionFirm>::Builder as BuilderFn<'_>>::Output. If all lifetimes are made explicit in the trait definition and impl, and there's an explicit outlives-relation in the trait definition and impl, then the code compiles.
Should be nightly regression, judging by the regressing commit, @rustbot label -regression-untriaged, +regression-from-stable-to-nightly.
Some more labels, @rustbot label A-lifetimes, A-traits, T-compiler
CC @lcnr as the author of the relevant PR.
it's caused by this line: https://github.com/rust-lang/rust/blob/503e19d01e941b88bf6d5b28e9108d046abcfa2d/compiler/rustc_typeck/src/check/compare_method.rs#L277
~~region check is also bad at dealing with ambiguity so it now fails because it probably has two "equally valid" assumed bounds to choose from, so it just chooses neither~~
going to look into this a bit deeper now
my previous understanding was wrong :sweat_smile:
fixed the issue in https://github.com/rust-lang/rust/pull/102016
Assigning priority in accordance with the discussion of the Prioritization Working Group.