diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-31 23:05:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-31 23:05:45 +0200 |
| commit | d78704a253b95f26a6dbc0ea0261fb3ee52d79f8 (patch) | |
| tree | a9927196fe53bfd5b178fea14ad42ecf567041e5 | |
| parent | 2f5d5480027f9a12a833fadfa8398ebef7c8d944 (diff) | |
| parent | 14e4f9f245c615cd379397908abc52c795b65d04 (diff) | |
| download | rust-d78704a253b95f26a6dbc0ea0261fb3ee52d79f8.tar.gz rust-d78704a253b95f26a6dbc0ea0261fb3ee52d79f8.zip | |
Rollup merge of #139151 - mejrs:underscore_to_dash, r=onur-ozkan
tidy: properly check for orphaned unstable_book pages This also recommends using underscores - something that took me a little bit too long to figure out. Note: this PR deletes the page `src/doc/unstable-book/src/library-features/c-variadic.md`. The page `src/doc/unstable-book/src/lang-features/c-variadic.md` remains.
| -rw-r--r-- | src/doc/unstable-book/src/library-features/c-variadic.md | 26 | ||||
| -rw-r--r-- | src/tools/tidy/src/unstable_book.rs | 29 |
2 files changed, 21 insertions, 34 deletions
diff --git a/src/doc/unstable-book/src/library-features/c-variadic.md b/src/doc/unstable-book/src/library-features/c-variadic.md deleted file mode 100644 index 77762116e6b..00000000000 --- a/src/doc/unstable-book/src/library-features/c-variadic.md +++ /dev/null @@ -1,26 +0,0 @@ -# `c_variadic` - -The tracking issue for this feature is: [#44930] - -[#44930]: https://github.com/rust-lang/rust/issues/44930 - ------------------------- - -The `c_variadic` library feature exposes the `VaList` structure, -Rust's analogue of C's `va_list` type. - -## Examples - -```rust -#![feature(c_variadic)] - -use std::ffi::VaList; - -pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize { - let mut sum = 0; - for _ in 0..n { - sum += args.arg::<usize>(); - } - sum -} -``` diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index 8be25b98df0..a2453a6c960 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -72,6 +72,19 @@ fn collect_unstable_book_lib_features_section_file_names(base_src_path: &Path) - collect_unstable_book_section_file_names(&unstable_book_lib_features_path(base_src_path)) } +/// Would switching underscores for dashes work? +fn maybe_suggest_dashes(names: &BTreeSet<String>, feature_name: &str, bad: &mut bool) { + let with_dashes = feature_name.replace('_', "-"); + if names.contains(&with_dashes) { + tidy_error!( + bad, + "the file `{}.md` contains underscores; use dashes instead: `{}.md`", + feature_name, + with_dashes, + ); + } +} + pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) { let lang_features = features.lang; let lib_features = features @@ -93,14 +106,13 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) { // Check for Unstable Book sections that don't have a corresponding unstable feature for feature_name in &unstable_book_lib_features_section_file_names - &unstable_lib_feature_names { - if !unstable_lang_feature_names.contains(&feature_name) { - tidy_error!( - bad, - "The Unstable Book has a 'library feature' section '{}' which doesn't \ + tidy_error!( + bad, + "The Unstable Book has a 'library feature' section '{}' which doesn't \ correspond to an unstable library feature", - feature_name - ); - } + feature_name + ); + maybe_suggest_dashes(&unstable_lib_feature_names, &feature_name, bad); } // Check for Unstable Book sections that don't have a corresponding unstable feature. @@ -112,7 +124,8 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) { "The Unstable Book has a 'language feature' section '{}' which doesn't \ correspond to an unstable language feature", feature_name - ) + ); + maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, bad); } // List unstable features that don't have Unstable Book sections. |
