Skip to content

Commit 5a41536

Browse files
Manishearthalexcrichton
authored andcommitted
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.
2 parents 65b1a98 + a7594f2 commit 5a41536

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
8181
};
8282
if s.len() == 0 {
8383
err("crate name must not be empty");
84+
} else if s.char_at(0) == '-' {
85+
err(&format!("crate name cannot start with a hyphen: {}", s));
8486
}
8587
for c in s.chars() {
8688
if c.is_alphanumeric() { continue }

src/test/run-make/weird-output-filenames/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ all:
1010
cp foo.rs $(TMPDIR)/+foo+bar
1111
$(RUSTC) $(TMPDIR)/+foo+bar 2>&1 \
1212
| grep "invalid character.*in crate name:"
13+
cp foo.rs $(TMPDIR)/-foo.rs
14+
$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
15+
| grep "crate name cannot start with a hyphen:"

0 commit comments

Comments
 (0)