Skip to content

Commit a73e1ef

Browse files
committed
Use RUSTFLAGS to deny warnings in check.rs.
1 parent 7e25898 commit a73e1ef

File tree

5 files changed

+55
-59
lines changed

5 files changed

+55
-59
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ unicase = "2.8.1"
4848
[dev-dependencies]
4949
pretty_assertions = "1.4.1"
5050

51-
[features]
52-
fatal-warnings = []
53-
5451
[lints.clippy]
5552
all = { level = "warn", priority = -2 }
5653
correctness = { level = "deny", priority = -1 }

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ You can install cargo rdme with cargo by running `cargo install cargo-rdme`.
1919

2020
## Usage
2121

22-
Cargo rdme will insert your crate’s documentation in your README file. To control where the
23-
documentation will be inserted you need to insert a marker: `<!-- cargo-rdme -->`. For example,
22+
Cargo rdme will insert your crate’s documentation in your README file. To control where the
23+
documentation will be inserted you need to insert a marker: `<!-- cargo-rdme -->`. For example,
2424
you can start your README with some glorious badges and follow up with the rustdoc
2525
documentation:
2626

@@ -47,8 +47,8 @@ README file.
4747

4848
## Automatic transformations
4949

50-
The documentation of your crate doesn’t always map directly to a good README. For example,
51-
rust code blocks can have hidden lines. Those should not be shown in the README file.
50+
The documentation of your crate doesn’t always map directly to a good README. For example,
51+
rust code blocks can have hidden lines. Those should not be shown in the README file.
5252

5353
This section covers the transformation cargo rdme automatically apply to generate a better
5454
README.
@@ -59,9 +59,9 @@ Rust code block are transformed in two ways by cargo rdme:
5959

6060
1. Rust code blocks with lines starting with `#` will be omitted, just like in `rustdoc`.
6161
2. Rust code blocks get annotated with the `rust` markdown tag so it gets proper syntax
62-
highlighting. We also remove tags that only concern `rustdoc` such as `should_panic`.
62+
highlighting. We also remove tags that only concern `rustdoc` such as `should_panic`.
6363

64-
In the table below you can see an example of these modification. The code block now is
64+
In the table below you can see an example of these modification. The code block now is
6565
tagged with `rust` and hidden lines were removed:
6666

6767
<table border="1">
@@ -117,7 +117,7 @@ links to [docs.rs](https://docs.rs) for these intralinks.
117117
Currently we only support links of the form `[⋯](crate::⋯)`, so be sure to use that format.
118118
Links to the standard library are also supported, and they must be of the form
119119
`[⋯](::<crate>::⋯)`, where `<crate>` is a crate that is part of the standard library, such as
120-
`std`, `core`, or `alloc`. Reference-style links are also supported.
120+
`std`, `core`, or `alloc`. Reference-style links are also supported.
121121

122122
Take a look at the example below:
123123

@@ -149,69 +149,69 @@ To check if a number is prime use
149149
</tr>
150150
</table>
151151

152-
Note that there is some limitations in intralink support. This is a complex feature: cargo rdme
153-
needs to do some work to be able to create the link to docs.rs. This is because the link
152+
Note that there is some limitations in intralink support. This is a complex feature: cargo rdme
153+
needs to do some work to be able to create the link to docs.rs. This is because the link
154154
includes the kind of item the intralink points to, in the case of `is_prime` we need to discover
155-
that is a function to generate a link that ends in `fn.is_prime.html`. Therefore, intralink
155+
that is a function to generate a link that ends in `fn.is_prime.html`. Therefore, intralink
156156
support should be considered "best effort" (for instance, don’t expect items generated by macros
157-
to be resolved). If cargo rdme is unable to generate the link it will still generate the README
157+
to be resolved). If cargo rdme is unable to generate the link it will still generate the README
158158
file, but a warning will be emitted.
159159

160160
### Heading levels
161161

162162
The heading levels in the crate’s documentation will, by default, be nested under the level
163-
of the section of the README where it is inserted into. This behavior can be changed with
163+
of the section of the README where it is inserted into. This behavior can be changed with
164164
the `--heading-base-level` command line flag, or in the configuration file (see example
165165
below).
166166

