Skip to content

Use a crate attribute to load plugins #22026

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 2 commits into from
Feb 10, 2015
Merged

Conversation

kmcallister
Copy link
Contributor

#[plugin] #[no_link] extern crate bleh;

becomes a crate attribute

#![plugin(bleh)]

The feature gate is still required.

It's almost never correct to link a plugin into the resulting library / executable, because it will bring all of libsyntax and librustc with it. However if you really want this behavior, you can get it with a separate extern crate item in addition to the plugin attribute.

Fixes #21043.
Fixes #20769.

[breaking-change]

@rust-highfive
Copy link
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@brson
Copy link
Contributor

brson commented Feb 6, 2015

Seems reasonable to me. r? @sfackler

@rust-highfive rust-highfive assigned sfackler and unassigned brson Feb 6, 2015
@huonw
Copy link
Member

huonw commented Feb 6, 2015

This stops it being possible to load a plugin in a submodule, right? Also, does it work with cfg_attr to e.g. only load a plugin for testing?

@kmcallister
Copy link
Contributor Author

This stops it being possible to load a plugin in a submodule, right?

Yeah, which sounds good to me.

Also, does it work with cfg_attr to e.g. only load a plugin for testing?

No; cfg_attr is a syntax extension so it runs much too late for that. Probably a follow-up issue.

@sfackler
Copy link
Member

sfackler commented Feb 7, 2015

Seems pretty easy to solve the cfg_attr issue by just moving the load call into the beginning of expansion.

@kmcallister
Copy link
Contributor Author

The cfg_attr PR is #22116.

    #[plugin] #[no_link] extern crate bleh;

becomes a crate attribute

    #![plugin(bleh)]

The feature gate is still required.

It's almost never correct to link a plugin into the resulting library /
executable, because it will bring all of libsyntax and librustc with it.
However if you really want this behavior, you can get it with a separate
`extern crate` item in addition to the `plugin` attribute.

Fixes rust-lang#21043.
Fixes rust-lang#20769.

[breaking-change]
@kmcallister
Copy link
Contributor Author

Rebased. @sfackler, with the cfg_attr PR in the queue, do you have any remaining comments about this PR?

@@ -284,11 +284,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}
match i.node {
ast::ItemExternCrate(_) => {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a message telling people what to do if they still have a #[plugin]-tagged extern crate?

@sfackler
Copy link
Member

sfackler commented Feb 9, 2015

r=me with the nit. Up to you on if you want to wait and let the cfg_attr change land first or not.

@kmcallister
Copy link
Contributor Author

@bors r=sfackler 1aedc45

@bors
Copy link
Collaborator

bors commented Feb 10, 2015

⌛ Testing commit 1aedc45 with merge 124d6a0...

bors added a commit that referenced this pull request Feb 10, 2015
```rust
#[plugin] #[no_link] extern crate bleh;
```

becomes a crate attribute

```rust
#![plugin(bleh)]
```

The feature gate is still required.

It's almost never correct to link a plugin into the resulting library / executable, because it will bring all of libsyntax and librustc with it. However if you really want this behavior, you can get it with a separate `extern crate` item in addition to the `plugin` attribute.

Fixes #21043.
Fixes #20769.

[breaking-change]
@bors
Copy link
Collaborator

bors commented Feb 10, 2015

💔 Test failed - auto-win-64-opt

@alexcrichton
Copy link
Member

@bors: retry

@bors
Copy link
Collaborator

bors commented Feb 10, 2015

⌛ Testing commit 1aedc45 with merge 94c06a1...

bors added a commit that referenced this pull request Feb 10, 2015
```rust
#[plugin] #[no_link] extern crate bleh;
```

becomes a crate attribute

```rust
#![plugin(bleh)]
```

The feature gate is still required.

It's almost never correct to link a plugin into the resulting library / executable, because it will bring all of libsyntax and librustc with it. However if you really want this behavior, you can get it with a separate `extern crate` item in addition to the `plugin` attribute.

Fixes #21043.
Fixes #20769.

[breaking-change]
@bors bors merged commit 1aedc45 into rust-lang:master Feb 10, 2015
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.

Stop using extern crate for plugins Plugins without #[no_link] produce shared library error when running
7 participants