-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add use statements support to #[project] attribute #85
Merged
Conversation
This file contains 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
I feel that if importing both the projected-type and the original type, it will not look very good. #[project]
use super::Foo;
use super::Foo; |
taiki-e
force-pushed
the
project-use
branch
2 times, most recently
from
September 10, 2019 20:57
441545a
to
b0b5b05
Compare
This comment has been minimized.
This comment has been minimized.
taiki-e
force-pushed
the
project-use
branch
from
September 18, 2019 13:13
b0b5b05
to
570ea2b
Compare
taiki-e
force-pushed
the
project-use
branch
from
September 19, 2019 05:32
570ea2b
to
577d55a
Compare
taiki-e
commented
Sep 19, 2019
Err(error!(glob, "#[project] attribute may not be used on glob imports")); | ||
} | ||
UseTree::Rename(rename) => { | ||
// TODO: Consider allowing the projected type to be renamed by `#[project] use Foo as Bar`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc #43
taiki-e
force-pushed
the
project-use
branch
2 times, most recently
from
September 19, 2019 05:36
93acf2a
to
2241bd9
Compare
bors r+ |
Merge conflict |
taiki-e
force-pushed
the
project-use
branch
from
September 19, 2019 05:58
2241bd9
to
b036c2f
Compare
bors retry |
bors bot
added a commit
that referenced
this pull request
Sep 19, 2019
85: Add use statements support to #[project] attribute r=taiki-e a=taiki-e This adds a feature to convert annotated imports to a projected type's imports. ~~For now, this works as an import for both projected type and projection trait.~~ Now, this works as an import for projected type. ### Examples ```rust use pin_project::pin_project; #[pin_project] struct Foo<A> { #[pin] field: A, } mod bar { use pin_project::project; use super::Foo; use std::pin::Pin; #[project] use super::Foo; #[project] fn baz<A>(foo: Pin<&mut Foo<A>>) { #[project] let Foo { field } = foo.project(); let _: Pin<&mut A> = field; } } ``` Co-authored-by: Taiki Endo <[email protected]>
Build succeeded
|
This was referenced Sep 20, 2019
Merged
bors bot
added a commit
that referenced
this pull request
Sep 22, 2019
101: Release 0.4.0-beta.1 r=taiki-e a=taiki-e Changes: * [Changed the argument type of project method back to `self: Pin<&mut Self>`.][90] * [Removed "project_attr" feature and always enable `#[project]` attribute.][94] * [Removed "renamed" feature.][100] * [`#[project]` attribute can now be used for `use` statements.][85] * [Added `project_ref` method and `#[project_ref]` attribute.][93] * [`#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type.][96] cc #21 [85]: #85 [90]: #90 [93]: #93 [94]: #94 [96]: #96 [100]: #100 Co-authored-by: Taiki Endo <[email protected]>
taiki-e
added
the
A-project-attribute
Area: #[project], #[project_ref], and #[project_replace] (note: this was removed in v1.0)
label
Sep 24, 2019
Merged
bors bot
added a commit
that referenced
this pull request
Sep 25, 2019
109: Release 0.4.0 r=taiki-e a=taiki-e cc #21 ### Changes since the latest 0.3 release: * **Pin projection has become a safe operation.** In the absence of other unsafe code that you write, it is impossible to cause undefined behavior. (#18) * `#[unsafe_project]` attribute has been replaced with `#[pin_project]` attribute. (#18, #33) * The `Unpin` argument has been removed - an `Unpin` impl is now generated by default. (#18) * Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl. (#18, #33, #86) * `Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait. (#18) * `#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type. (#96) * `#[pin_project]` can now be used for public type with private field types. (#53) * `#[pin_project]` can now interoperate with `#[cfg()]`. (#77) * Added `project_ref` method to `#[pin_project]` types. (#93) * Added `#[project_ref]` attribute. (#93) * Removed "project_attr" feature and always enable `#[project]` attribute. (#94) * `#[project]` attribute can now be used for `impl` blocks. (#46) * `#[project]` attribute can now be used for `use` statements. (#85) * `#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions. (#51) ### Changes since the 0.4.0-beta.1 release: * Fixed an issue that caused an error when using `#[pin_project(UnsafeUnpin)]` and not providing a manual `UnsafeUnpin` implementation on a type with no generics or lifetime. (#107) Co-authored-by: Taiki Endo <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-project-attribute
Area: #[project], #[project_ref], and #[project_replace] (note: this was removed in v1.0)
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.
This adds a feature to convert annotated imports to a projected type's imports.
For now, this works as an import for both projected type and projection trait.Now, this works as an import for projected type.Examples