-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add use statements support to #[project] attribute
- Loading branch information
Showing
7 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// compile-fail | ||
|
||
// Currently, the visibility of projected type is always `pub(self)`, | ||
// so this test is fine, but once https://github.com/taiki-e/pin-project/issues/81 | ||
// is merged, the test needs to be extended. | ||
|
||
use pin_project::{pin_project, project}; | ||
|
||
#[pin_project] | ||
struct A { | ||
field: u8, | ||
} | ||
|
||
#[project] | ||
pub use crate::A; | ||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
error[E0255]: the name `__AProjection` is defined multiple times | ||
--> $DIR/use-public.rs:15:16 | ||
| | ||
9 | #[pin_project] | ||
| -------------- previous definition of the type `__AProjection` here | ||
... | ||
15 | pub use crate::A; | ||
| ^ `__AProjection` reimported here | ||
| | ||
= note: `__AProjection` must be defined only once in the type namespace of this module | ||
help: you can use `as` to change the binding name of the import | ||
| | ||
15 | pub use crate::A as other___AProjection; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0255]: the name `__AProjectionTrait` is defined multiple times | ||
--> $DIR/use-public.rs:15:16 | ||
| | ||
9 | #[pin_project] | ||
| -------------- previous definition of the trait `__AProjectionTrait` here | ||
... | ||
15 | pub use crate::A; | ||
| ^ `__AProjectionTrait` reimported here | ||
| | ||
= note: `__AProjectionTrait` must be defined only once in the type namespace of this module | ||
help: you can use `as` to change the binding name of the import | ||
| | ||
15 | pub use crate::A as other___AProjectionTrait; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0365]: `__AProjection` is private, and cannot be re-exported | ||
--> $DIR/use-public.rs:15:16 | ||
| | ||
15 | pub use crate::A; | ||
| ^ re-export of private `__AProjection` | ||
| | ||
= note: consider declaring type or module `__AProjection` with `pub` | ||
|
||
error[E0365]: `__AProjectionTrait` is private, and cannot be re-exported | ||
--> $DIR/use-public.rs:15:16 | ||
| | ||
15 | pub use crate::A; | ||
| ^ re-export of private `__AProjectionTrait` | ||
| | ||
= note: consider declaring type or module `__AProjectionTrait` with `pub` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0255, E0365. | ||
For more information about an error, try `rustc --explain E0255`. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// compile-fail | ||
|
||
use pin_project::pin_project; | ||
|
||
#[pin_project] | ||
struct A { | ||
field: u8, | ||
} | ||
|
||
mod b { | ||
use pin_project::project; | ||
|
||
#[project] | ||
use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports | ||
#[project] | ||
use crate::*; //~ ERROR #[project] attribute may not be used on glob imports | ||
} | ||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: #[project] attribute may not be used on renamed imports | ||
--> $DIR/use.rs:14:16 | ||
| | ||
14 | use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports | ||
| ^^^^^^ | ||
|
||
error: #[project] attribute may not be used on glob imports | ||
--> $DIR/use.rs:16:16 | ||
| | ||
16 | use crate::*; //~ ERROR #[project] attribute may not be used on glob imports | ||
| ^ | ||
|
||
error: aborting due to 2 previous errors | ||
|