Skip to content

Commit c5a1a67

Browse files
Move check for error in impl header outside of reporting
1 parent 1447f9d commit c5a1a67

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+5-4
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -Znext-solver
2+
3+
trait ToUnit<'a> {
4+
type Unit;
5+
}
6+
7+
impl<T> ToUnit for *const T {}
8+
//~^ ERROR implicit elided lifetime not allowed here
9+
10+
trait Overlap<T> {}
11+
12+
impl<T> Overlap<T> for T {}
13+
impl<T> Overlap<for<'a> fn(<*const T as ToUnit<'a>>::Unit)> for T {}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0726]: implicit elided lifetime not allowed here
2+
--> $DIR/skip-reporting-if-references-err.rs:7:9
3+
|
4+
LL | impl<T> ToUnit for *const T {}
5+
| ^^^^^^ expected lifetime parameter
6+
|
7+
help: indicate the anonymous lifetime
8+
|
9+
LL | impl<T> ToUnit<'_> for *const T {}
10+
| ++++
11+
12+
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:14 ~ skip_reporting_if_references_err[c8da]::{impl#2}::'a), "'a")], def_id: DefId(0:5 ~ skip_reporting_if_references_err[c8da]::ToUnit::Unit) }
13+
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:14 ~ skip_reporting_if_references_err[c8da]::{impl#2}::'a), "'a")], def_id: DefId(0:5 ~ skip_reporting_if_references_err[c8da]::ToUnit::Unit) }
14+
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:14 ~ skip_reporting_if_references_err[c8da]::{impl#2}::'a), "'a")], def_id: DefId(0:5 ~ skip_reporting_if_references_err[c8da]::ToUnit::Unit) }
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0726`.

0 commit comments

Comments
 (0)