167167
## Configuration file
168168

169169
If the default behavior of `cargo rdme` is not appropriate for your project you can crate a
170-
configuration file `.cargo-rdme.toml` in the root of your project. This is how that
170+
configuration file `.cargo-rdme.toml` in the root of your project. This is how that
171171
configuration file can look like:
172172

173173
```toml
174-
# Override the README file path. When this is not set cargo rdme will use the file path defined
174+
# Override the README file path. When this is not set cargo rdme will use the file path defined
175175
# in the project’s `Cargo.toml`.
176176
readme-path = "MY-README.md"
177177

178-
# What line terminator to use when generating the README file. This can be "lf" or "crlf".
178+
# What line terminator to use when generating the README file. This can be "lf" or "crlf".
179179
line-terminator = "lf"
180180

181181
# If you are using a workspace to hold multiple projects, use this to select the project from
182-
# which to extract the documentation from. It can be useful to also set `readme-path` to create
182+
# which to extract the documentation from. It can be useful to also set `readme-path` to create
183183
# the README file in the root of the project.
184184
workspace-project = "subproject"
185185

186186
# Defines the base heading level to use when inserting the crate’s documentation in the
187-
# README. If this is not set the crate’s documentation will be inserted with its sections
187+
# README. If this is not set the crate’s documentation will be inserted with its sections
188188
# belonging to the README section where the insertion happens.
189189
heading-base-level = 0
190190

191-
# The default entrypoint will be `src/lib.rs`. You can change that in the `entrypoint` table.
191+
# The default entrypoint will be `src/lib.rs`. You can change that in the `entrypoint` table.
192192
[entrypoint]
193193
# The entrypoint type can be "lib" or "bin".
194194
type = "bin"
195-
# When you set type to "bin" the entrypoint default to `src/main.rs`. If you have binary targets
195+
# When you set type to "bin" the entrypoint default to `src/main.rs`. If you have binary targets
196196
# specified in your cargo manifest you can select them by name with `bin-name`.
197197
bin-name = "my-bin-name"
198198

199199
[intralinks]
200-
# Defines the base url to use in intralinks urls. The default value is `https://docs.rs`.
200+
# Defines the base url to use in intralinks urls. The default value is `https://docs.rs`.
201201
docs-rs-base-url = "https://mydocs.rs"
202-
# Defines the version to use in intralinks urls. The default value is `latest`.
202+
# Defines the version to use in intralinks urls. The default value is `latest`.
203203
docs-rs-version = "1.0.0"
204204
# If this is set the intralinks will be stripping in the README file.
205205
strip-links = false
206206
```
207207

208-
These setting can be overridden with command line flags. Run `cargo rdme --help` for more
208+
These setting can be overridden with command line flags. Run `cargo rdme --help` for more
209209
information.
210210

211211
## Integration with CI
212212

213213
To verify that your README is up to date with your crate’s documentation you can run
214-
`cargo rdme --check`. The exit code will be `0` if the README is up to date, `3` if it’s
214+
`cargo rdme --check`. The exit code will be `0` if the README is up to date, `3` if it’s
215215
not, or `4` if there were warnings.
216216

217217
If you use GitHub Actions you can add this step to verify if the README is up to date:

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]
2-
31
use crate::markdown::{Markdown, MarkdownError};
42
use cargo_metadata::{PackageName, TargetKind};
53
use std::collections::HashMap;

src/main.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]
2-
// Note: If you change this remember to update `README.md`. To do so run `cargo run`.
1+
// Note: If you change this remember to update `README.md`. To do so run `cargo run`.
32
//! Cargo command to create your README from your crate’s documentation.
43
//!
54
//! # Installation
@@ -8,8 +7,8 @@
87
//!
98
//! # Usage
109
//!
11-
//! Cargo rdme will insert your crate’s documentation in your README file. To control where the
12-
//! documentation will be inserted you need to insert a marker: `<!-- cargo-rdme -->`. For example,
10+
//! Cargo rdme will insert your crate’s documentation in your README file. To control where the
11+
//! documentation will be inserted you need to insert a marker: `<!-- cargo-rdme -->`. For example,
1312
//! you can start your README with some glorious badges and follow up with the rustdoc
1413
//! documentation:
1514
//!
@@ -36,8 +35,8 @@
3635
//!
3736
//! # Automatic transformations
3837
//!
39-
//! The documentation of your crate doesn’t always map directly to a good README. For example,
40-
//! rust code blocks can have hidden lines. Those should not be shown in the README file.
38+
//! The documentation of your crate doesn’t always map directly to a good README. For example,
39+
//! rust code blocks can have hidden lines. Those should not be shown in the README file.
4140
//!
4241
//! This section covers the transformation cargo rdme automatically apply to generate a better
4342
//! README.
@@ -48,9 +47,9 @@
4847
//!
4948
//! 1. Rust code blocks with lines starting with `#` will be omitted, just like in `rustdoc`.
5049
//! 2. Rust code blocks get annotated with the `rust` markdown tag so it gets proper syntax
51-
//! highlighting. We also remove tags that only concern `rustdoc` such as `should_panic`.
50+
//! highlighting. We also remove tags that only concern `rustdoc` such as `should_panic`.
5251
//!
53-
//! In the table below you can see an example of these modification. The code block now is
52+
//! In the table below you can see an example of these modification. The code block now is
5453
//! tagged with `rust` and hidden lines were removed:
5554
//!
5655
//! <table border="1">
@@ -106,7 +105,7 @@
106105
//! Currently we only support links of the form `[⋯](crate::⋯)`, so be sure to use that format.
107106
//! Links to the standard library are also supported, and they must be of the form
108107
//! `[⋯](::<crate>::⋯)`, where `<crate>` is a crate that is part of the standard library, such as
109-
//! `std`, `core`, or `alloc`. Reference-style links are also supported.
108+
//! `std`, `core`, or `alloc`. Reference-style links are also supported.
110109
//!
111110
//! Take a look at the example below:
112111
//!
@@ -138,69 +137,69 @@
138137
//! </tr>
139138
//! </table>
140139
//!
141-
//! Note that there is some limitations in intralink support. This is a complex feature: cargo rdme
142-
//! needs to do some work to be able to create the link to docs.rs. This is because the link
140+
//! Note that there is some limitations in intralink support. This is a complex feature: cargo rdme
141+
//! needs to do some work to be able to create the link to docs.rs. This is because the link
143142
//! includes the kind of item the intralink points to, in the case of `is_prime` we need to discover
144-
//! that is a function to generate a link that ends in `fn.is_prime.html`. Therefore, intralink
143+
//! that is a function to generate a link that ends in `fn.is_prime.html`. Therefore, intralink
145144
//! support should be considered "best effort" (for instance, don’t expect items generated by macros
146-
//! to be resolved). If cargo rdme is unable to generate the link it will still generate the README
145+
//! to be resolved). If cargo rdme is unable to generate the link it will still generate the README
147146
//! file, but a warning will be emitted.
148147
//!
149148
//! ## Heading levels
150149
//!
151150
//! The heading levels in the crate’s documentation will, by default, be nested under the level
152-
//! of the section of the README where it is inserted into. This behavior can be changed with
151+
//! of the section of the README where it is inserted into. This behavior can be changed with
153152
//! the `--heading-base-level` command line flag, or in the configuration file (see example
154153
//! below).
155154
//!
156155
//! # Configuration file
157156
//!
158157
//! If the default behavior of `cargo rdme` is not appropriate for your project you can crate a
159-
//! configuration file `.cargo-rdme.toml` in the root of your project. This is how that
158+
//! configuration file `.cargo-rdme.toml` in the root of your project. This is how that
160159
//! configuration file can look like:
161160
//!
162161
//! ```toml
163-
//! # Override the README file path. When this is not set cargo rdme will use the file path defined
162+
//! # Override the README file path. When this is not set cargo rdme will use the file path defined
164163
//! # in the project’s `Cargo.toml`.
165164
//! readme-path = "MY-README.md"
166165
//!
167-
//! # What line terminator to use when generating the README file. This can be "lf" or "crlf".
166+
//! # What line terminator to use when generating the README file. This can be "lf" or "crlf".
168167
//! line-terminator = "lf"
169168
//!
170169
//! # If you are using a workspace to hold multiple projects, use this to select the project from
171-
//! # which to extract the documentation from. It can be useful to also set `readme-path` to create
170+
//! # which to extract the documentation from. It can be useful to also set `readme-path` to create
172171
//! # the README file in the root of the project.
173172
//! workspace-project = "subproject"
174173
//!
175174
//! # Defines the base heading level to use when inserting the crate’s documentation in the
176-
//! # README. If this is not set the crate’s documentation will be inserted with its sections
175+
//! # README. If this is not set the crate’s documentation will be inserted with its sections
177176
//! # belonging to the README section where the insertion happens.
178177
//! heading-base-level = 0
179178
//!
180-
//! # The default entrypoint will be `src/lib.rs`. You can change that in the `entrypoint` table.
179+
//! # The default entrypoint will be `src/lib.rs`. You can change that in the `entrypoint` table.
181180
//! [entrypoint]
182181
//! # The entrypoint type can be "lib" or "bin".
183182
//! type = "bin"
184-
//! # When you set type to "bin" the entrypoint default to `src/main.rs`. If you have binary targets
183+
//! # When you set type to "bin" the entrypoint default to `src/main.rs`. If you have binary targets
185184
//! # specified in your cargo manifest you can select them by name with `bin-name`.
186185
//! bin-name = "my-bin-name"
187186
//!
188187
//! [intralinks]
189-
//! # Defines the base url to use in intralinks urls. The default value is `https://docs.rs`.
188+
//! # Defines the base url to use in intralinks urls. The default value is `https://docs.rs`.
190189
//! docs-rs-base-url = "https://mydocs.rs"
191-
//! # Defines the version to use in intralinks urls. The default value is `latest`.
190+
//! # Defines the version to use in intralinks urls. The default value is `latest`.
192191
//! docs-rs-version = "1.0.0"
193192
//! # If this is set the intralinks will be stripping in the README file.
194193
//! strip-links = false
195194
//! ```
196195
//!
197-
//! These setting can be overridden with command line flags. Run `cargo rdme --help` for more
196+
//! These setting can be overridden with command line flags. Run `cargo rdme --help` for more
198197
//! information.
199198
//!
200199
//! # Integration with CI
201200
//!
202201
//! To verify that your README is up to date with your crate’s documentation you can run
203-
//! `cargo rdme --check`. The exit code will be `0` if the README is up to date, `3` if it’s
202+
//! `cargo rdme --check`. The exit code will be `0` if the README is up to date, `3` if it’s
204203
//! not, or `4` if there were warnings.
205204
//!
206205
//! If you use GitHub Actions you can add this step to verify if the README is up to date:
@@ -467,7 +466,7 @@ fn run(options: options::Options) -> Result<(), RunError> {
467466
No marker found in the README file ({readme_filepath}).
468467
469468
cargo-rdme expects a marker in the README where the crate’s documentation will
470-
be inserted. This is the marker you should add to your README:
469+
be inserted. This is the marker you should add to your README:
471470
472471
{marker}",
473472
readme_filepath = readme_path.display(),

tools/check.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ assert_installed "cargo"
2020

2121
trap on_failure ERR
2222

23+
export RUSTFLAGS="-Dwarnings"
24+
2325
function check_basic {
2426
echo 'Building:'
25-
cargo build --features fatal-warnings --all-targets
27+
cargo build --all-targets --all-features
2628
echo 'Testing:'
27-
cargo test --features fatal-warnings --all-targets
29+
cargo hack test --each-feature --all-targets
2830
# Weirdly, the `cargo test ... --all-targets ...` above does not run the tests in the documentation, so we run the
2931
# doc tests like this.
3032
# See https://github.com/rust-lang/cargo/issues/6669.
3133
echo 'Testing doc:'
32-
cargo test --features fatal-warnings --doc
34+
cargo test --doc --all-features
3335
echo 'Checking the benchmarks:'
34-
cargo bench --features fatal-warnings -- --test
36+
cargo bench --all-features -- --test
3537
echo 'Checking documentation:'
36-
cargo doc --features fatal-warnings --no-deps
38+
cargo doc --no-deps --all-features
3739
}
3840

3941
function check_doc_url_links {

0 commit comments

Comments
 (0)