Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check for late-bound vars, check for escaping bound vars #11760

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,12 @@ pub fn make_normalized_projection<'tcx>(
) -> Option<Ty<'tcx>> {
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
#[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!(
false,
"args contain late-bound region at index `{i}` which can't be normalized.\n\
Expand Down Expand Up @@ -1233,7 +1238,12 @@ pub fn make_normalized_projection_with_regions<'tcx>(
) -> Option<Ty<'tcx>> {
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
#[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!(
false,
"args contain late-bound region at index `{i}` which can't be normalized.\n\
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/crashes/ice-11230.rs
Original file line number Diff line number Diff line change
@@ -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() {}
}