From eb2f1d925ffdb79d45c7b74cef549e54533c3951 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Mar 2015 15:39:03 -0700 Subject: 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 --- src/libsyntax/print/pprust.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/print') 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)); -- cgit 1.4.1-3-g733a5