Skip to content

Commit 8da4be0

Browse files
committed
Auto merge of rust-lang#115304 - Enselic:trailing-gt, r=cjgillot
Allow file names to end with '>' The [`rustc_span::FileName`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/enum.FileName.html) enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`. Closes rust-lang#73419
2 parents 5236c8e + a0cac34 commit 8da4be0

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

compiler/rustc_span/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ pub enum FileName {
305305

306306
impl From<PathBuf> for FileName {
307307
fn from(p: PathBuf) -> Self {
308-
assert!(!p.to_string_lossy().ends_with('>'));
309308
FileName::Real(RealFileName::LocalPath(p))
310309
}
311310
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
include ../tools.mk
2+
3+
# We are creating files with forbidden characters in their names, so we need to
4+
# ignore-windows
5+
6+
ifdef RUSTC_BLESS_TEST
7+
RUSTC_TEST_OP = cp
8+
else
9+
RUSTC_TEST_OP = $(DIFF)
10+
endif
11+
12+
all:
13+
echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt"
14+
echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>"
15+
cp silly-file-names.rs "$(TMPDIR)/silly-file-names.rs"
16+
$(RUSTC) "$(TMPDIR)/silly-file-names.rs" -o "$(TMPDIR)/silly-file-names"
17+
"$(TMPDIR)/silly-file-names" > "$(TMPDIR)/silly-file-names.run.stdout"
18+
$(RUSTC_TEST_OP) "$(TMPDIR)/silly-file-names.run.stdout" silly-file-names.run.stdout
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// run-pass
2+
// check-run-results
3+
4+
fn main() {
5+
println!(include!("<leading-lt"));
6+
println!(include!("trailing-gt>"));
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
comes from a file with a name that begins with <
2+
comes from a file with a name that ends with >

0 commit comments

Comments
 (0)