-
-
Notifications
You must be signed in to change notification settings - Fork 39
Replace unsafe_project with safe pin_projectable attribute
#18
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
37419c2
Replace #[unsafe_project] with #[pin_projectable]
Aaron1011 1db86f1
Remove unnecessary nightly feature
Aaron1011 e82696f
Run 'cargo fmt'
Aaron1011 500d43f
Explicitly depend on newer Serde
Aaron1011 01bac2d
Move UI tests into pin-project crate
Aaron1011 1d81d65
Fix crate name
Aaron1011 23f9546
Fix typos
Aaron1011 46779b3
Move renamed dependency support behind a feature
Aaron1011 8942555
Run 'cargo fmt'
Aaron1011 f445dfd
Remove lingering 'Unpin' parameter
Aaron1011 87668a9
Test that the relative ordering of `#[pin_projectable]` and `#[repr(p…
Aaron1011 94faf6d
Move 'serde' and 'lazy_static' behind the 'renamed' feature
Aaron1011 2433d77
Fix clippy lints
Aaron1011 60e4242
Fix missed clippy lint
Aaron1011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,6 @@ | ||
| [package] | ||
| name = "pin-project" | ||
| # NB: When modifying, also modify html_root_url in lib.rs | ||
| version = "0.3.4" | ||
| authors = ["Taiki Endo <te316e89@gmail.com>"] | ||
| edition = "2018" | ||
| license = "Apache-2.0/MIT" | ||
| description = "An attribute that creates a projection struct covering all the fields." | ||
| repository = "https://github.com/taiki-e/pin-project" | ||
| documentation = "https://docs.rs/pin-project/" | ||
| readme = "README.md" | ||
| keywords = ["pin", "macros", "attribute"] | ||
| categories = ["rust-patterns"] | ||
| exclude = ["/.travis.yml", "/bors.toml"] | ||
| [workspace] | ||
|
|
||
| [badges] | ||
| travis-ci = { repository = "taiki-e/pin-project" } | ||
|
|
||
| [lib] | ||
| proc-macro = true | ||
|
|
||
| [features] | ||
| # Default features. | ||
| default = ["project_attr"] | ||
| # Enable to use `project` attribute. | ||
| project_attr = ["syn/visit-mut"] | ||
|
|
||
| [dependencies] | ||
| proc-macro2 = "0.4.13" | ||
| quote = "0.6.8" | ||
| syn = { version = "0.15.29", features = ["full"] } | ||
|
|
||
| [dev-dependencies] | ||
| compiletest = { version = "0.3.21", package = "compiletest_rs", features = ["stable", "tmp"] } | ||
| members = [ | ||
| "pin-project", | ||
| "pin-project-internal", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [package] | ||
| name = "pin-project-internal" | ||
| # NB: When modifying, also modify html_root_url in lib.rs | ||
| version = "0.3.4" | ||
| authors = ["Taiki Endo <te316e89@gmail.com>"] | ||
| edition = "2018" | ||
| license = "Apache-2.0/MIT" | ||
| description = "An interal crate to support pin_project - do not use directly" | ||
| repository = "https://github.com/taiki-e/pin-project" | ||
| documentation = "https://docs.rs/pin-project/" | ||
| readme = "README.md" | ||
| keywords = ["pin", "macros", "attribute"] | ||
| categories = ["rust-patterns"] | ||
| exclude = ["/.travis.yml", "/bors.toml"] | ||
|
|
||
| [lib] | ||
| proc-macro = true | ||
|
|
||
| [features] | ||
| # Default features. | ||
| default = ["project_attr"] | ||
| # Enable to use `project` attribute. | ||
| project_attr = ["syn/visit-mut"] | ||
|
|
||
|
|
||
| [dependencies] | ||
| proc-macro2 = "0.4.13" | ||
| quote = "0.6.8" | ||
| syn = { version = "0.15.29", features = ["full", "extra-traits"] } | ||
| proc-macro-crate = "0.1.4" | ||
taiki-e marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Required until https://github.com/alexcrichton/toml-rs/pull/311 is merged, | ||
| # and proc-macro-crate updates to a new version of toml-rs | ||
| serde = "1.0.97" | ||
| lazy_static = "1.3.0" | ||
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #![recursion_limit = "256"] | ||
| #![doc(html_root_url = "https://docs.rs/pin-project/0.3.3")] | ||
| #![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))] | ||
| #![warn(unsafe_code)] | ||
| #![warn(rust_2018_idioms, unreachable_pub)] | ||
| #![warn(single_use_lifetimes)] | ||
| #![warn(clippy::all, clippy::pedantic)] | ||
| #![warn(clippy::nursery)] | ||
|
|
||
| extern crate proc_macro; | ||
|
|
||
| #[macro_use] | ||
| mod utils; | ||
|
|
||
| mod pin_projectable; | ||
| #[cfg(feature = "project_attr")] | ||
| mod project; | ||
|
|
||
| use lazy_static::lazy_static; | ||
| use proc_macro::TokenStream; | ||
|
|
||
| #[cfg(feature = "project_attr")] | ||
| #[proc_macro_attribute] | ||
| pub fn project(args: TokenStream, input: TokenStream) -> TokenStream { | ||
| assert!(args.is_empty()); | ||
| TokenStream::from(project::attribute(input.into())) | ||
| } | ||
|
|
||
| /// This is a doc comment from the defining crate! | ||
| #[proc_macro] | ||
| pub fn pin_project(input: TokenStream) -> TokenStream { | ||
| TokenStream::from( | ||
| pin_projectable::pin_project(input.into()).unwrap_or_else(|e| e.to_compile_error()), | ||
| ) | ||
| } | ||
|
|
||
| #[proc_macro_attribute] | ||
| pub fn pin_projectable(args: TokenStream, input: TokenStream) -> TokenStream { | ||
| TokenStream::from( | ||
| pin_projectable::attribute(args.into(), input.into()) | ||
| .unwrap_or_else(|e| e.to_compile_error()), | ||
| ) | ||
| } | ||
|
|
||
| lazy_static! { | ||
| pub(crate) static ref PIN_PROJECT_CRATE: String = { | ||
| let crate_name = proc_macro_crate::crate_name("pin-project") | ||
| .expect("pin-project-internal was used without pin-project!"); | ||
taiki-e marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| crate_name | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.