Delay overlap errors if errors are involved
This commit is contained in:
parent
322c7b6269
commit
9174edbae9
3 changed files with 15 additions and 8 deletions
|
@ -22,7 +22,7 @@ use crate::traits::{
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{error_code, DelayDm, Diagnostic};
|
use rustc_errors::{error_code, DelayDm, Diagnostic};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt};
|
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_middle::ty::{InternalSubsts, SubstsRef};
|
use rustc_middle::ty::{InternalSubsts, SubstsRef};
|
||||||
use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK;
|
use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK;
|
||||||
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
||||||
|
@ -350,6 +350,10 @@ fn report_conflicting_impls<'tcx>(
|
||||||
impl_span: Span,
|
impl_span: Span,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
) {
|
) {
|
||||||
|
if (overlap.trait_ref, overlap.self_ty).references_error() {
|
||||||
|
err.downgrade_to_delayed_bug();
|
||||||
|
}
|
||||||
|
|
||||||
match tcx.span_of_impl(overlap.with_impl) {
|
match tcx.span_of_impl(overlap.with_impl) {
|
||||||
Ok(span) => {
|
Ok(span) => {
|
||||||
err.span_label(span, "first implementation here");
|
err.span_label(span, "first implementation here");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
struct S<const L: usize>;
|
struct S<const L: usize>;
|
||||||
|
|
||||||
impl<const N: i32> Copy for S<N> {}
|
impl<const N: i32> Copy for S<N> {}
|
||||||
|
//~^ ERROR the constant `N` is not of type `usize`
|
||||||
impl<const M: usize> Copy for S<M> {}
|
impl<const M: usize> Copy for S<M> {}
|
||||||
//~^ ERROR conflicting implementations of trait `Copy` for type `S<[const error]>`
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
error[E0119]: conflicting implementations of trait `Copy` for type `S<[const error]>`
|
error: the constant `N` is not of type `usize`
|
||||||
--> $DIR/bad-const-wf-doesnt-specialize.rs:9:1
|
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:29
|
||||||
|
|
|
|
||||||
LL | impl<const N: i32> Copy for S<N> {}
|
LL | impl<const N: i32> Copy for S<N> {}
|
||||||
| -------------------------------- first implementation here
|
| ^^^^
|
||||||
LL | impl<const M: usize> Copy for S<M> {}
|
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<[const error]>`
|
note: required by a bound in `S`
|
||||||
|
--> $DIR/bad-const-wf-doesnt-specialize.rs:6:10
|
||||||
|
|
|
||||||
|
LL | struct S<const L: usize>;
|
||||||
|
| ^^^^^^^^^^^^^^ required by this bound in `S`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0119`.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue