Expand description
Library for applying diagnostic suggestions to source code.
This is a low-level library. You pass it the JSON output from rustc,
and you can then use it to apply suggestions to in-memory strings.
This library doesn’t execute commands, or read or write from the filesystem.
If you are looking for the cargo fix implementation, the core of it is
located in cargo::ops::fix.
The general outline of how to use this library is:
- Call
rustcand collect the JSON data. - Pass the json data to
get_suggestions_from_json. - Create a
CodeFixwith the source of a file to modify. - Call
CodeFix::applyto apply a change. - Call
CodeFix::finishto get the result and write it back to disk.
Modules§
- Rustc Diagnostic JSON Output.
Structs§
- Represents a code fix. This doesn’t write to disks but is only in memory.
- Represents a replacement of a
snippet. - Represents code that will get replaced.
- Solution to a diagnostic item.
- An error/warning and possible solutions for fixing it
Enums§
- A filter to control which suggestion should be applied.
Functions§
- Applies multiple
suggestionsto the givencode. - Collects code
Suggestions from a single compiler diagnostic line. - Collects code
Suggestions from one or more compiler diagnostic lines.