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.
This commit is contained in:
commit
d78704a253
2 changed files with 21 additions and 34 deletions
|
@ -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
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -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))
|
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) {
|
pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
|
||||||
let lang_features = features.lang;
|
let lang_features = features.lang;
|
||||||
let lib_features = features
|
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
|
// 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
|
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!(
|
||||||
tidy_error!(
|
bad,
|
||||||
bad,
|
"The Unstable Book has a 'library feature' section '{}' which doesn't \
|
||||||
"The Unstable Book has a 'library feature' section '{}' which doesn't \
|
|
||||||
correspond to an unstable library feature",
|
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.
|
// 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 \
|
"The Unstable Book has a 'language feature' section '{}' which doesn't \
|
||||||
correspond to an unstable language feature",
|
correspond to an unstable language feature",
|
||||||
feature_name
|
feature_name
|
||||||
)
|
);
|
||||||
|
maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, bad);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List unstable features that don't have Unstable Book sections.
|
// List unstable features that don't have Unstable Book sections.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue