Auto merge of #11760 - compiler-errors:escaping, r=Jarcho
Don't check for late-bound vars, check for escaping bound vars Fixes an assertion that didn't make sense. Many valid and well-formed types *have* late-bound vars (e.g. `for<'a> fn(&'a ())`), they just must not have *escaping* late-bound vars in order to be normalized correctly. Addresses rust-lang/rust-clippy#11230, cc `@jyn514` and `@matthiaskrgr` changelog: don't check for late-bound vars, check for escaping bound vars. Addresses rust-lang/rust-clippy#11230
This commit is contained in:
commit
07bc130074
@ -1160,7 +1160,12 @@ pub fn make_normalized_projection<'tcx>(
|
|||||||
) -> Option<Ty<'tcx>> {
|
) -> Option<Ty<'tcx>> {
|
||||||
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_late_bound_regions()) {
|
if let Some((i, arg)) = ty
|
||||||
|
.args
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.find(|(_, arg)| arg.has_escaping_bound_vars())
|
||||||
|
{
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
false,
|
false,
|
||||||
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
||||||
@ -1233,7 +1238,12 @@ pub fn make_normalized_projection_with_regions<'tcx>(
|
|||||||
) -> Option<Ty<'tcx>> {
|
) -> Option<Ty<'tcx>> {
|
||||||
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_late_bound_regions()) {
|
if let Some((i, arg)) = ty
|
||||||
|
.args
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.find(|(_, arg)| arg.has_escaping_bound_vars())
|
||||||
|
{
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
false,
|
false,
|
||||||
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
||||||
|
6
tests/ui/crashes/ice-11230.rs
Normal file
6
tests/ui/crashes/ice-11230.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/// Test for https://github.com/rust-lang/rust-clippy/issues/11230
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
const A: &[for<'a> fn(&'a ())] = &[];
|
||||||
|
for v in A.iter() {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user