diff options
| author | bors <bors@rust-lang.org> | 2023-10-06 14:57:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-06 14:57:09 +0000 |
| commit | 64fa0c34d7cb1a2d522414ab2c87024e465bd613 (patch) | |
| tree | 0b965f17a3c2bd707cd111f094216d5a679dc0b8 | |
| parent | 1bc0463b183392ad4e0ae9c5f7a76630d487230d (diff) | |
| parent | 8a1be9942d63f0417efc1ead54dd71ff088140e3 (diff) | |
| download | rust-64fa0c34d7cb1a2d522414ab2c87024e465bd613.tar.gz rust-64fa0c34d7cb1a2d522414ab2c87024e465bd613.zip | |
Auto merge of #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 #73419
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 1 | ||||
| -rw-r--r-- | tests/run-make/silly-file-names/Makefile | 18 | ||||
| -rw-r--r-- | tests/run-make/silly-file-names/silly-file-names.rs | 4 | ||||
| -rw-r--r-- | tests/run-make/silly-file-names/silly-file-names.run.stdout | 2 |
4 files changed, 24 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 772e09291a1..36d7c7653ee 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -305,7 +305,6 @@ pub enum FileName { impl From<PathBuf> for FileName { fn from(p: PathBuf) -> Self { - assert!(!p.to_string_lossy().ends_with('>')); FileName::Real(RealFileName::LocalPath(p)) } } diff --git a/tests/run-make/silly-file-names/Makefile b/tests/run-make/silly-file-names/Makefile new file mode 100644 index 00000000000..a09bdb1c532 --- /dev/null +++ b/tests/run-make/silly-file-names/Makefile @@ -0,0 +1,18 @@ +# ignore-cross-compile we need to execute the binary +# ignore-windows we create files with < and > in their names + +include ../tools.mk + +ifdef RUSTC_BLESS_TEST + RUSTC_TEST_OP = cp +else + RUSTC_TEST_OP = $(DIFF) +endif + +all: + echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt" + echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>" + cp silly-file-names.rs "$(TMPDIR)/silly-file-names.rs" + $(RUSTC) "$(TMPDIR)/silly-file-names.rs" -o "$(TMPDIR)/silly-file-names" + "$(TMPDIR)/silly-file-names" > "$(TMPDIR)/silly-file-names.run.stdout" + $(RUSTC_TEST_OP) "$(TMPDIR)/silly-file-names.run.stdout" silly-file-names.run.stdout diff --git a/tests/run-make/silly-file-names/silly-file-names.rs b/tests/run-make/silly-file-names/silly-file-names.rs new file mode 100644 index 00000000000..a2008209141 --- /dev/null +++ b/tests/run-make/silly-file-names/silly-file-names.rs @@ -0,0 +1,4 @@ +fn main() { + println!(include!("<leading-lt")); + println!(include!("trailing-gt>")); +} diff --git a/tests/run-make/silly-file-names/silly-file-names.run.stdout b/tests/run-make/silly-file-names/silly-file-names.run.stdout new file mode 100644 index 00000000000..fbc4c89e0f0 --- /dev/null +++ b/tests/run-make/silly-file-names/silly-file-names.run.stdout @@ -0,0 +1,2 @@ +comes from a file with a name that begins with < +comes from a file with a name that ends with > |
