File tree Expand file tree Collapse file tree 4 files changed +65
-4
lines changed
compiler/rustc_trait_selection/src/traits/specialize Expand file tree Collapse file tree 4 files changed +65
-4
lines changed Original file line number Diff line number Diff line change @@ -402,10 +402,6 @@ fn report_conflicting_impls<'tcx>(
402402 impl_span : Span ,
403403 err : & mut Diag < ' _ , G > ,
404404 ) {
405- if ( overlap. trait_ref , overlap. self_ty ) . references_error ( ) {
406- err. downgrade_to_delayed_bug ( ) ;
407- }
408-
409405 match tcx. span_of_impl ( overlap. with_impl ) {
410406 Ok ( span) => {
411407 err. span_label ( span, "first implementation here" ) ;
@@ -458,6 +454,11 @@ fn report_conflicting_impls<'tcx>(
458454 )
459455 } ) ;
460456
457+ // Don't report overlap errors if the header references error
458+ if let Err ( err) = ( overlap. trait_ref , overlap. self_ty ) . error_reported ( ) {
459+ return Err ( err) ;
460+ }
461+
461462 match used_to_be_allowed {
462463 None => {
463464 let reported = if overlap. with_impl . is_local ( )
Original file line number Diff line number Diff line change 1+ error[E0726]: implicit elided lifetime not allowed here
2+ --> $DIR/skip-reporting-if-references-err.rs:10:9
3+ |
4+ LL | impl<T> ToUnit for T {}
5+ | ^^^^^^ expected lifetime parameter
6+ |
7+ help: indicate the anonymous lifetime
8+ |
9+ LL | impl<T> ToUnit<'_> for T {}
10+ | ++++
11+
12+ error[E0277]: the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
13+ --> $DIR/skip-reporting-if-references-err.rs:15:29
14+ |
15+ LL | impl Overlap for for<'a> fn(<() as ToUnit<'a>>::Unit) {}
16+ | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `()`
17+
18+ error[E0277]: the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
19+ --> $DIR/skip-reporting-if-references-err.rs:15:18
20+ |
21+ LL | impl Overlap for for<'a> fn(<() as ToUnit<'a>>::Unit) {}
22+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `()`
23+
24+ error: aborting due to 3 previous errors
25+
26+ Some errors have detailed explanations: E0277, E0726.
27+ For more information about an error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change 1+ error[E0726]: implicit elided lifetime not allowed here
2+ --> $DIR/skip-reporting-if-references-err.rs:10:9
3+ |
4+ LL | impl<T> ToUnit for T {}
5+ | ^^^^^^ expected lifetime parameter
6+ |
7+ help: indicate the anonymous lifetime
8+ |
9+ LL | impl<T> ToUnit<'_> for T {}
10+ | ++++
11+
12+ error: aborting due to 1 previous error
13+
14+ For more information about this error, try `rustc --explain E0726`.
Original file line number Diff line number Diff line change 1+ // Regression test for #121006.
2+ //@ revisions: current next
3+ //@ ignore-compare-mode-next-solver (explicit revisions)
4+ //@[next] compile-flags: -Znext-solver
5+
6+ trait ToUnit < ' a > {
7+ type Unit ;
8+ }
9+
10+ impl < T > ToUnit for T { }
11+ //~^ ERROR implicit elided lifetime not allowed here
12+
13+ trait Overlap { }
14+ impl < U > Overlap for fn ( U ) { }
15+ impl Overlap for for <' a > fn ( <( ) as ToUnit < ' a > >:: Unit ) { }
16+ //[current]~^ ERROR the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
17+ //[current]~| ERROR the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
18+
19+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments