Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate rustfix to the cargo repo #13005

Merged
merged 396 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
396 commits
Select commit Hold shift + click to select a range
8313660
Split rustfix into two crates
killercup May 3, 2018
cfe1706
Merge pull request #65 from rust-lang-nursery/split-into-two-crates
alexcrichton May 3, 2018
2e87f69
Symlink Readme and license files in cargo-fix
killercup May 3, 2018
4e18b57
Add more metadata to cargo-fix crate
killercup May 3, 2018
193ef4a
Fix metadata in cargo-fix crate
killercup May 3, 2018
07cbb8e
cargo-fix requires brand new rustfix 0.2
killercup May 3, 2018
400ae0e
Rewrite the `cargo fix` command
alexcrichton May 4, 2018
7d83fdf
Add todo comment for lint-filtering HashSet
killercup May 4, 2018
43cc63e
Simplify some .context() calls
killercup May 4, 2018
06ccb07
Add an `env_logger` dependency
alexcrichton May 4, 2018
7d3c9b6
Merge pull request #66 from alexcrichton/rewrite-cargo-fix
alexcrichton May 4, 2018
6cb9bb7
Add AppVeyor configuration
alexcrichton May 4, 2018
5f81993
Merge pull request #68 from alexcrichton/appveyor
alexcrichton May 4, 2018
82fb067
Print some log information about what's being fixed
alexcrichton May 4, 2018
f611bb1
Switch to replace-rs
killercup May 4, 2018
d150af8
Make replace a rustfix module
killercup May 4, 2018
8aef421
Add test for preserving line endings
killercup May 4, 2018
de7714d
Add multiple suggestions test
killercup May 4, 2018
893f29f
Omit now-unused crate
killercup May 4, 2018
4539593
Prevent underflow
killercup May 4, 2018
17b9f0b
Delete obsolete code
killercup May 4, 2018
f9b8801
Run ignored tests on CI
killercup May 4, 2018
18f0217
Merge pull request #67 from rust-lang-nursery/cool-replacements
alexcrichton May 4, 2018
cab6296
Fix tests if `cargo fix` is already installed
alexcrichton May 4, 2018
9f8d2d1
Merge pull request #81 from alexcrichton/no-local-fix
alexcrichton May 4, 2018
b0e0cc0
Switch tests to working-code-by-default
alexcrichton May 5, 2018
eb73d31
Don't fix broken code
alexcrichton May 5, 2018
df64322
Auto undo changes tha accidentally break code
alexcrichton May 5, 2018
3c691a3
Pass --cap-lints=warn to the first compile
alexcrichton May 5, 2018
1f2e5b9
Unconditionally pass `--cap-lints=warn`
alexcrichton May 5, 2018
702c8f3
Merge pull request #82 from alexcrichton/do-not-work-with-broken-code
alexcrichton May 5, 2018
99b0f8b
Fix compile on master
alexcrichton May 5, 2018
ab3334e
Update READMEs
killercup May 5, 2018
04eac39
Merge pull request #86 from killercup/update-readme
alexcrichton May 5, 2018
a86ce67
Start giving `cargo fix` a dedicated CLI
alexcrichton May 5, 2018
ee2ca1e
Merge pull request #87 from alexcrichton/clap
killercup May 5, 2018
5785698
Add some more logging
killercup May 5, 2018
0923fbf
Add cargo-like output
killercup May 5, 2018
075fcba
Update tests to include "Fixing …" lines
killercup May 5, 2018
e2ae392
Introduce a diagnostics server
killercup May 5, 2018
17c4a78
Merge pull request #85 from killercup/cargo-fix-output
alexcrichton May 5, 2018
5d20194
Run `cargo fmt`
alexcrichton May 5, 2018
a1ea6d7
Fix a typo when reporting what's fixed
alexcrichton May 5, 2018
6fa957e
Switch "fixing" messages to Cyan
alexcrichton May 5, 2018
b2ddfeb
Don't print "Fixing" if fixes are reverted
alexcrichton May 5, 2018
ccbe3db
Merge pull request #91 from alexcrichton/do-not-lie-if-not-fixing
killercup May 5, 2018
51fa20b
Merge alexcrichton-typo into master
killercup May 5, 2018
7f905f0
Merge alexcrichton-cyan into master
killercup May 5, 2018
5de95a9
Fix compile on stable
alexcrichton May 6, 2018
59b3617
Warn users when fixes break code
alexcrichton May 6, 2018
8f44658
Adjust wording when asking for bug report
killercup May 6, 2018
17bcea9
Merge pull request #93 from alexcrichton/warn-when-break
killercup May 6, 2018
e160ba5
Add more debug logging to rustfix
killercup May 6, 2018
040686f
Custom warning when rustfix replacing fails
killercup May 6, 2018
a646d16
Merge pull request #94 from killercup/warn-when-rustfix-cant-replace-…
alexcrichton May 6, 2018
3f3905e
Refactor rustfix tests a bit
killercup May 6, 2018
e3d5d6d
Rustfix edition testing setup
killercup May 6, 2018
8ed4006
Mark edition lints as ignored for now
killercup May 6, 2018
b5e4e61
Merge pull request #96 from killercup/refactor-rustfix-tests
alexcrichton May 7, 2018
cea8fd1
WIP: Add `--prepare-for` flag
killercup May 9, 2018
bb18250
Fix typo
killercup May 9, 2018
fe2526e
WIP: Trigger 2018 breakage lints
killercup May 9, 2018
43d5f18
No need for the allow(unused) anymore
killercup May 9, 2018
cd641cd
Use rust_2018_preview feature
killercup May 10, 2018
a956e9e
Let's not disable lints
killercup May 10, 2018
5649ad4
Merge pull request #98 from rust-lang-nursery/prepare-for-flag
alexcrichton May 10, 2018
f1f2bbd
Add tests for some edition lints
alexcrichton May 11, 2018
df678eb
Merge pull request #99 from alexcrichton/some-tests
killercup May 11, 2018
c85afe0
Add a simple tool that applies fixes from JSON
killercup May 13, 2018
7b0e921
Merge pull request #101 from killercup/json-tool
alexcrichton May 13, 2018
d9729ee
Fix CI for most recent nightly
alexcrichton May 13, 2018
eebc699
Update lint group names
killercup May 13, 2018
11ae16a
Merge commit 'eebc699a88295bff575e678e3032288c24a23968'
alexcrichton May 13, 2018
ebca9b6
Prepare rustfix 0.3
killercup May 13, 2018
7ed3595
fix typo
gnzlbg May 15, 2018
0fcf13b
Merge pull request #105 from gnzlbg/patch-1
killercup May 15, 2018
d853360
Reformat everything with rustfmt from stable 1.26
yaahc May 16, 2018
84c0df9
Merge pull request #106 from jrlusby/cargofmt
killercup May 16, 2018
d6f7fe8
Comment out broken lint test for now
killercup May 16, 2018
347bcac
Add test for insert only suggestion
yaahc May 16, 2018
e5dff5a
Add unit test for multiple pass edge case
yaahc May 16, 2018
0ef9786
Add inserted state
yaahc May 16, 2018
9ec8a55
Fix integration to pass compilation
yaahc May 17, 2018
52a9eb8
Readd check for invalid ranges
yaahc May 17, 2018
a0546dd
Check if in a VCS
BrainMaestro May 15, 2018
38b2ba7
Check if VCS working tree is dirty
BrainMaestro May 15, 2018
81452cb
Add tests for new VCS functionality
BrainMaestro May 16, 2018
f8025f5
Remove rustup-init.exe to fix appveyor tests
BrainMaestro May 17, 2018
6810c7f
Add special case for empty string
yaahc May 18, 2018
85aa218
Merge pull request #107 from jrlusby/insertonly
killercup May 18, 2018
114bdc7
Fix warnings in test
killercup May 18, 2018
5583b1a
Uppercase some abbreviations
killercup May 18, 2018
cbfc26c
Refactor diagnostics code
killercup May 18, 2018
7c363fc
Reformat error output
killercup May 18, 2018
13a12de
Refactor VCS/dirty detection to show warning
killercup May 18, 2018
2f7a051
Default tests to ignore dirty working dir
killercup May 18, 2018
f09ed17
Skip suggestions with multiple options
yaahc May 18, 2018
e6f1ace
Add new edge_cases test
yaahc May 18, 2018
9b8b734
Merge pull request #108 from jrlusby/skip_multiples
killercup May 18, 2018
b4efcd3
Merge pull request #109 from killercup/BrainMaestro-add-vcs-functiona…
alexcrichton May 18, 2018
1d92033
Dont pass RUST_LOG to rustc subprocess in tests
yaahc May 18, 2018
cd37ed0
Merge pull request #110 from jrlusby/isolate-env
killercup May 18, 2018
a8d0e3f
Overwrite RUST_LOG env var in cargo-fix tests
killercup May 18, 2018
3c082c7
Merge pull request #111 from killercup/strip-log-env-from-cargo-fix-t…
alexcrichton May 18, 2018
f6e423f
Bump rustfix to version 0.3.1
killercup May 22, 2018
7d5bb22
Add filtering by machine applicability
killercup May 23, 2018
2eaaa75
Address review feedback
killercup May 23, 2018
5e71ec2
Add a `.fix_everything()` test helper
killercup May 23, 2018
0411465
Merge pull request #97 from killercup/feature/filter-by-machine-appli…
killercup May 23, 2018
28dbb43
Bum rustfix and cargo-fix to 0.4.0
killercup May 23, 2018
e3608da
cli: fix injection of --prepare-for flags
matthiaskrgr May 24, 2018
3b8982f
"rustfix'" → "rustfix's"
zackmdavis Jun 3, 2018
a3a9d41
reset terminal color/bold after emitting error
zackmdavis Jun 3, 2018
d3e7260
Merge pull request #116 from zackmdavis/apostrophe_s
killercup Jun 3, 2018
ab63ed8
Merge pull request #117 from zackmdavis/reset_stream
killercup Jun 3, 2018
379fabd
Add test for setting RUSTFLAGS
killercup Jun 7, 2018
88527e6
Formatting and a typo fix
killercup Jun 7, 2018
b5e14a3
Merge pull request #112 from matthiaskrgr/fix_RUSTFLAGS_prepare_for
killercup Jun 7, 2018
47e1e1b
Bump cargo-fix version to 0.4.1
killercup Jun 8, 2018
c750e4d
Fix typo in Readme.md
lexxvir Jun 22, 2018
51b666f
Ignore duplicate replacements
alexcrichton Jul 16, 2018
116c7e9
Merge pull request #131 from alexcrichton/duplicates
alexcrichton Jul 16, 2018
abcad4c
Delete `cargo fix`
alexcrichton Jul 17, 2018
aee3a2b
Merge pull request #132 from alexcrichton/delete
alexcrichton Jul 17, 2018
2764630
Add link to edition guide to README
Jul 20, 2018
247d271
Merge pull request #135 from withoutboats/add-link-to-readme
killercup Jul 20, 2018
d0a60f0
Bump to 0.4.1
alexcrichton Jul 26, 2018
ac3022e
Update manifest metadata
alexcrichton Jul 26, 2018
c9d3e09
Handle invalid snippets instead of panicking
alexcrichton Jul 30, 2018
cb3229b
Expose an interface to apply fixes on-by-one
alexcrichton Jul 31, 2018
8921742
Merge pull request #140 from alexcrichton/rustfix-incremental
alexcrichton Jul 31, 2018
66ef037
Merge pull request #139 from alexcrichton/fix-bug
alexcrichton Jul 31, 2018
28b9ec5
Bump to 0.4.2
alexcrichton Jul 31, 2018
da6b20d
update links
light4 Aug 14, 2018
ef816e0
Merge pull request #142 from light4/master
alexcrichton Aug 14, 2018
c666342
use RUSTC environment var in `parse_and_replace::compile` if present
zackmdavis Aug 20, 2018
0476da8
fix link
PSeitz Oct 7, 2018
f99e56d
Merge pull request #148 from PSeitz/patch-1
killercup Oct 7, 2018
a0eb55d
allow multiple solutions
pietroalbini Dec 8, 2018
4a577a6
remove test about multi-option lints
pietroalbini Dec 8, 2018
5f1c320
tests: use the cached json errors instead of calling rustc
pietroalbini Dec 9, 2018
4595c3b
tests: add test for multiple suggestions
pietroalbini Dec 9, 2018
a2538c5
Merge pull request #155 from pietroalbini/multiple-solutions
killercup Dec 9, 2018
518ed3f
Merge pull request #144 from zackmdavis/and_the_case_of_the_environme…
pietroalbini Dec 9, 2018
298d740
fix failure deprecation warning
pietroalbini Dec 9, 2018
557ebdf
release rustfix 0.4.3
pietroalbini Dec 9, 2018
42fd66d
Revert "Allow multiple solutions in a suggestion"
pietroalbini Dec 9, 2018
1ca1cbd
Merge pull request #156 from rust-lang-nursery/revert-155-multiple-so…
killercup Dec 9, 2018
d904271
Make Diagnostic::rendered public.
ehuss Dec 12, 2018
c16724c
Merge pull request #159 from ehuss/pub-rendered
alexcrichton Dec 13, 2018
7e88e76
Bump to 0.4.4
alexcrichton Dec 13, 2018
e03175e
Implement common traits for Diagnostic and associated types
jsgf Jan 11, 2019
dff0dba
Derive Eq for Suggestion and related types
jsgf Jan 11, 2019
2f5f030
Merge pull request #160 from jsgf/master
Manishearth Jan 11, 2019
df1bba0
Fix out of bounds access
phansch Mar 24, 2019
cf0be8b
Replace conditional with min()
phansch Mar 25, 2019
fa8a2f0
Merge pull request #165 from phansch/fix_out_of_bounds
killercup Mar 26, 2019
5d4c8c8
Change example to automatically determine filename
philipc Apr 3, 2019
47e9aab
example/fix-json: Apply suggestions from code review
philipc Apr 3, 2019
f126ec8
example/fix-json: skip suggestions that don't apply
philipc Apr 3, 2019
7010307
Merge pull request #166 from philipc/fix-json
killercup Apr 3, 2019
0cc670d
Fix string indexing
phansch Apr 4, 2019
e6b66f0
Migrate to Rust 2018
phansch Apr 4, 2019
2239a23
Merge pull request #168 from phansch/2018
killercup Apr 5, 2019
9ddee0e
use `derive` feature over `serde_derive` crate
euclio May 13, 2019
e292079
Merge pull request #169 from euclio/serde-derive
Manishearth May 13, 2019
b9c2ea2
Update tests for `bare_trait_objects` warning.
ehuss Aug 6, 2019
836108f
Merge pull request #167 from phansch/fix_string_indexing
alexcrichton Aug 7, 2019
9078d49
Merge pull request #172 from ehuss/update-error-new-rustc
alexcrichton Aug 7, 2019
e6bb424
Bump version to 0.4.6 and add change log
Jul 16, 2019
1736be4
Merge pull request #171 from killercup/release/0.4.6
alexcrichton Aug 7, 2019
8a5949d
Update Travis CI URL
atouchet Aug 9, 2019
c26abc0
Merge pull request #173 from atouchet/travis
Aug 9, 2019
4cd5108
Switch from Travis/AppVeyor to Github Actions
alexcrichton Oct 29, 2019
ba81441
Run rustfmt
alexcrichton Oct 29, 2019
6d4f793
Merge pull request #179 from alexcrichton/gh-actions
pietroalbini Oct 29, 2019
6535333
Remove outdated build badges
alexcrichton Oct 29, 2019
e7241b3
Remove bors configuration
alexcrichton Oct 29, 2019
5553ac4
Migrate from `failure` to `anyhow`
alexcrichton Jan 7, 2020
c3f8cd3
Run rustfmt
alexcrichton Jan 7, 2020
c43a5ec
More updates to anyhow
alexcrichton Jan 7, 2020
c56cb42
Run rustfmt
alexcrichton Jan 7, 2020
3a1dc7d
Merge pull request #184 from alexcrichton/failure
alexcrichton Jan 7, 2020
715eff0
Bump to 0.5.0
alexcrichton Jan 7, 2020
9986e9a
Update CI installation of Rust on macos
alexcrichton Jan 28, 2020
f3f1035
Remove duplicate in edge-cases tests.
ehuss Apr 1, 2020
892a95c
Don't panic on span for empty file.
ehuss Apr 1, 2020
d244f66
Provide helpful error message if not using nightly.
ehuss Apr 2, 2020
df8401b
Prevent panic when span points past end of line.
ehuss Apr 2, 2020
e3b06b0
Merge pull request #185 from ehuss/fix-edge-cases
killercup Apr 2, 2020
cb85f85
Bump version to 0.5.1
killercup Apr 2, 2020
fd1f32d
Removed unnecessary `use` statement
deeprobin Oct 5, 2020
1ddf2b2
Replaced is_inserted implementation of State with matches! macro to i…
deeprobin Oct 5, 2020
6974044
Added IDE-specific ignores to .gitignore
deeprobin Oct 5, 2020
f69fe43
Merge pull request #188 from deeprobin/improvements
Manishearth Oct 5, 2020
50f1708
Added newline at EOF
deeprobin Oct 6, 2020
0afd94a
Merge pull request #189 from deeprobin/fix-gitignore
Manishearth Oct 6, 2020
304bf52
Fix typo in Readme
LeSeulArtichaut Dec 13, 2020
acb86f9
Merge pull request #191 from LeSeulArtichaut/patch-1
ehuss Dec 14, 2020
dfbce93
Switch to similar from difference
mitsuhiko Jan 30, 2021
ae9b645
Merge pull request #193 from mitsuhiko/feature/difference-to-similar
killercup Feb 1, 2021
d4f016a
allow multiple solutions
pietroalbini Dec 8, 2018
37e974e
remove test about multi-option lints
pietroalbini Dec 8, 2018
a2b6e67
tests: add test for multiple suggestions
pietroalbini Dec 9, 2018
fa2cd29
Merge pull request #195 from m-ou-se/revert-revert-multiple-suggestions
Manishearth Jun 1, 2021
e6dabf1
Bump version to 0.6.0
Jun 9, 2021
635eef7
Fix panic computing indentation.
ehuss Aug 30, 2021
7388839
Merge pull request #199 from ehuss/indent-whitespace
Manishearth Aug 31, 2021
370a778
Update Readme.md
yvan-sraka Oct 22, 2021
c3343a3
Merge pull request #202 from yvan-sraka/patch-1
Manishearth Oct 23, 2021
6801cf1
Fix few clippy lints
yvan-sraka Oct 30, 2021
c70fc02
Merge pull request #203 from yvan-sraka/fix-rustfix
Manishearth Oct 30, 2021
cf6f7ed
ci: use new cargo fmt option
calebcartwright Jan 13, 2022
0886aef
Merge pull request #204 from calebcartwright/latest-cargo-fmt
Manishearth Jan 13, 2022
a653fcd
Fix for anynow causing semver-breakage
kornelski Jan 30, 2022
9878d16
Merge pull request #205 from kornelski/patch-1
ehuss Jan 30, 2022
ab6029d
replace the tempdir crate with the tempfile one, as tempfile have sup…
alexanderkjall Feb 13, 2022
4e61922
Make Diagnostic::is_primary public
P1n3appl3 Feb 16, 2022
b70d575
Merge pull request #207 from P1n3appl3/master
Manishearth Feb 16, 2022
cdcaeb0
Merge pull request #206 from alexanderkjall/replace-tempdir-with-temp…
ehuss Feb 18, 2022
3cdeffd
Bump version
smoelius May 23, 2022
d67672b
Merge pull request #212 from smoelius/master
Manishearth May 23, 2022
c249c97
README update aiming to clarify things for less experienced rustaceans
3tilley Oct 15, 2023
b416b98
Update Readme.md
Manishearth Oct 16, 2023
7806962
Update Readme.md
Manishearth Oct 16, 2023
10fd5eb
Merge pull request #222 from 3tilley/master
Manishearth Oct 16, 2023
ab33223
Apply PR suggestion from #222
3tilley Oct 17, 2023
f01a5ba
Merge pull request #223 from 3tilley/master
Manishearth Oct 17, 2023
d34d36d
fix insert at beginning
dnbln Nov 8, 2023
da51cd2
fix fmt
dnbln Nov 8, 2023
ae377f7
Merge pull request #224 from dnbln/master
ehuss Nov 19, 2023
73e5506
Merge remote-tracking branch 'rustfix/master' into rustfix
ehuss Nov 19, 2023
3ca00ad
Integrate rustfix's manifest into the workspace.
ehuss Nov 19, 2023
9cb59bc
Idiom lints are now configured in the manifest.
ehuss Nov 19, 2023
d0d9bd5
Switch rustfix to using tracing instead of log.
ehuss Nov 19, 2023
f25cc63
Update rustfix to use a newer proptest.
ehuss Nov 19, 2023
3c0126a
rustfix: Drop test dependency on duct
ehuss Nov 19, 2023
63830af
Remove some unused rustfix files.
ehuss Nov 19, 2023
a4fd77c
Switch rustfix license files to be symlinks
ehuss Nov 19, 2023
6e798b3
Update rustfix readme to be a little more current.
ehuss Nov 19, 2023
b8ba6cd
Bump the rustfix version.
ehuss Nov 19, 2023
7e04d19
Add rustfix to publish.
ehuss Nov 19, 2023
d6e49ca
Fix clippy warnings.
ehuss Nov 19, 2023
b5308f6
Fix tests to run on stable.
ehuss Nov 19, 2023
f99a494
Remove copyright headers in tests.
ehuss Nov 19, 2023
402d072
Ignore rustfix for semver-checks since it doesn't exist on the beta b…
ehuss Nov 21, 2023
70f56e9
Add a general introduction to the rustfix library docs.
ehuss Nov 21, 2023
5cb98b9
Add rustfix lib to autolabel triggers.
ehuss Nov 21, 2023
5c2b9d7
Update contrib docs on rustfix issue tracking.
ehuss Nov 21, 2023
47c7ff0
Deduplicate the similar dependency.
ehuss Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pulldown-cmark = { version = "0.9.3", default-features = false }
rand = "0.8.5"
regex = "1.9.3"
rusqlite = { version = "0.29.0", features = ["bundled"] }
rustfix = "0.6.1"
rustfix = { version = "0.6.2", path = "crates/rustfix" }
same-file = "1.0.6"
security-framework = "2.9.2"
semver = { version = "1.0.20", features = ["serde"] }
Expand Down
33 changes: 33 additions & 0 deletions crates/rustfix/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "rustfix"
version = "0.6.2"
authors = [
"Pascal Hertleif <killercup@gmail.com>",
"Oliver Schneider <oli-obk@users.noreply.github.com>",
]
rust-version = "1.70.0" # MSRV:3
edition.workspace = true
license.workspace = true
homepage = "https://github.com/rust-lang/cargo"
repository = "https://github.com/rust-lang/cargo"
description = "Automatically apply the suggestions made by rustc"
documentation = "https://docs.rs/rustfix"
exclude = [
"examples/*",
"tests/*",
]

[dependencies]
anyhow.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
tracing.workspace = true

[dev-dependencies]
proptest.workspace = true
similar = "2.2.1"
tempfile.workspace = true
tracing-subscriber.workspace = true

[lints]
workspace = true
79 changes: 79 additions & 0 deletions crates/rustfix/Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.4.6] - 2019-07-16

### Changed

Internal changes:

- Change example to automatically determine filename
- Migrate to Rust 2018
- use `derive` feature over `serde_derive` crate

## [0.4.5] - 2019-03-26

### Added

- Implement common traits for Diagnostic and related types

### Fixed

- Fix out of bounds access in parse_snippet

## [0.4.4] - 2018-12-13

### Added

- Make Diagnostic::rendered public.

### Changed

- Revert faulty "Allow multiple solutions in a suggestion"

## [0.4.3] - 2018-12-09 - *yanked!*

### Added

- Allow multiple solutions in a suggestion

### Changed

- use `RUSTC` environment var if present

## [0.4.2] - 2018-07-31

### Added

- Expose an interface to apply fixes on-by-one

### Changed

- Handle invalid snippets instead of panicking

## [0.4.1] - 2018-07-26

### Changed

- Ignore duplicate replacements

## [0.4.0] - 2018-05-23

### Changed

- Filter by machine applicability by default

[Unreleased]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.6...HEAD
[0.4.6]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.5...rustfix-0.4.6
[0.4.5]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.4...rustfix-0.4.5
[0.4.4]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.3...rustfix-0.4.4
[0.4.3]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.2...rustfix-0.4.3
[0.4.2]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.1...rustfix-0.4.2
[0.4.1]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.0...rustfix-0.4.1
[0.4.0]: https://github.com/rust-lang-nursery/rustfix/compare/rustfix-0.4.0
1 change: 1 addition & 0 deletions crates/rustfix/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/rustfix/LICENSE-MIT
29 changes: 29 additions & 0 deletions crates/rustfix/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# rustfix

[![Latest Version](https://img.shields.io/crates/v/rustfix.svg)](https://crates.io/crates/rustfix)
[![Rust Documentation](https://docs.rs/rustfix/badge.svg)](https://docs.rs/rustfix)

Rustfix is a library defining useful structures that represent fix suggestions from rustc.

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`].

[`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
[`cargo::ops::fix`]: https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/fix.rs

## License

Licensed under either of

- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.
44 changes: 44 additions & 0 deletions crates/rustfix/examples/fix-json.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#![allow(clippy::disallowed_methods, clippy::print_stdout, clippy::print_stderr)]

use anyhow::Error;
use std::io::{stdin, BufReader, Read};
use std::{collections::HashMap, collections::HashSet, env, fs};

fn main() -> Result<(), Error> {
let suggestions_file = env::args().nth(1).expect("USAGE: fix-json <file or -->");
let suggestions = if suggestions_file == "--" {
let mut buffer = String::new();
BufReader::new(stdin()).read_to_string(&mut buffer)?;
buffer
} else {
fs::read_to_string(&suggestions_file)?
};
let suggestions = rustfix::get_suggestions_from_json(
&suggestions,
&HashSet::new(),
rustfix::Filter::Everything,
)?;

let mut files = HashMap::new();
for suggestion in suggestions {
let file = suggestion.solutions[0].replacements[0]
.snippet
.file_name
.clone();
files.entry(file).or_insert_with(Vec::new).push(suggestion);
}

for (source_file, suggestions) in &files {
let source = fs::read_to_string(source_file)?;
let mut fix = rustfix::CodeFix::new(&source);
for suggestion in suggestions.iter().rev() {
if let Err(e) = fix.apply(suggestion) {
eprintln!("Failed to apply suggestion to {}: {}", source_file, e);
}
}
let fixes = fix.finish()?;
fs::write(source_file, fixes)?;
}

Ok(())
}
8 changes: 8 additions & 0 deletions crates/rustfix/proptest-regressions/replace.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
xs 358148376 3634975642 2528447681 3675516813 # shrinks to ref s = ""
xs 3127423015 3362740891 2605681441 2390162043 # shrinks to ref data = "", ref replacements = [(0..0, [])]
89 changes: 89 additions & 0 deletions crates/rustfix/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//! Rustc Diagnostic JSON Output
//!
//! The following data types are copied from [rust-lang/rust](https://github.com/rust-lang/rust/blob/de78655bca47cac8e783dbb563e7e5c25c1fae40/src/libsyntax/json.rs)

use serde::Deserialize;

#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
pub struct Diagnostic {
/// The primary error message.
pub message: String,
pub code: Option<DiagnosticCode>,
/// "error: internal compiler error", "error", "warning", "note", "help".
level: String,
pub spans: Vec<DiagnosticSpan>,
/// Associated diagnostic messages.
pub children: Vec<Diagnostic>,
/// The message as rustc would render it. Currently this is only
/// `Some` for "suggestions", but eventually it will include all
/// snippets.
pub rendered: Option<String>,
}

#[derive(Clone, Deserialize, Debug, Hash, Eq, PartialEq)]
pub struct DiagnosticSpan {
pub file_name: String,
pub byte_start: u32,
pub byte_end: u32,
/// 1-based.
pub line_start: usize,
pub line_end: usize,
/// 1-based, character offset.
pub column_start: usize,
pub column_end: usize,
/// Is this a "primary" span -- meaning the point, or one of the points,
/// where the error occurred?
pub is_primary: bool,
/// Source text from the start of line_start to the end of line_end.
pub text: Vec<DiagnosticSpanLine>,
/// Label that should be placed at this location (if any)
label: Option<String>,
/// If we are suggesting a replacement, this will contain text
/// that should be sliced in atop this span. You may prefer to
/// load the fully rendered version from the parent `Diagnostic`,
/// however.
pub suggested_replacement: Option<String>,
pub suggestion_applicability: Option<Applicability>,
/// Macro invocations that created the code at this span, if any.
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
}

#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)]
pub enum Applicability {
MachineApplicable,
HasPlaceholders,
MaybeIncorrect,
Unspecified,
}

#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
pub struct DiagnosticSpanLine {
pub text: String,

/// 1-based, character offset in self.text.
pub highlight_start: usize,

pub highlight_end: usize,
}

#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
struct DiagnosticSpanMacroExpansion {
/// span where macro was applied to generate this code; note that
/// this may itself derive from a macro (if
/// `span.expansion.is_some()`)
span: DiagnosticSpan,

/// name of macro that was applied (e.g., "foo!" or "#[derive(Eq)]")
macro_decl_name: String,

/// span where macro was defined (if known)
def_site_span: Option<DiagnosticSpan>,
}

#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Hash)]
pub struct DiagnosticCode {
/// The code itself.
pub code: String,
/// An explanation for the code.
explanation: Option<String>,
}
Loading