about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-02-23 14:54:43 +0530
committerAlex Crichton <alex@alexcrichton.com>2015-02-23 11:43:56 -0800
commit5a41536462af8bdf58950238c101a5ffd11267f6 (patch)
treed7bd3d597e5e1e83e6a9cd706bb9a5b0c3a90e56
parent65b1a985229663435851997e44155482eda2f6f4 (diff)
parenta7594f2d5b9f668b1001c9b0b6f1fdd95768c2c5 (diff)
Rollup merge of #22664 - lfairy:just-say-no, r=alexcrichton
 Leading hyphens already don't work (#22661), so no code should break from this change.

Closes #22661.
-rw-r--r--src/librustc/metadata/creader.rs2
-rw-r--r--src/test/run-make/weird-output-filenames/Makefile3
2 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index 4c123b55e8e..46155925b3c 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -81,6 +81,8 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
     };
     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));
     }
     for c in s.chars() {
         if c.is_alphanumeric() { continue }
diff --git a/src/test/run-make/weird-output-filenames/Makefile b/src/test/run-make/weird-output-filenames/Makefile
index 5d6e629ffc1..3d57a2263e1 100644
--- a/src/test/run-make/weird-output-filenames/Makefile
+++ b/src/test/run-make/weird-output-filenames/Makefile
@@ -10,3 +10,6 @@ all:
 	cp foo.rs $(TMPDIR)/+foo+bar
 	$(RUSTC) $(TMPDIR)/+foo+bar 2>&1 \
 		| 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:"