-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Lifetime error when indexing with borrowed index in beta but not in stable #74933
Copy link
Copy link
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Description
Activity
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
I tried to compile this code:
I expected the code to compile
Instead, it failed to compile with this lifetime error:
Workarounds
If I change the function in these ways it compiles.
https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=ca6b8a2243d7116cb8180bb4300f6edc
https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=21326b3dcd6c017d0e644ef7eab89769
Meta
This compiles successfully on Stable Rust 1.45.0 back to 1.26.0 (when
'_lifetimes were stabilized)This fails to compile on these versions(haven't tried previous ones in the same channels):
This issue has been assigned to @nbdd0121 via this comment.