Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwU
Constrain const vars to error if const types are mismatched When equating two consts of different types, if either are const variables, constrain them to the correct const error kind. This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection. Fixes #109296 The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message... r? `@BoxyUwU`
This commit is contained in:
commit
081c607b0a
6 changed files with 51 additions and 13 deletions
|
@ -22,7 +22,7 @@ use crate::traits::{
|
|||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{error_code, DelayDm, Diagnostic};
|
||||
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_session::lint::builtin::COHERENCE_LEAK_CHECK;
|
||||
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
||||
|
@ -350,6 +350,10 @@ fn report_conflicting_impls<'tcx>(
|
|||
impl_span: Span,
|
||||
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) {
|
||||
Ok(span) => {
|
||||
err.span_label(span, "first implementation here");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue