diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-19 15:39:03 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-24 14:55:15 -0700 |
| commit | eb2f1d925ffdb79d45c7b74cef549e54533c3951 (patch) | |
| tree | a517d12dbb1458f49e21ae40e026d699576dce92 /src/libsyntax/print | |
| parent | ed810385045ab0db90303574ba3ea47dfa2a36d5 (diff) | |
| download | rust-eb2f1d925ffdb79d45c7b74cef549e54533c3951.tar.gz rust-eb2f1d925ffdb79d45c7b74cef549e54533c3951.zip | |
rustc: Add support for `extern crate foo as bar`
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 828d085fd43..f6213b7db40 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -821,8 +821,13 @@ impl<'a> State<'a> { ast::ItemExternCrate(ref optional_path) => { try!(self.head(&visibility_qualified(item.vis, "extern crate"))); - if let Some((ref p, style)) = *optional_path { - try!(self.print_string(p, style)); + if let Some(p) = *optional_path { + let val = token::get_name(p); + if val.contains("-") { + try!(self.print_string(&val, ast::CookedStr)); + } else { + try!(self.print_name(p)); + } try!(space(&mut self.s)); try!(word(&mut self.s, "as")); try!(space(&mut self.s)); |
