1
Fork 0

Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errors

Continue compilation after check_mod_type_wf errors

The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too.

The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication.

fixes https://github.com/rust-lang/rust/issues/120860
This commit is contained in:
bors 2024-02-14 18:32:19 +00:00
commit ee9c7c940c
215 changed files with 2723 additions and 293 deletions

View file

@ -3,6 +3,7 @@ use crate::thir::cx::region::Scope;
use crate::thir::cx::Cx;
use crate::thir::util::UserAnnotatedTyHelpers;
use itertools::Itertools;
use rustc_ast::LitKind;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
@ -20,7 +21,8 @@ use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{
self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType,
};
use rustc_span::{sym, Span};
use rustc_span::source_map::Spanned;
use rustc_span::{sym, Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
impl<'tcx> Cx<'tcx> {
@ -894,7 +896,14 @@ impl<'tcx> Cx<'tcx> {
Res::Def(DefKind::ConstParam, def_id) => {
let hir_id = self.tcx.local_def_id_to_hir_id(def_id.expect_local());
let generics = self.tcx.generics_of(hir_id.owner);
let index = generics.param_def_id_to_index[&def_id];
let Some(&index) = generics.param_def_id_to_index.get(&def_id) else {
self.tcx.dcx().has_errors().unwrap();
// We already errored about a late bound const
return ExprKind::Literal {
lit: &Spanned { span: DUMMY_SP, node: LitKind::Err },
neg: false,
};
};
let name = self.tcx.hir().name(hir_id);
let param = ty::ParamConst::new(index, name);