From eb2f1d925ffdb79d45c7b74cef549e54533c3951 Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Thu, 19 Mar 2015 15:39:03 -0700
Subject: [PATCH] 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/librustc/metadata/creader.rs              | 32 ++++++++++++-------
 src/librustc_trans/save/mod.rs                |  2 +-
 src/librustdoc/visit_ast.rs                   |  2 +-
 src/libsyntax/ast.rs                          |  4 +--
 src/libsyntax/parse/mod.rs                    |  2 +-
 src/libsyntax/parse/obsolete.rs               |  6 ++++
 src/libsyntax/parse/parser.rs                 | 32 +++++++------------
 src/libsyntax/print/pprust.rs                 |  9 ++++--
 src/libsyntax/std_inject.rs                   |  6 ++--
 .../{coherence-lib.rs => coherence_lib.rs}    |  0
 ...-orphan-lib.rs => coherence_orphan_lib.rs} |  0
 .../{issue-11680.rs => issue_11680.rs}        |  0
 .../{issue-12612-1.rs => issue_12612_1.rs}    |  0
 .../{issue-12612-2.rs => issue_12612_2.rs}    |  0
 .../{issue-16725.rs => issue_16725.rs}        |  0
 ...rivacy.rs => issue_17718_const_privacy.rs} |  0
 .../{issue-21202.rs => issue_21202.rs}        |  0
 ...n-crate.rs => lint_unused_extern_crate.rs} |  0
 ...uple-struct.rs => privacy_tuple_struct.rs} |  0
 ...method_type_parameters_cross_crate_lib.rs} |  0
 ...eld-privacy.rs => struct_field_privacy.rs} |  0
 ...rait-safety-lib.rs => trait_safety_lib.rs} |  0
 ...t_trait_impl_cross_crate_coherence_lib.rs} |  0
 ...able-variant.rs => unreachable_variant.rs} |  0
 src/test/compile-fail/bad-crate-id.rs         |  1 +
 src/test/compile-fail/bad-crate-id2.rs        |  1 +
 src/test/compile-fail/coherence-all-remote.rs |  4 +--
 .../compile-fail/coherence-bigint-param.rs    |  4 +--
 .../compile-fail/coherence-cow-no-cover.rs    |  4 +--
 .../coherence-lone-type-parameter.rs          |  4 +--
 src/test/compile-fail/coherence-orphan.rs     |  4 +--
 .../coherence-overlapping-pairs.rs            |  4 +--
 .../coherence-pair-covered-uncovered-1.rs     |  4 +--
 .../coherence-pair-covered-uncovered.rs       |  4 +--
 .../derive-no-std-not-supported.rs            |  2 +-
 src/test/compile-fail/issue-11680.rs          |  4 +--
 src/test/compile-fail/issue-12612.rs          |  4 +--
 src/test/compile-fail/issue-16725.rs          |  4 +--
 .../compile-fail/issue-17718-const-privacy.rs |  4 +--
 src/test/compile-fail/issue-21202.rs          |  4 +--
 .../compile-fail/lint-unused-extern-crate.rs  |  6 ++--
 src/test/compile-fail/privacy5.rs             | 22 ++++++-------
 ...nded-method-type-parameters-cross-crate.rs |  4 +--
 .../compile-fail/static-array-across-crate.rs |  2 +-
 src/test/compile-fail/struct-field-privacy.rs |  8 ++---
 .../compile-fail/suggest-private-fields.rs    |  8 ++---
 .../trait-safety-trait-impl-cc.rs             |  4 +--
 ...efault-trait-impl-cross-crate-coherence.rs |  4 +--
 src/test/compile-fail/unreachable-variant.rs  |  4 +--
 src/test/parse-fail/bad-lit-suffixes.rs       |  1 +
 .../extern-crate-as-no-string-help.rs         | 15 ---------
 src/test/parse-fail/extern-foreign-crate.rs   |  2 +-
 src/test/pretty/issue-4264.pp                 |  2 +-
 src/test/pretty/raw-str-nonexpr.rs            |  2 +-
 .../run-make/weird-output-filenames/Makefile  |  2 +-
 src/test/run-pass/coherence-bigint-int.rs     |  4 +--
 src/test/run-pass/coherence-bigint-vecint.rs  |  4 +--
 src/test/run-pass/coherence-blanket.rs        |  4 +--
 .../coherence-covered-type-parameter.rs       |  4 +--
 src/test/run-pass/coherence-cow-1.rs          |  4 +--
 src/test/run-pass/coherence-cow-2.rs          |  4 +--
 .../coherence-iterator-vec-any-elem.rs        |  4 +--
 src/test/run-pass/coherence-iterator-vec.rs   |  4 +--
 src/test/run-pass/coherence-local-1.rs        |  4 +--
 src/test/run-pass/coherence-local-2.rs        |  4 +--
 src/test/run-pass/issue-12612.rs              |  8 ++---
 src/test/run-pass/trait-safety-ok-cc.rs       |  4 +--
 67 files changed, 144 insertions(+), 145 deletions(-)
 rename src/test/auxiliary/{coherence-lib.rs => coherence_lib.rs} (100%)
 rename src/test/auxiliary/{coherence-orphan-lib.rs => coherence_orphan_lib.rs} (100%)
 rename src/test/auxiliary/{issue-11680.rs => issue_11680.rs} (100%)
 rename src/test/auxiliary/{issue-12612-1.rs => issue_12612_1.rs} (100%)
 rename src/test/auxiliary/{issue-12612-2.rs => issue_12612_2.rs} (100%)
 rename src/test/auxiliary/{issue-16725.rs => issue_16725.rs} (100%)
 rename src/test/auxiliary/{issue-17718-const-privacy.rs => issue_17718_const_privacy.rs} (100%)
 rename src/test/auxiliary/{issue-21202.rs => issue_21202.rs} (100%)
 rename src/test/auxiliary/{lint-unused-extern-crate.rs => lint_unused_extern_crate.rs} (100%)
 rename src/test/auxiliary/{privacy-tuple-struct.rs => privacy_tuple_struct.rs} (100%)
 rename src/test/auxiliary/{regions-bounded-method-type-parameters-cross-crate-lib.rs => regions_bounded_method_type_parameters_cross_crate_lib.rs} (100%)
 rename src/test/auxiliary/{struct-field-privacy.rs => struct_field_privacy.rs} (100%)
 rename src/test/auxiliary/{trait-safety-lib.rs => trait_safety_lib.rs} (100%)
 rename src/test/auxiliary/{typeck-default-trait-impl-cross-crate-coherence-lib.rs => typeck_default_trait_impl_cross_crate_coherence_lib.rs} (100%)
 rename src/test/auxiliary/{unreachable-variant.rs => unreachable_variant.rs} (100%)
 delete mode 100644 src/test/parse-fail/extern-crate-as-no-string-help.rs

diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index 00a47ce17da..7d8789c3cd1 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -73,22 +73,24 @@ struct CrateInfo {
 }
 
 pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
-    let err = |s: &str| {
+    let say = |s: &str, warn: bool| {
         match (sp, sess) {
             (_, None) => panic!("{}", s),
+            (Some(sp), Some(sess)) if warn => sess.span_warn(sp, s),
             (Some(sp), Some(sess)) => sess.span_err(sp, s),
+            (None, Some(sess)) if warn => sess.warn(s),
             (None, Some(sess)) => sess.err(s),
         }
     };
     if s.len() == 0 {
-        err("crate name must not be empty");
-    } else if s.char_at(0) == '-' {
-        err(&format!("crate name cannot start with a hyphen: {}", s));
+        say("crate name must not be empty", false);
+    } else if s.contains("-") {
+        say(&format!("crate names soon cannot contain hyphens: {}", s), true);
     }
     for c in s.chars() {
         if c.is_alphanumeric() { continue }
         if c == '_' || c == '-' { continue }
-        err(&format!("invalid character `{}` in crate name: `{}`", c, s));
+        say(&format!("invalid character `{}` in crate name: `{}`", c, s), false);
     }
     match sess {
         Some(sess) => sess.abort_if_errors(),
@@ -153,8 +155,9 @@ impl<'a> CrateReader<'a> {
         }
     }
 
-    // Traverses an AST, reading all the information about use'd crates and extern
-    // libraries necessary for later resolving, typechecking, linking, etc.
+    // Traverses an AST, reading all the information about use'd crates and
+    // extern libraries necessary for later resolving, typechecking, linking,
+    // etc.
     pub fn read_crates(&mut self, krate: &ast::Crate) {
         self.process_crate(krate);
         visit::walk_crate(self, krate);
@@ -184,11 +187,10 @@ impl<'a> CrateReader<'a> {
                 debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
                        ident, path_opt);
                 let name = match *path_opt {
-                    Some((ref path_str, _)) => {
-                        let name = path_str.to_string();
-                        validate_crate_name(Some(self.sess), &name[..],
+                    Some(name) => {
+                        validate_crate_name(Some(self.sess), name.as_str(),
                                             Some(i.span));
-                        name
+                        name.as_str().to_string()
                     }
                     None => ident.to_string(),
                 };
@@ -304,7 +306,13 @@ impl<'a> CrateReader<'a> {
                       -> Option<ast::CrateNum> {
         let mut ret = None;
         self.sess.cstore.iter_crate_data(|cnum, data| {
-            if data.name != name { return }
+            // For now we do a "fuzzy match" on crate names by considering
+            // hyphens equal to underscores. This is purely meant to be a
+            // transitionary feature while we deprecate the quote syntax of
+            // `extern crate` statements.
+            if data.name != name.replace("-", "_") {
+                return
+            }
 
             match hash {
                 Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs
index 53aa6d44fe7..327e5ab3882 100644
--- a/src/librustc_trans/save/mod.rs
+++ b/src/librustc_trans/save/mod.rs
@@ -1165,7 +1165,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
                 let name = get_ident(item.ident);
                 let name = &name;
                 let location = match *s {
-                    Some((ref s, _)) => s.to_string(),
+                    Some(s) => s.to_string(),
                     None => name.to_string(),
                 };
                 let alias_span = self.span.span_for_last_ident(item.span);
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index 11e10cc2aa7..3f813b30ecc 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -237,7 +237,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             ast::ItemExternCrate(ref p) => {
                 let path = match *p {
                     None => None,
-                    Some((ref x, _)) => Some(x.to_string()),
+                    Some(x) => Some(x.to_string()),
                 };
                 om.extern_crates.push(ExternCrate {
                     name: name,
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 704abc43f10..fec67c7aef4 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1771,8 +1771,8 @@ pub struct Item {
 pub enum Item_ {
     /// An`extern crate` item, with optional original crate name,
     ///
-    /// e.g. `extern crate foo` or `extern crate "foo-bar" as foo`
-    ItemExternCrate(Option<(InternedString, StrStyle)>),
+    /// e.g. `extern crate foo` or `extern crate foo_bar as foo`
+    ItemExternCrate(Option<Name>),
     /// A `use` or `pub use` item
     ItemUse(P<ViewPath>),
 
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 968d2fd7e2a..4e851761212 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -1060,7 +1060,7 @@ mod test {
         let vitem_s = item_to_string(&*vitem);
         assert_eq!(&vitem_s[..], ex_s);
 
-        let ex_s = "extern crate \"foo\" as bar;";
+        let ex_s = "extern crate foo as bar;";
         let vitem = string_to_item(ex_s.to_string()).unwrap();
         let vitem_s = item_to_string(&*vitem);
         assert_eq!(&vitem_s[..], ex_s);
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 7da0a6de547..276be73823a 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -24,6 +24,7 @@ use ptr::P;
 pub enum ObsoleteSyntax {
     ClosureKind,
     EmptyIndex,
+    ExternCrateString,
 }
 
 pub trait ParserObsoleteMethods {
@@ -56,6 +57,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
                 "write `[..]` instead",
                 false, // warning for now
             ),
+            ObsoleteSyntax::ExternCrateString => (
+                "\"crate-name\"",
+                "use an identifier not in quotes instead",
+                false, // warning for now
+            ),
         };
 
         self.report(sp, kind, kind_str, desc, error);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 4ae5e0faa31..fe259d0bf78 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4986,37 +4986,28 @@ impl<'a> Parser<'a> {
                                 attrs: Vec<Attribute>)
                                 -> P<Item> {
 
-        let span = self.span;
         let (maybe_path, ident) = match self.token {
             token::Ident(..) => {
-                let the_ident = self.parse_ident();
-                let path = if self.eat_keyword_noexpect(keywords::As) {
-                    // skip the ident if there is one
-                    if self.token.is_ident() { self.bump(); }
-
-                    self.span_err(span, "expected `;`, found `as`");
-                    self.fileline_help(span,
-                                   &format!("perhaps you meant to enclose the crate name `{}` in \
-                                           a string?",
-                                          the_ident.as_str()));
-                    None
+                let crate_name = self.parse_ident();
+                if self.eat_keyword(keywords::As) {
+                    (Some(crate_name.name), self.parse_ident())
                 } else {
-                    None
-                };
-                self.expect(&token::Semi);
-                (path, the_ident)
+                    (None, crate_name)
+                }
             },
-            token::Literal(token::Str_(..), suf) | token::Literal(token::StrRaw(..), suf) => {
+            token::Literal(token::Str_(..), suf) |
+            token::Literal(token::StrRaw(..), suf) => {
                 let sp = self.span;
                 self.expect_no_suffix(sp, "extern crate name", suf);
                 // forgo the internal suffix check of `parse_str` to
                 // avoid repeats (this unwrap will always succeed due
                 // to the restriction of the `match`)
-                let (s, style, _) = self.parse_optional_str().unwrap();
+                let (s, _, _) = self.parse_optional_str().unwrap();
                 self.expect_keyword(keywords::As);
                 let the_ident = self.parse_ident();
-                self.expect(&token::Semi);
-                (Some((s, style)), the_ident)
+                self.obsolete(sp, ObsoleteSyntax::ExternCrateString);
+                let s = token::intern(&s);
+                (Some(s), the_ident)
             },
             _ => {
                 let span = self.span;
@@ -5027,6 +5018,7 @@ impl<'a> Parser<'a> {
                                         token_str));
             }
         };
+        self.expect(&token::Semi);
 
         let last_span = self.last_span;
         self.mk_item(lo,
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));
diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs
index ac7cdb1b413..0fa7e4f902c 100644
--- a/src/libsyntax/std_inject.rs
+++ b/src/libsyntax/std_inject.rs
@@ -54,8 +54,8 @@ impl fold::Folder for StandardLibraryInjector {
 
         // The name to use in `extern crate "name" as std;`
         let actual_crate_name = match self.alt_std_name {
-            Some(ref s) => token::intern_and_get_ident(&s[..]),
-            None => token::intern_and_get_ident("std"),
+            Some(ref s) => token::intern(&s),
+            None => token::intern("std"),
         };
 
         krate.module.items.insert(0, P(ast::Item {
@@ -64,7 +64,7 @@ impl fold::Folder for StandardLibraryInjector {
             attrs: vec!(
                 attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
                         InternedString::new("macro_use")))),
-            node: ast::ItemExternCrate(Some((actual_crate_name, ast::CookedStr))),
+            node: ast::ItemExternCrate(Some(actual_crate_name)),
             vis: ast::Inherited,
             span: DUMMY_SP
         }));
diff --git a/src/test/auxiliary/coherence-lib.rs b/src/test/auxiliary/coherence_lib.rs
similarity index 100%
rename from src/test/auxiliary/coherence-lib.rs
rename to src/test/auxiliary/coherence_lib.rs
diff --git a/src/test/auxiliary/coherence-orphan-lib.rs b/src/test/auxiliary/coherence_orphan_lib.rs
similarity index 100%
rename from src/test/auxiliary/coherence-orphan-lib.rs
rename to src/test/auxiliary/coherence_orphan_lib.rs
diff --git a/src/test/auxiliary/issue-11680.rs b/src/test/auxiliary/issue_11680.rs
similarity index 100%
rename from src/test/auxiliary/issue-11680.rs
rename to src/test/auxiliary/issue_11680.rs
diff --git a/src/test/auxiliary/issue-12612-1.rs b/src/test/auxiliary/issue_12612_1.rs
similarity index 100%
rename from src/test/auxiliary/issue-12612-1.rs
rename to src/test/auxiliary/issue_12612_1.rs
diff --git a/src/test/auxiliary/issue-12612-2.rs b/src/test/auxiliary/issue_12612_2.rs
similarity index 100%
rename from src/test/auxiliary/issue-12612-2.rs
rename to src/test/auxiliary/issue_12612_2.rs
diff --git a/src/test/auxiliary/issue-16725.rs b/src/test/auxiliary/issue_16725.rs
similarity index 100%
rename from src/test/auxiliary/issue-16725.rs
rename to src/test/auxiliary/issue_16725.rs
diff --git a/src/test/auxiliary/issue-17718-const-privacy.rs b/src/test/auxiliary/issue_17718_const_privacy.rs
similarity index 100%
rename from src/test/auxiliary/issue-17718-const-privacy.rs
rename to src/test/auxiliary/issue_17718_const_privacy.rs
diff --git a/src/test/auxiliary/issue-21202.rs b/src/test/auxiliary/issue_21202.rs
similarity index 100%
rename from src/test/auxiliary/issue-21202.rs
rename to src/test/auxiliary/issue_21202.rs
diff --git a/src/test/auxiliary/lint-unused-extern-crate.rs b/src/test/auxiliary/lint_unused_extern_crate.rs
similarity index 100%
rename from src/test/auxiliary/lint-unused-extern-crate.rs
rename to src/test/auxiliary/lint_unused_extern_crate.rs
diff --git a/src/test/auxiliary/privacy-tuple-struct.rs b/src/test/auxiliary/privacy_tuple_struct.rs
similarity index 100%
rename from src/test/auxiliary/privacy-tuple-struct.rs
rename to src/test/auxiliary/privacy_tuple_struct.rs
diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions_bounded_method_type_parameters_cross_crate_lib.rs
similarity index 100%
rename from src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
rename to src/test/auxiliary/regions_bounded_method_type_parameters_cross_crate_lib.rs
diff --git a/src/test/auxiliary/struct-field-privacy.rs b/src/test/auxiliary/struct_field_privacy.rs
similarity index 100%
rename from src/test/auxiliary/struct-field-privacy.rs
rename to src/test/auxiliary/struct_field_privacy.rs
diff --git a/src/test/auxiliary/trait-safety-lib.rs b/src/test/auxiliary/trait_safety_lib.rs
similarity index 100%
rename from src/test/auxiliary/trait-safety-lib.rs
rename to src/test/auxiliary/trait_safety_lib.rs
diff --git a/src/test/auxiliary/typeck-default-trait-impl-cross-crate-coherence-lib.rs b/src/test/auxiliary/typeck_default_trait_impl_cross_crate_coherence_lib.rs
similarity index 100%
rename from src/test/auxiliary/typeck-default-trait-impl-cross-crate-coherence-lib.rs
rename to src/test/auxiliary/typeck_default_trait_impl_cross_crate_coherence_lib.rs
diff --git a/src/test/auxiliary/unreachable-variant.rs b/src/test/auxiliary/unreachable_variant.rs
similarity index 100%
rename from src/test/auxiliary/unreachable-variant.rs
rename to src/test/auxiliary/unreachable_variant.rs
diff --git a/src/test/compile-fail/bad-crate-id.rs b/src/test/compile-fail/bad-crate-id.rs
index 71e3ce9a35a..193666f8269 100644
--- a/src/test/compile-fail/bad-crate-id.rs
+++ b/src/test/compile-fail/bad-crate-id.rs
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 extern crate "" as foo; //~ ERROR: crate name must not be empty
+//~^ WARNING: obsolete syntax
 
 fn main() {}
diff --git a/src/test/compile-fail/bad-crate-id2.rs b/src/test/compile-fail/bad-crate-id2.rs
index 6425908672d..29df0fa705e 100644
--- a/src/test/compile-fail/bad-crate-id2.rs
+++ b/src/test/compile-fail/bad-crate-id2.rs
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 extern crate "#a" as bar; //~ ERROR: invalid character `#` in crate name: `#a`
+//~^ WARNING: obsolete syntax
 
 fn main() {}
diff --git a/src/test/compile-fail/coherence-all-remote.rs b/src/test/compile-fail/coherence-all-remote.rs
index 1e3b7f6dbd2..7a5340041c2 100644
--- a/src/test/compile-fail/coherence-all-remote.rs
+++ b/src/test/compile-fail/coherence-all-remote.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 impl<T> Remote1<T> for isize { }
diff --git a/src/test/compile-fail/coherence-bigint-param.rs b/src/test/compile-fail/coherence-bigint-param.rs
index b7ca499be73..32c5b669381 100644
--- a/src/test/compile-fail/coherence-bigint-param.rs
+++ b/src/test/compile-fail/coherence-bigint-param.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 pub struct BigInt;
diff --git a/src/test/compile-fail/coherence-cow-no-cover.rs b/src/test/compile-fail/coherence-cow-no-cover.rs
index 1bec97de533..475d7df1fdb 100644
--- a/src/test/compile-fail/coherence-cow-no-cover.rs
+++ b/src/test/compile-fail/coherence-cow-no-cover.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // Test that it's not ok for U to appear uncovered
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::{Remote,Pair};
 
 pub struct Cover<T>(T);
diff --git a/src/test/compile-fail/coherence-lone-type-parameter.rs b/src/test/compile-fail/coherence-lone-type-parameter.rs
index 9f7481f12f2..e78f392b386 100644
--- a/src/test/compile-fail/coherence-lone-type-parameter.rs
+++ b/src/test/compile-fail/coherence-lone-type-parameter.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote;
 
 impl<T> Remote for T { }
diff --git a/src/test/compile-fail/coherence-orphan.rs b/src/test/compile-fail/coherence-orphan.rs
index 97dffec2dd9..2243a0507f2 100644
--- a/src/test/compile-fail/coherence-orphan.rs
+++ b/src/test/compile-fail/coherence-orphan.rs
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 // ignore-tidy-linelength
-// aux-build:coherence-orphan-lib.rs
+// aux-build:coherence_orphan_lib.rs
 
 #![feature(optin_builtin_traits)]
 
-extern crate "coherence-orphan-lib" as lib;
+extern crate coherence_orphan_lib as lib;
 
 use lib::TheTrait;
 
diff --git a/src/test/compile-fail/coherence-overlapping-pairs.rs b/src/test/compile-fail/coherence-overlapping-pairs.rs
index 9878bdec2c3..ba9dc53e868 100644
--- a/src/test/compile-fail/coherence-overlapping-pairs.rs
+++ b/src/test/compile-fail/coherence-overlapping-pairs.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote;
 
 struct Foo;
diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs
index 2bdcc346f70..f55efef14fa 100644
--- a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs
+++ b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs
@@ -11,9 +11,9 @@
 // Test that the same coverage rules apply even if the local type appears in the
 // list of type parameters, not the self type.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::{Remote1, Pair};
 
 pub struct Local<T>(T);
diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered.rs b/src/test/compile-fail/coherence-pair-covered-uncovered.rs
index 881494f009f..0642dff4b28 100644
--- a/src/test/compile-fail/coherence-pair-covered-uncovered.rs
+++ b/src/test/compile-fail/coherence-pair-covered-uncovered.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::{Remote, Pair};
 
 struct Local<T>(T);
diff --git a/src/test/compile-fail/derive-no-std-not-supported.rs b/src/test/compile-fail/derive-no-std-not-supported.rs
index f82e7f3e36a..d0cb4f23a8c 100644
--- a/src/test/compile-fail/derive-no-std-not-supported.rs
+++ b/src/test/compile-fail/derive-no-std-not-supported.rs
@@ -13,7 +13,7 @@
 
 extern crate core;
 extern crate rand;
-extern crate "serialize" as rustc_serialize;
+extern crate serialize as rustc_serialize;
 
 #[derive(Rand)]  //~ ERROR this trait cannot be derived
 //~^ WARNING `#[derive(Rand)]` is deprecated
diff --git a/src/test/compile-fail/issue-11680.rs b/src/test/compile-fail/issue-11680.rs
index 0f30243b39a..1bd7b0aa1c2 100644
--- a/src/test/compile-fail/issue-11680.rs
+++ b/src/test/compile-fail/issue-11680.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-11680.rs
+// aux-build:issue_11680.rs
 
-extern crate "issue-11680" as other;
+extern crate issue_11680 as other;
 
 fn main() {
     let _b = other::Foo::Bar(1);
diff --git a/src/test/compile-fail/issue-12612.rs b/src/test/compile-fail/issue-12612.rs
index 41cd3863001..f76d12d93fd 100644
--- a/src/test/compile-fail/issue-12612.rs
+++ b/src/test/compile-fail/issue-12612.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-12612-1.rs
+// aux-build:issue_12612_1.rs
 
-extern crate "issue-12612-1" as foo;
+extern crate issue_12612_1 as foo;
 
 use foo::bar;
 
diff --git a/src/test/compile-fail/issue-16725.rs b/src/test/compile-fail/issue-16725.rs
index 67fcd820429..cadf602a4cf 100644
--- a/src/test/compile-fail/issue-16725.rs
+++ b/src/test/compile-fail/issue-16725.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-16725.rs
+// aux-build:issue_16725.rs
 
-extern crate "issue-16725" as foo;
+extern crate issue_16725 as foo;
 
 fn main() {
     unsafe { foo::bar(); }
diff --git a/src/test/compile-fail/issue-17718-const-privacy.rs b/src/test/compile-fail/issue-17718-const-privacy.rs
index a9af30a3ff0..021edbee566 100644
--- a/src/test/compile-fail/issue-17718-const-privacy.rs
+++ b/src/test/compile-fail/issue-17718-const-privacy.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-17718-const-privacy.rs
+// aux-build:issue_17718_const_privacy.rs
 
-extern crate "issue-17718-const-privacy" as other;
+extern crate issue_17718_const_privacy as other;
 
 use a::B; //~ ERROR: const `B` is private
 use other::{
diff --git a/src/test/compile-fail/issue-21202.rs b/src/test/compile-fail/issue-21202.rs
index 05485008e51..2bce838c1cf 100644
--- a/src/test/compile-fail/issue-21202.rs
+++ b/src/test/compile-fail/issue-21202.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-21202.rs
+// aux-build:issue_21202.rs
 
-extern crate "issue-21202" as crate1;
+extern crate issue_21202 as crate1;
 
 use crate1::A;
 
diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs
index ada0cd2bc98..854c51d0769 100644
--- a/src/test/compile-fail/lint-unused-extern-crate.rs
+++ b/src/test/compile-fail/lint-unused-extern-crate.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:lint-unused-extern-crate.rs
+// aux-build:lint_unused_extern_crate.rs
 
 #![deny(unused_extern_crates)]
 #![allow(unused_variables)]
@@ -19,12 +19,12 @@
 
 extern crate libc; //~ ERROR: unused extern crate
 
-extern crate "collections" as collecs; // no error, it is used
+extern crate collections as collecs; // no error, it is used
 
 extern crate rand; // no error, the use marks it as used
                    // even if imported objects aren't used
 
-extern crate "lint-unused-extern-crate" as other; // no error, the use * marks it as used
+extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used
 
 #[allow(unused_imports)]
 use rand::isaac::IsaacRng;
diff --git a/src/test/compile-fail/privacy5.rs b/src/test/compile-fail/privacy5.rs
index a7f6a514b96..4ca37fc2ad2 100644
--- a/src/test/compile-fail/privacy5.rs
+++ b/src/test/compile-fail/privacy5.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:privacy-tuple-struct.rs
+// aux-build:privacy_tuple_struct.rs
 
-extern crate "privacy-tuple-struct" as other;
+extern crate privacy_tuple_struct as other;
 
 mod a {
     pub struct A(());
@@ -101,30 +101,30 @@ fn xcrate() {
     let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
     let d = other::D(4);
 
-    let other::A(()) = a; //~ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
+    let other::A(()) = a; //~ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
     let other::A(_) = a;
     match a { other::A(()) => {} }
-    //~^ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
+    //~^ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
     match a { other::A(_) => {} }
 
     let other::B(_) = b;
-    let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
+    let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
     match b { other::B(_) => {} }
     match b { other::B(_b) => {} }
-    //~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
+    //~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
     match b { other::B(1) => {} other::B(_) => {} }
-    //~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
+    //~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
 
     let other::C(_, _) = c;
     let other::C(_a, _) = c;
-    let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
-    let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
+    let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
+    let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
     match c { other::C(_, _) => {} }
     match c { other::C(_a, _) => {} }
     match c { other::C(_, _b) => {} }
-    //~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
+    //~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
     match c { other::C(_a, _b) => {} }
-    //~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
+    //~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
 
     let other::D(_) = d;
     let other::D(_d) = d;
diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
index 1705cfec6e2..82d05c5d716 100644
--- a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
+++ b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:regions-bounded-method-type-parameters-cross-crate-lib.rs
+// aux-build:regions_bounded_method_type_parameters_cross_crate_lib.rs
 
 // Check explicit region bounds on methods in the cross crate case.
 
-extern crate "regions-bounded-method-type-parameters-cross-crate-lib" as lib;
+extern crate regions_bounded_method_type_parameters_cross_crate_lib as lib;
 
 use lib::Inv;
 use lib::MaybeOwned;
diff --git a/src/test/compile-fail/static-array-across-crate.rs b/src/test/compile-fail/static-array-across-crate.rs
index 422cf630429..04a731e847a 100644
--- a/src/test/compile-fail/static-array-across-crate.rs
+++ b/src/test/compile-fail/static-array-across-crate.rs
@@ -10,7 +10,7 @@
 
 // aux-build:pub_static_array.rs
 
-extern crate "pub_static_array" as array;
+extern crate pub_static_array as array;
 
 use array::ARRAY;
 
diff --git a/src/test/compile-fail/struct-field-privacy.rs b/src/test/compile-fail/struct-field-privacy.rs
index 667e944f92c..a1b6b9a744c 100644
--- a/src/test/compile-fail/struct-field-privacy.rs
+++ b/src/test/compile-fail/struct-field-privacy.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:struct-field-privacy.rs
+// aux-build:struct_field_privacy.rs
 
-extern crate "struct-field-privacy" as xc;
+extern crate struct_field_privacy as xc;
 
 struct A {
     a: isize,
@@ -37,11 +37,11 @@ fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B) {
     c.a;
     c.b; //~ ERROR: field `b` of struct `inner::B` is private
 
-    d.a; //~ ERROR: field `a` of struct `struct-field-privacy::A` is private
+    d.a; //~ ERROR: field `a` of struct `struct_field_privacy::A` is private
     d.b;
 
     e.a;
-    e.b; //~ ERROR: field `b` of struct `struct-field-privacy::B` is private
+    e.b; //~ ERROR: field `b` of struct `struct_field_privacy::B` is private
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/suggest-private-fields.rs b/src/test/compile-fail/suggest-private-fields.rs
index 30648498ba8..f987257d4ee 100644
--- a/src/test/compile-fail/suggest-private-fields.rs
+++ b/src/test/compile-fail/suggest-private-fields.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:struct-field-privacy.rs
+// aux-build:struct_field_privacy.rs
 
-extern crate "struct-field-privacy" as xc;
+extern crate struct_field_privacy as xc;
 
 use xc::B;
 
@@ -22,9 +22,9 @@ struct A {
 fn main () {
     // external crate struct
     let k = B {
-        aa: 20, //~ ERROR structure `struct-field-privacy::B` has no field named `aa`
+        aa: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `aa`
         //~^ HELP did you mean `a`?
-        bb: 20, //~ ERROR structure `struct-field-privacy::B` has no field named `bb`
+        bb: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `bb`
     };
     // local crate struct
     let l = A {
diff --git a/src/test/compile-fail/trait-safety-trait-impl-cc.rs b/src/test/compile-fail/trait-safety-trait-impl-cc.rs
index 032deb2e017..6050b549b65 100644
--- a/src/test/compile-fail/trait-safety-trait-impl-cc.rs
+++ b/src/test/compile-fail/trait-safety-trait-impl-cc.rs
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:trait-safety-lib.rs
+// aux-build:trait_safety_lib.rs
 
 // Check that unsafe traits require unsafe impls and that inherent
 // impls cannot be unsafe.
 
-extern crate "trait-safety-lib" as lib;
+extern crate trait_safety_lib as lib;
 
 struct Bar;
 impl lib::Foo for Bar { //~ ERROR requires an `unsafe impl` declaration
diff --git a/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs b/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs
index 3a29bb9c227..7d25c04882f 100644
--- a/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs
+++ b/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs
@@ -8,14 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:typeck-default-trait-impl-cross-crate-coherence-lib.rs
+// aux-build:typeck_default_trait_impl_cross_crate_coherence_lib.rs
 
 // Test that we do not consider associated types to be sendable without
 // some applicable trait bound (and we don't ICE).
 
 #![feature(optin_builtin_traits)]
 
-extern crate "typeck-default-trait-impl-cross-crate-coherence-lib" as lib;
+extern crate typeck_default_trait_impl_cross_crate_coherence_lib as lib;
 
 use lib::DefaultedTrait;
 
diff --git a/src/test/compile-fail/unreachable-variant.rs b/src/test/compile-fail/unreachable-variant.rs
index ef991d85337..5983c83f8b4 100644
--- a/src/test/compile-fail/unreachable-variant.rs
+++ b/src/test/compile-fail/unreachable-variant.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:unreachable-variant.rs
+// aux-build:unreachable_variant.rs
 
-extern crate "unreachable-variant" as other;
+extern crate unreachable_variant as other;
 
 fn main() {
     let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private
diff --git a/src/test/parse-fail/bad-lit-suffixes.rs b/src/test/parse-fail/bad-lit-suffixes.rs
index d10337e768c..9e5fe4ab8a9 100644
--- a/src/test/parse-fail/bad-lit-suffixes.rs
+++ b/src/test/parse-fail/bad-lit-suffixes.rs
@@ -11,6 +11,7 @@
 
 extern crate
     "foo"suffix //~ ERROR extern crate name with a suffix is illegal
+                //~^ WARNING: obsolete syntax
      as foo;
 
 extern
diff --git a/src/test/parse-fail/extern-crate-as-no-string-help.rs b/src/test/parse-fail/extern-crate-as-no-string-help.rs
deleted file mode 100644
index 5cc52f6f6db..00000000000
--- a/src/test/parse-fail/extern-crate-as-no-string-help.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Tests that the proper help is displayed in the error message
-
-extern crate foo as bar;
-//~^ ERROR expected `;`, found `as`
-//~^^ HELP perhaps you meant to enclose the crate name `foo` in a string?
diff --git a/src/test/parse-fail/extern-foreign-crate.rs b/src/test/parse-fail/extern-foreign-crate.rs
index 24b978b0a21..1ff4368dac5 100644
--- a/src/test/parse-fail/extern-foreign-crate.rs
+++ b/src/test/parse-fail/extern-foreign-crate.rs
@@ -11,4 +11,4 @@
 // Verifies that the expected token errors for `extern crate` are
 // raised
 
-extern crate foo {} //~ERROR expected `;`, found `{`
+extern crate foo {} //~ERROR expected one of `;` or `as`, found `{`
diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp
index 58cd19059c0..c2ed10ce6a1 100644
--- a/src/test/pretty/issue-4264.pp
+++ b/src/test/pretty/issue-4264.pp
@@ -3,7 +3,7 @@
 #[prelude_import]
 use std::prelude::v1::*;
 #[macro_use]
-extern crate "std" as std;
+extern crate std as std;
 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
diff --git a/src/test/pretty/raw-str-nonexpr.rs b/src/test/pretty/raw-str-nonexpr.rs
index 965b1760f1f..bce78e4f4c1 100644
--- a/src/test/pretty/raw-str-nonexpr.rs
+++ b/src/test/pretty/raw-str-nonexpr.rs
@@ -13,6 +13,6 @@
 #![feature(asm)]
 
 #[cfg(foo = r#"just parse this"#)]
-extern crate r##"blah"## as blah;
+extern crate blah as blah;
 
 fn main() { unsafe { asm!(r###"blah"###); } }
diff --git a/src/test/run-make/weird-output-filenames/Makefile b/src/test/run-make/weird-output-filenames/Makefile
index 3d57a2263e1..2172ed888b1 100644
--- a/src/test/run-make/weird-output-filenames/Makefile
+++ b/src/test/run-make/weird-output-filenames/Makefile
@@ -12,4 +12,4 @@ all:
 		| grep "invalid character.*in crate name:"
 	cp foo.rs $(TMPDIR)/-foo.rs
 	$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
-		| grep "crate name cannot start with a hyphen:"
+		| grep "soon cannot contain hyphens:"
diff --git a/src/test/run-pass/coherence-bigint-int.rs b/src/test/run-pass/coherence-bigint-int.rs
index cbfe30906a7..9ad4f6b9d75 100644
--- a/src/test/run-pass/coherence-bigint-int.rs
+++ b/src/test/run-pass/coherence-bigint-int.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 pub struct BigInt;
diff --git a/src/test/run-pass/coherence-bigint-vecint.rs b/src/test/run-pass/coherence-bigint-vecint.rs
index 8537c1bb002..ac4b98cfc8c 100644
--- a/src/test/run-pass/coherence-bigint-vecint.rs
+++ b/src/test/run-pass/coherence-bigint-vecint.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 pub struct BigInt;
diff --git a/src/test/run-pass/coherence-blanket.rs b/src/test/run-pass/coherence-blanket.rs
index 2f2709698a0..32743aafa82 100644
--- a/src/test/run-pass/coherence-blanket.rs
+++ b/src/test/run-pass/coherence-blanket.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 pub trait Local {
diff --git a/src/test/run-pass/coherence-covered-type-parameter.rs b/src/test/run-pass/coherence-covered-type-parameter.rs
index 7bb3a01ccf8..890470d8ac2 100644
--- a/src/test/run-pass/coherence-covered-type-parameter.rs
+++ b/src/test/run-pass/coherence-covered-type-parameter.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote;
 
 struct Foo<T>(T);
diff --git a/src/test/run-pass/coherence-cow-1.rs b/src/test/run-pass/coherence-cow-1.rs
index 4d76f482b4e..31f6c9af020 100644
--- a/src/test/run-pass/coherence-cow-1.rs
+++ b/src/test/run-pass/coherence-cow-1.rs
@@ -8,14 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // Test that it's ok for T to appear first in the self-type, as long
 // as it's covered somewhere.
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::{Remote,Pair};
 
 pub struct Cover<T>(T);
diff --git a/src/test/run-pass/coherence-cow-2.rs b/src/test/run-pass/coherence-cow-2.rs
index 685432ad1cf..ccda8440ea2 100644
--- a/src/test/run-pass/coherence-cow-2.rs
+++ b/src/test/run-pass/coherence-cow-2.rs
@@ -8,14 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // Test that it's ok for T to appear second in the self-type, as long
 // as it's covered somewhere.
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::{Remote,Pair};
 
 pub struct Cover<T>(T);
diff --git a/src/test/run-pass/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/coherence-iterator-vec-any-elem.rs
index e807b6ca3bc..04a6cd58827 100644
--- a/src/test/run-pass/coherence-iterator-vec-any-elem.rs
+++ b/src/test/run-pass/coherence-iterator-vec-any-elem.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 struct Foo<T>(T);
diff --git a/src/test/run-pass/coherence-iterator-vec.rs b/src/test/run-pass/coherence-iterator-vec.rs
index 3cb3efe8e7b..8a3301dee27 100644
--- a/src/test/run-pass/coherence-iterator-vec.rs
+++ b/src/test/run-pass/coherence-iterator-vec.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote1;
 
 struct Foo<T>(T);
diff --git a/src/test/run-pass/coherence-local-1.rs b/src/test/run-pass/coherence-local-1.rs
index 172066abb2b..21faa30245d 100644
--- a/src/test/run-pass/coherence-local-1.rs
+++ b/src/test/run-pass/coherence-local-1.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote;
 
 struct Local;
diff --git a/src/test/run-pass/coherence-local-2.rs b/src/test/run-pass/coherence-local-2.rs
index afdea4e6b7f..5fd3e8ca86e 100644
--- a/src/test/run-pass/coherence-local-2.rs
+++ b/src/test/run-pass/coherence-local-2.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:coherence-lib.rs
+// aux-build:coherence_lib.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "coherence-lib" as lib;
+extern crate coherence_lib as lib;
 use lib::Remote;
 
 struct Local<T>(T);
diff --git a/src/test/run-pass/issue-12612.rs b/src/test/run-pass/issue-12612.rs
index 8a23e43d59e..bdf8f84a959 100644
--- a/src/test/run-pass/issue-12612.rs
+++ b/src/test/run-pass/issue-12612.rs
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:issue-12612-1.rs
-// aux-build:issue-12612-2.rs
+// aux-build:issue_12612_1.rs
+// aux-build:issue_12612_2.rs
 
 // pretty-expanded FIXME #23616
 
-extern crate "issue-12612-1" as foo;
-extern crate "issue-12612-2" as bar;
+extern crate issue_12612_1 as foo;
+extern crate issue_12612_2 as bar;
 
 mod test {
     use bar::baz;
diff --git a/src/test/run-pass/trait-safety-ok-cc.rs b/src/test/run-pass/trait-safety-ok-cc.rs
index 11a58de4532..28f683c485a 100644
--- a/src/test/run-pass/trait-safety-ok-cc.rs
+++ b/src/test/run-pass/trait-safety-ok-cc.rs
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// aux-build:trait-safety-lib.rs
+// aux-build:trait_safety_lib.rs
 
 // Simple smoke test that unsafe traits can be compiled across crates.
 
 // pretty-expanded FIXME #23616
 
-extern crate "trait-safety-lib" as lib;
+extern crate trait_safety_lib as lib;
 
 use lib::Foo;