Open Baptistemontan opened 1 month ago
This problem is quite annoying with macros, as it propagate the error through the whole macro generated code and stop pin-pointing the source of the problem.
The behavior change came with 1.78, I tried 1.78, 1.79, 1.80, 1.81-nightly and 1.82-nightly.
This isn't leaking RPITs. This code has the same error:
use std::fmt::Display;
fn foo<T: Display>(_x: T) -> impl Display {
""
}
struct Bar; // doesn't impl `Display`
fn main() {
let x = foo(Bar);
println!("{}", x);
}
This just has to do with bad error spans and a lack of error deduplications. The root cause of all 3 of these errors is still the T: Display
bound.
@compiler-errors True, this was a supposition on my part, and I did'nt really know how to name the issue, any suggestion how to rename it ?
This is purely a diagnostics regression so this doesn't need triaging.
I caused this in #122341. I may spend some time looking into how to deduplicate these error messages.
Code
I tried this code:
I expected to see this happen:
The error to be reported on the call to
foo()
only:Instead, this happened:
The error is propagated to the use of the
println!
macro call, without supposingx
to implementDisplay
:Version it worked on
It most recently worked on: Rust 1.77
Version with regression
rustc --version --verbose
:Backtrace
Backtrace
```
```