-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
|
||
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 |
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.
Do we actually support this sort of versioned crate id meaningfully in rustc? (@alexcrichton?)
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.
Currently no, this is actually an invalid crate ID today (safe to remove)
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 ] |
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.
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
.
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.
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
Nice patch! Thank you. |
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.