Skip to content

Commit f43f974

Browse files
committed
fix(lexer): Allow '-' in the infostring continue set
This more closely matches the RFC and what our T-lang contact has asked for, see #136889 (comment)
1 parent 9b0ddec commit f43f974

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

compiler/rustc_lexer/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,11 @@ impl Cursor<'_> {
540540
// whitespace between the opening and the infostring.
541541
self.eat_while(|ch| ch != '\n' && is_whitespace(ch));
542542

543-
// copied from `eat_identifier`, but allows `.` in infostring to allow something like
543+
// copied from `eat_identifier`, but allows `-` and `.` in infostring to allow something like
544544
// `---Cargo.toml` as a valid opener
545545
if is_id_start(self.first()) {
546546
self.bump();
547-
self.eat_while(|c| is_id_continue(c) || c == '.');
547+
self.eat_while(|c| is_id_continue(c) || c == '-' || c == '.');
548548
}
549549

550550
self.eat_while(|ch| ch != '\n' && is_whitespace(ch));

tests/ui/frontmatter/hyphen-in-infostring-non-leading.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--- Cargo-toml
2-
//~^ ERROR: invalid infostring for frontmatter
32
---
43

5-
// infostrings cannot have hyphens
4+
// infostrings can contain hyphens as long as a hyphen isn't the first character.
5+
//@ check-pass
66

77
#![feature(frontmatter)]
88

tests/ui/frontmatter/hyphen-in-infostring-non-leading.stderr

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)