Skip to content

Commit

Permalink
Allow file names to end with '>'
Browse files Browse the repository at this point in the history
The `rustc_span::FileName` 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 `>`.
  • Loading branch information
Enselic committed Oct 3, 2023
1 parent a6dfd89 commit fbfa93d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/include-macros/silly-file-names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// run-pass
// check-run-results

fn main() {
println!(include!("silly-file-names/<leading-lt"));
println!(include!("silly-file-names/trailing-gt>"));
}
2 changes: 2 additions & 0 deletions tests/ui/include-macros/silly-file-names.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
comes from a file with a name that begins with '<'
comes from a file with a name that ends with '>'
1 change: 1 addition & 0 deletions tests/ui/include-macros/silly-file-names/<leading-lt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"comes from a file with a name that begins with '<'"
1 change: 1 addition & 0 deletions tests/ui/include-macros/silly-file-names/trailing-gt>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"comes from a file with a name that ends with '>'"

0 comments on commit fbfa93d

Please sign in to comment.