Skip to content

Suggest correct path in include_bytes!#121833

Merged
bors merged 2 commits intorust-lang:masterfrom
kornelski:parent_include
Mar 28, 2024
Merged

Suggest correct path in include_bytes!#121833
bors merged 2 commits intorust-lang:masterfrom
kornelski:parent_include

Conversation

@kornelski
Copy link
Contributor

include_bytes! paths are relative, and I'm often not sure how nested is the .rs file that I'm editing, so I have to guess the number of "../..". This change searches .. and ../.. for the given file and offers corrected path as a suggestion.

I wasn't sure how to get the right span, and how to properly escape it.

error: couldn't read src/file.txt: No such file or directory (os error 2)
 --> src/main.rs:2:13
  |
2 |     let x = include_bytes!("file.txt");
  |             ^^^^^^^^^^^^^^^----------^
  |                            |
  |                            help: it's in a parent directory: `"../../file.txt"`

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.