Skip to content

Clean up rust changes#395

Open
tjpalmer wants to merge 2 commits intoshaw-ai-fixesfrom
shaw-ai-fixes-tom2
Open

Clean up rust changes#395
tjpalmer wants to merge 2 commits intoshaw-ai-fixesfrom
shaw-ai-fixes-tom2

Conversation

@tjpalmer
Copy link
Copy Markdown
Contributor

  • Maybe I'm good with the shaw-ai-fixes pr after these changes

Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
@tjpalmer tjpalmer requested a review from ShawSumma March 25, 2026 19:40
private val listedLength = FunctionCall(listedTypes.map { "$it::length" }, "$LISTED_TRAIT_NAME::len", hasGeneric = true)
private val listedMap = FunctionCall("Listed::map", "temper_core::listed::map", hasGeneric = true, fnIndex = -1)
private val listedMapDropping =
FunctionCall("Listed::mapDropping", "temper_core::listed::map_dropping", hasGeneric = true, fnIndex = -1)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed mapDropping because of #394. Removed the others because they aren't needed, because the default method conversion already works.

): List<Rust.Item> {
return when (member) {
is TmpL.GarbageStatement -> return listOf()
is TmpL.GarbageStatement -> translateGarbageStatement(member).toItem() // won't compile but that's ok
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Per my request on the main pr, I replaced the listOf() things with translations that maybe help some in the generated code, even if the translations fail at compile or run time.

val subject = when (val subj = ref.subject) {
is TmpL.Expression -> translateExpression(subj, avoidClone = true)
is TmpL.TypeName -> translateTypeName(subj)
is TmpL.TypeName -> translateTypeName(subj) // wrong but also shouldn't happen
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I chose to leave this here but commented.

// This branch is never expected, so some this translation is untested.
type.types.isEmpty() -> ANY_NAME.toId(pos)
type.types.size == 1 -> translateType(type.types.first(), inExpr = inExpr, isFlex = isFlex)
else -> Rust.ImplTraitType(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Again, left this here but commented.


private fun translateUnsupportedStatement(statement: TmpL.Statement): Rust.ExprStatement = run {
Rust.ExprStatement(statement.pos, translateUnsupported(statement))
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Explicit garbage and other unsupported things end up here.

}
}
Arc::new(result)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Again, dropped because #394.

@tjpalmer tjpalmer marked this pull request as ready for review March 25, 2026 21:07
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.

1 participant