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

lang-items: Add Result and Try lang items #3375

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

CohenArthur
Copy link
Member

This is a necessary step for starting to handle the desugar of <expr>?. In Rust 1.49, the desugar looks like this:

    /// match Try::into_result(<expr>) {
    ///     Ok(val) => #[allow(unreachable_code)] val,
    ///     Err(err) => #[allow(unreachable_code)]
    ///                 return Try::from_error(From::from(err)),
    /// }

which uses 4 out of the 5 lang items added in this PR. the remaining lang item is used for try blocks, an unstable feature which I'm not sure we need to support at first for std

gcc/rust/ChangeLog:

	* util/rust-lang-item.h: Add handling for Result::Ok, Result::Err, Try, Try::into_result,
	Try::from_ok, Try::from_err.
	* util/rust-lang-item.cc: Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/try-trait.rs: New test.
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

LGTM

@philberty philberty added this to the Remaining typecheck issues milestone Jan 21, 2025
@CohenArthur CohenArthur added this pull request to the merge queue Jan 21, 2025
Merged via the queue into Rust-GCC:master with commit b87fd67 Jan 21, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants