Skip to content
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

Added support for extern crate ... as ...; #16689

Merged
merged 1 commit into from
Aug 27, 2014
Merged

Conversation

wickerwaka
Copy link

For review. Not sure about the link_attrs stuff. Will work on converting all the tests.

extern crate "foobar" as foo;
extern crate foobar as foo;

Implements remaining part of RFC #47.
Addresses issue #16461.

Removed link_attrs from rust.md, they don't appear to be supported by
the parser.


extern crate foo = "some/where/rust-foo#foo:1.0"; // a full crate ID for external tools
extern crate "some/where/rust-foo#foo:1.0" as foo; // a full crate ID for external tools
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually support this sort of versioned crate id meaningfully in rustc? (@alexcrichton?)

Copy link
Member

Choose a reason for hiding this comment

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

Currently no, this is actually an invalid crate ID today (safe to remove)

@wickerwaka wickerwaka changed the title Added support for: Added support for extern crate ... as ...; Aug 23, 2014
@wickerwaka
Copy link
Author

Okay, I think this is everything now. Tests and the pretty printer have been updated. Should I leave in the support for the non string literal version? The pretty printer will always print it with a string literal for the original crate name.

extern_crate_decl : "extern" "crate" ident [ '(' link_attrs ')' ] ? [ '=' string_lit ] ? ;
link_attrs : link_attr [ ',' link_attrs ] + ;
link_attr : ident '=' literal ;
extern_crate_decl : "extern" "crate" [ ident | crateid as ident ]
Copy link
Member

Choose a reason for hiding this comment

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

As accepted, the RFC only lists extern crate foo as bar as an alternative, it was only accepted that we would alter the syntax to extern crate "foo" as bar.

Copy link
Member

Choose a reason for hiding this comment

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

I also don't think that there's a production for crateid, which would need to be added.

Implements remaining part of RFC rust-lang#47.
Addresses issue rust-lang#16461.

Removed link_attrs from rust.md, they don't appear to be supported by
the parser.

Changed all the tests to use the new extern crate syntax

Change pretty printer to use 'as' syntax
@brson
Copy link
Contributor

brson commented Aug 26, 2014

Nice patch! Thank you.

bors added a commit that referenced this pull request Aug 27, 2014
For review. Not sure about the link_attrs stuff. Will work on converting all the tests.

extern crate "foobar" as foo;
extern crate foobar as foo;

Implements remaining part of RFC #47.
Addresses issue #16461.

Removed link_attrs from rust.md, they don't appear to be supported by
the parser.
@bors bors closed this Aug 27, 2014
@bors bors merged commit c0e003d into rust-lang:master Aug 27, 2014
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.

6 participants