Parsing rust cratename from toml, instead of filepath #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this does
Panic-Analyzer pulls the crate name of the analyzed crate from the respective Cargo.toml file instead of pulling it out of the directory path
Why is this desired?
Since the crate name is not necessarily included in the filepath to a crate, it is safer to pull the crate name from the crate's Cargo.toml instead of the crate's file path
How is this achieved?
We are using the
toml
crate to parse toml files. To do so, the toml file is read into string (since thetoml
crate does not yet allow parsing of the toml from file directly). This should be ok since toml files are usually not gigabytes in size. The toml is then parsed for the "name" key under the "package" section.