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

Cheat around the unsafe_code lint in the select macro #430

Closed
wants to merge 1 commit into from
Closed

Cheat around the unsafe_code lint in the select macro #430

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 16, 2019

Fixes #405.

@taiki-e
Copy link
Member

taiki-e commented Oct 16, 2019

As #[forbid(unsafe_code)] does not forbid unsafe code generated by macros, I think it is sufficient to just remove #[allow(unsafe_code)].

UPDATE: I've filed #431 as an alternative to this PR.

@@ -1212,3 +1207,14 @@ macro_rules! select {
)
};
}

/// Same as `std::mem::transmute`, except the function is not marked with `unsafe`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Pedantically speaking, undefined behavior may be invoked because of the absence of unsafe. Not that I'm opposing to this change, but how about saying it's a HACK?

@jeehoonkang
Copy link
Contributor

Oh, I'm sorry not to notice that #431 tries to replace it. #431 looks better if it's correct, but I'm not an expert to decide whether it's correct...

@taiki-e
Copy link
Member

taiki-e commented Oct 17, 2019

The way used by #431 doesn't seem to work on Rust 1.28. The current behavior is probably because of rust-lang/rust#52467 and seems to be available after 1.29. (fyi: rust-lang/rust#53975)

@ghost
Copy link
Author

ghost commented Oct 22, 2019

Closing in favor of #431

@ghost ghost closed this Oct 22, 2019
bors bot added a commit that referenced this pull request May 20, 2020
431: Remove #[allow(unsafe_code)] from select! macro r=taiki-e a=taiki-e

Replaces #430 

Closes #405 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Unable to use select macro in #![forbid(unsafe_code)] environments
2 participants