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

feat: use semver to match required version #6066

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3469dd6
test: add test for `required_version`
ologbonowiwi Feb 8, 2024
2ce0666
chore: install `semver`
ologbonowiwi Feb 8, 2024
01a1ebf
refactor: use `semver` to compare versions
ologbonowiwi Feb 8, 2024
73e75ad
fix: use exact version for comparison when no comparator is specified
ologbonowiwi Feb 8, 2024
75b65d6
refactor: avoid overhead by considering default behavior from `semver`
ologbonowiwi Feb 9, 2024
33eb55c
test: add complex comparisons for required_version
ologbonowiwi Feb 9, 2024
b9934e6
refactor: handle `required_version` parsing manually
ologbonowiwi Feb 9, 2024
21ca2e2
chore: add `#[allow(dead_code)]`
ologbonowiwi Feb 9, 2024
435d1b9
docs: specify atual behavior on required_version docs
ologbonowiwi Feb 9, 2024
cbb6f62
refactor: avoid unwrap and nesting
ologbonowiwi Feb 9, 2024
93a3400
refactor: extract semver version checking
ologbonowiwi Feb 9, 2024
1fc86bc
test: extensively test `chek_semver_version`
ologbonowiwi Feb 9, 2024
89d2c0b
Merge branch 'master' into feat/#6063/use-semver-to-check-required-ve…
ologbonowiwi Feb 9, 2024
005ecb9
docs: add examples on configurations
ologbonowiwi Feb 9, 2024
d599275
Merge branch 'feat/#6063/use-semver-to-check-required-version' of git…
ologbonowiwi Feb 9, 2024
012f71b
docs: explain multiple values
ologbonowiwi Feb 9, 2024
da749b6
docs: mention `semver::Version` spec
ologbonowiwi Feb 9, 2024
18e692d
docs: delete `semver::Version` from spec
ologbonowiwi Feb 9, 2024
dd1d8ce
docs: add examples of different settings
ologbonowiwi Feb 9, 2024
cf53621
Merge branch 'feat/#6063/use-semver-to-check-required-version' of git…
ologbonowiwi Feb 9, 2024
7a92ca5
feat: enforce exact comparison
ologbonowiwi Feb 9, 2024
a7a04c7
docs: add more examples of operators
ologbonowiwi Feb 9, 2024
aceb3fd
docs: improve formatting
ologbonowiwi Feb 9, 2024
7fe12d1
refactor: early return `None` to avoid cognitive load
ologbonowiwi Feb 9, 2024
9142de4
docs: add `*` to examples
ologbonowiwi Feb 9, 2024
899d843
docs: clarify `*` restrictions on range
ologbonowiwi Feb 9, 2024
5b6592d
Update Configurations.md
ologbonowiwi Feb 17, 2024
60b7e2f
style(docs): add `:` to keep standard
ologbonowiwi Feb 17, 2024
ab0ba60
refactor: improve variable naming
ologbonowiwi Oct 8, 2024
f096df6
docs: add comment explaining why we need to check `^` and override th…
ologbonowiwi Oct 8, 2024
c3537ea
Merge branch 'master' into feat/#6063/use-semver-to-check-required-ve…
ologbonowiwi Oct 8, 2024
c29d067
refactor: use `version_req` instead of `required_version` and `label`…
ologbonowiwi Oct 8, 2024
aa2df65
test: add `"./rustfmt.toml"` to `Path`
ologbonowiwi Oct 8, 2024
2b58939
test: add wildcard unmatch
ologbonowiwi Oct 8, 2024
9380e25
docs: improve multiple versions to match session
ologbonowiwi Oct 8, 2024
9c4682a
test: add test for invalid usage of `||`
ologbonowiwi Oct 8, 2024
9567198
Merge branch 'master' of github.com:rust-lang/rustfmt into feat/#6063…
ologbonowiwi Oct 10, 2024
d649463
refactor: add versions on error logs
ologbonowiwi Oct 10, 2024
82dbefd
test: include more tests for mismatching versions
ologbonowiwi Oct 10, 2024
fbaddcc
docs: remove confusing section
ologbonowiwi Oct 10, 2024
0bae336
Merge branch 'feat/#6063/use-semver-to-check-required-version' of git…
ologbonowiwi Oct 10, 2024
23cf487
docs: re-include `style_edition` deleted by merge
ologbonowiwi Oct 10, 2024
f5684a7
docs: improve contradicting requirements explanation
ologbonowiwi Oct 10, 2024
fede8d0
test: include more mismatch tests
ologbonowiwi Oct 10, 2024
4e15dbf
docs: revert unnecessary change
ologbonowiwi Oct 10, 2024
e201040
test: include test matching to wildcard matching any version
ologbonowiwi Feb 18, 2025
afdef69
docs: improve multiple versions to match explanation
ologbonowiwi Feb 18, 2025
1eacf2c
Merge branch 'master' into feat/#6063/use-semver-to-check-required-ve…
ologbonowiwi Feb 18, 2025
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
25 changes: 13 additions & 12 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ unicode-width = "0.1"
unicode-properties = { version = "0.1", default-features = false, features = ["general-category"] }

rustfmt-config_proc_macro = { version = "0.3", path = "config_proc_macro" }
semver = "1.0.21"

# Rustc dependencies are loaded from the sysroot, Cargo doesn't know about them.

Expand Down
55 changes: 54 additions & 1 deletion Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2412,9 +2412,62 @@ Require a specific version of rustfmt. If you want to make sure that the
specific version of rustfmt is used in your CI, use this option.

- **Default value**: `CARGO_PKG_VERSION`
- **Possible values**: any published version (e.g. `"0.3.8"`)
- **Possible values**: `semver` compliant values, such as defined on [semver.org](https://semver.org/).
- **Stable**: No (tracking issue: [#3386](https://github.com/rust-lang/rustfmt/issues/3386))

#### Match on exact version:

```toml
required_version="1.0.0"
```

#### Higher or equal to:

```toml
required_version=">=1.0.0"
```

#### Lower or equal to:

```toml
required_version="<=1.0.0"
```

#### New minor or patch versions:

```toml
required_version="^1.0.0"
```

#### New patch versions:

```toml
required_version="~1.0.0"
```

#### Wildcard:

```toml
required_version="*" # matches any version.
required_version="1.*" # matches any version with the same major version
required_version="1.0.*" # matches any version with the same major and minor version
```

#### Multiple versions to match:

A comma separated list of version requirements.
The match succeeds when the current rustfmt version matches all version requirements.

The one notable exception is that a wildcard matching any version cannot be used in the list.
For example, `*, <1.0.0` will always fail.

Additionally, the version match will always fail if any of the version requirements contradict themselves.
Some examples of contradictory requirements are `1.*, >2.0.0`, `1.0.*, >2.0.0` and `<1.5.0, >1.10.*`.

```toml
required_version=">=1.0.0, <2.0.0"
```

## `short_array_element_width_threshold`

The width threshold for an array element to be considered "short".
Expand Down
Loading
Loading