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

Fix missing lifetime error in dangling reference example #2093

Merged
merged 1 commit into from
May 23, 2024

Conversation

randomPoison
Copy link
Collaborator

The example of returning a reference to a local variable doesn't compile due to a missing lifetime specifier, which isn't what we're trying to demonstrate with that example. I usually add the lifetime in manually in order to demonstrate the compiler error, but it occurs to me that if we make the argument a reference we can sneakily get the correct compiler error without having to introduce the lifetime syntax.

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

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

Nice!

@djmitche djmitche enabled auto-merge (squash) May 23, 2024 16:55
@djmitche djmitche disabled auto-merge May 23, 2024 16:59
@djmitche djmitche enabled auto-merge (squash) May 23, 2024 17:01
@djmitche
Copy link
Collaborator

Merging is blocked on #2094

@djmitche djmitche merged commit 6115a12 into main May 23, 2024
36 checks passed
@djmitche djmitche deleted the legare/dangling-lifetime branch May 23, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants