Skip to content

Conversation

@eliassjogreen
Copy link
Member

@eliassjogreen eliassjogreen commented Sep 18, 2025

Needs #790 to be merged first.

Still a bit work in progress with some edge-cases which need ironing out, but it seems to mostly work now which is pretty cool.

@aapoalas
Copy link
Member

praise: Ooh this is really cool! <3

@eliassjogreen eliassjogreen force-pushed the feat/lint-immediately-bind-scoped branch from 9cb1134 to 1eeee0c Compare October 14, 2025 20:55
@eliassjogreen eliassjogreen force-pushed the feat/lint-immediately-bind-scoped branch from 1eeee0c to 0fd6b5a Compare November 17, 2025 13:01
@eliassjogreen
Copy link
Member Author

Majorly unsure if all of the edge-cases are actually correct now that I'm looking back at it... Would be nice if you could write a few tests/examples to test the hardest and most obscure but still "correct" uses.

Also need to figure out how to handle the remaining 8 failures which all seem to follow the pattern:

let px = value.unbind();
let gc = gc.into_nogc();
let py = py.get(agent);
(px.bind(gc), py.bind(gc))

@aapoalas
Copy link
Member

Majorly unsure if all of the edge-cases are actually correct now that I'm looking back at it... Would be nice if you could write a few tests/examples to test the hardest and most obscure but still "correct" uses.

I'll try to get on this... sometime around here? :)

Also need to figure out how to handle the remaining 8 failures which all seem to follow the pattern:

let px = value.unbind();
let gc = gc.into_nogc();
let py = py.get(agent);
(px.bind(gc), py.bind(gc))

Hmm... It does seem to me that these are effectively all more or less wrong and the lint is correct. I'll try fixing them up.

@aapoalas aapoalas marked this pull request as ready for review December 13, 2025 19:44
@aapoalas aapoalas force-pushed the feat/lint-immediately-bind-scoped branch from e160dbd to eafee71 Compare December 13, 2025 19:47
aapoalas
aapoalas previously approved these changes Dec 13, 2025
Copy link
Member

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

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

LGTM, and it's a great and important step towards using GC lint safety <3

}

/// Check if a use of an unbound value is valid (binding or function argument)
fn is_valid_use_of_unbound_value(cx: &LateContext<'_>, expr: &Expr, hir_id: HirId) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

note: Return position would also be valid: return Ok(value.get(agent)); is perfectly safe.

@eliassjogreen
Copy link
Member Author

Updated the lint to check the take method too and found two new issues 😉.

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.

2 participants