File tree 4 files changed +65
-4
lines changed
compiler/rustc_trait_selection/src/traits/specialize
4 files changed +65
-4
lines changed Original file line number Diff line number Diff line change @@ -407,10 +407,6 @@ fn report_conflicting_impls<'tcx>(
407
407
impl_span : Span ,
408
408
err : & mut Diag < ' _ , G > ,
409
409
) {
410
- if ( overlap. trait_ref , overlap. self_ty ) . references_error ( ) {
411
- err. downgrade_to_delayed_bug ( ) ;
412
- }
413
-
414
410
match tcx. span_of_impl ( overlap. with_impl ) {
415
411
Ok ( span) => {
416
412
err. span_label ( span, "first implementation here" ) ;
@@ -463,6 +459,11 @@ fn report_conflicting_impls<'tcx>(
463
459
)
464
460
} ) ;
465
461
462
+ // Don't report overlap errors if the header references error
463
+ if let Err ( err) = ( overlap. trait_ref , overlap. self_ty ) . error_reported ( ) {
464
+ return Err ( err) ;
465
+ }
466
+
466
467
match used_to_be_allowed {
467
468
None => {
468
469
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