Skip to content

Conversation

@richardeoin
Copy link
Contributor

Rather than the equivalent exports from std

See https://doc.rust-lang.org/core/index.html

Useful for creating no_std crates, and is completely equivalent in other
cases. There are still some features that require std, using these in a
no_std crate will error at compile time (the current behaviour).

Mark the cpp crate as no_std

Rather than their re-exports from std

See https://doc.rust-lang.org/core/index.html

Useful for creating no_std crates, and is completely equivalent in other
cases. There are still some features that require std, using these in a
no_std crate will error at compile time (the current behaviour)
There's nothing from std used here
@ogoffart
Copy link
Collaborator

Thanks or the patch.
This looks quite good.
However, tere are still some usage of std:: in cpp/src/lib.rs
I guess they should be removed before marking the crate as no_std.

@ogoffart
Copy link
Collaborator

There is also one use of ::std::sync::Once in the cpp_macro generated code. That needs std. But maybe the crate can still be marked as no_std even if it it stays.

@richardeoin
Copy link
Contributor Author

The no_std meta in cpp/src/lib.rs actually applies to almost nothing. The macros are expanded in the user's crate, and it doesn't propagate into the cpp_macros crate because that is marked with:

[lib]
proc_macro = true

But still they can be replaced with core at no cost, I will do that.

As you say there's no trivial replacement for ::std::sync::Once, but this is only occurs if expanded into the user's crate (through the use of the rust! macro, I think). So much of this crates functionality can be used by no_std crates anyhow.

@ogoffart ogoffart merged commit 46c1f8d into mystor:master Apr 25, 2020
@ogoffart
Copy link
Collaborator

Thank you !

@ratijas
Copy link
Contributor

ratijas commented Sep 6, 2020

I'd like to note that while the PR is good in itself and mostly works in the wild, it was released under patch version bump despite being a breaking change (woboq/qmetaobject-rs#108) — which is bad.

Incompatibility arise from the fact that in Rust 2015 edition using ::core paths require explicit extern crate core; line at the top of the main.rs file, while ::std paths work out-of-the-box.

I probably should open a new issue with a request for updated documentation regarding 2015 edition, or write such PR myself...

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.

3 participants