Skip to content

Conversation

@asmello
Copy link
Collaborator

@asmello asmello commented Feb 23, 2025

This one is a bit subtle. It causes some code relying on the Default trait implementation to be rejected by the compiler:

fn or_default(ptr: &Pointer) -> &Pointer {
    Some(ptr).unwrap_or_default()
}

This is because this desugars to:

match self {
    Some(x) => x, // '_
    None => Self::default() // 'static
}

Which demands that '_ == 'static to be accepted. This is overly strict, we should coerce to whatever lifetime the original & had instead.

@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.8%. Comparing base (f3c23b9) to head (e0d7a70).

Additional details and impacted files
Files with missing lines Coverage Δ
src/pointer.rs 95.6% <100.0%> (+<0.1%) ⬆️

@chanced chanced merged commit 0abe6e5 into main Feb 25, 2025
21 checks passed
@chanced
Copy link
Owner

chanced commented Feb 25, 2025

Wow, great catch!

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.

4 participants