Skip to content

Conversation

@enthropy7
Copy link
Contributor

@enthropy7 enthropy7 commented Jan 16, 2026

added bounds check in prohibit_explicit_late_bound_lifetimes to prevent index out of bounds panic when args.args is empty. also regression test here to ensure function pointers in const generics produce proper error messages instead of ICE.

Fixes #151186
Fixes #137084

@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2026

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 16, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2026

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@enthropy7 enthropy7 force-pushed the main branch 4 times, most recently from 2cc5c51 to 1db0e70 Compare January 16, 2026 18:23
@enthropy7
Copy link
Contributor Author

also fixes #137084

@fmease
Copy link
Member

fmease commented Jan 16, 2026

also fixes #137084

Please mention all issues in the PR description via e.g., Fixes #NNN, so they can be auto-closed on merge & are properly linked (useful for e.g., search queries). Read more about keywords here: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests

Moreover, please remove the #NNN from the title, it's not descriptive & nobody can click on it either.

@enthropy7 enthropy7 changed the title Fixes issue #151186 ICE when using function pointer as const generic parameter Fixes ICE when using function pointer as const generic parameter Jan 16, 2026
@enthropy7 enthropy7 force-pushed the main branch 2 times, most recently from d7a40b3 to 87f1829 Compare January 16, 2026 18:52
@enthropy7 enthropy7 changed the title Fixes ICE when using function pointer as const generic parameter Fixed ICE when using function pointer as const generic parameter Jan 16, 2026
@enthropy7 enthropy7 force-pushed the main branch 2 times, most recently from 5cd5886 to f0865a1 Compare January 16, 2026 19:02
@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 16, 2026

r? BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned WaffleLapkin Jan 16, 2026
}

if let Some(span_late) = def.has_late_bound_regions {
if let Some(span_late) = def.has_late_bound_regions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is somewhat confusing to me 🤔

Can you try doing two things for me:

  1. remove the infer_lifetimes case above, it seems unnecessary if we only emit an error/fcw if there's explicit arguments given
  2. use args.has_lifetime_params() instead of !args.args.is_empty(), I think this is closer to the logic we want, especially for cases like this where there are arguments but they're not lifetimes

I think both of these together would make it a lot easier to read this fn 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi again! thanks for the review! implemented all of your suggestions, now waiting for CI check, tests passed, fn now looking better and more consistent :3

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 19, 2026

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 19, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 19, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 19, 2026
@enthropy7
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 19, 2026
Comment on lines 619 to 624
let Some(first_lifetime_arg) =
args.args.iter().find(|arg| matches!(arg, GenericArg::Lifetime(_)))
else {
return ExplicitLateBound::No;
};
let span = first_lifetime_arg.span();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this? if args isnt empty then args.args[0] should work fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, overcomplicated it, was a little bit confused

@enthropy7 enthropy7 force-pushed the main branch 2 times, most recently from c9e6735 to ce65294 Compare January 19, 2026 16:15
Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me. Can you squash all your commits into one? I'll r+ it afterwards

View changes since this review

@enthropy7
Copy link
Contributor Author

Thanks, looks good to me. Can you squash all your commits into one? I'll r+ it afterwards

View changes since this review

done, thanks for the tips on working at this PR!

@WaffleLapkin
Copy link
Member

@bors r=BoxyUwU

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 21, 2026

📌 Commit 4131674 has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 21, 2026
Fixed ICE when using function pointer as const generic parameter

added bounds check in prohibit_explicit_late_bound_lifetimes to prevent index out of bounds panic when args.args is empty. also regression test here to ensure function pointers in const generics produce proper error messages instead of ICE.

Fixes rust-lang#151186
Fixes rust-lang#137084
rust-bors bot pushed a commit that referenced this pull request Jan 21, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #151010 (std: use `ByteStr`'s `Display` for `OsStr`)
 - #151156 (Add GCC and the GCC codegen backend to build-manifest and rustup)
 - #151219 (Fixed ICE when using function pointer as const generic parameter)
 - #151343 (Port some crate level attrs to the attribute parser)
 - #151463 (add x86_64-unknown-linux-gnuasan to CI)

r? @ghost
@rust-bors rust-bors bot merged commit afc1842 into rust-lang:main Jan 22, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 22, 2026
rust-timer added a commit that referenced this pull request Jan 22, 2026
Rollup merge of #151219 - enthropy7:main, r=BoxyUwU

Fixed ICE when using function pointer as const generic parameter

added bounds check in prohibit_explicit_late_bound_lifetimes to prevent index out of bounds panic when args.args is empty. also regression test here to ensure function pointers in const generics produce proper error messages instead of ICE.

Fixes #151186
Fixes #137084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE:index out of bounds: the len is 0 but the index is 0 mgca: index out of bounds

7 participants