Rollup merge of #108186 - compiler-errors:closures-with-late-bound-types-r-bad, r=cjgillot
Deny non-lifetime bound vars in `for<..> ||` closure binders Moves the check for illegal bound var types from astconv to resolve_bound_vars. If a binder is defined to have a type or const late-bound var that's not allowed, we'll resolve any usages to ty error or const error values, so we shouldn't ever see late-bound types or consts in places they aren't expected. Fixes #108184 Fixes #108181 Fixes #108192
This commit is contained in:
commit
d3d5163921
23 changed files with 210 additions and 102 deletions
|
@ -3,6 +3,7 @@
|
|||
use crate::ty;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{ItemLocalId, OwnerId};
|
||||
use rustc_macros::HashStable;
|
||||
|
@ -13,6 +14,7 @@ pub enum ResolvedArg {
|
|||
EarlyBound(/* decl */ DefId),
|
||||
LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* decl */ DefId),
|
||||
Free(DefId, /* lifetime decl */ DefId),
|
||||
Error(ErrorGuaranteed),
|
||||
}
|
||||
|
||||
/// A set containing, at most, one known element.
|
||||
|
|
|
@ -149,6 +149,9 @@ impl<'tcx> Const<'tcx> {
|
|||
ty::ConstKind::Bound(debruijn, ty::BoundVar::from_u32(index)),
|
||||
ty,
|
||||
)),
|
||||
Some(rbv::ResolvedArg::Error(guar)) => {
|
||||
Some(tcx.const_error_with_guaranteed(ty, guar))
|
||||
}
|
||||
arg => bug!("unexpected bound var resolution for {:?}: {arg:?}", expr.hir_id),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue