Skip to content

Commit ffa8627

Browse files
committed
Fix crates using tidy programmatically
1 parent 0d7dc2a commit ffa8627

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/tools/features-status-dump/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::path::PathBuf;
55

66
use anyhow::{Context, Result};
77
use clap::Parser;
8+
use tidy::diagnostics::RunningCheck;
89
use tidy::features::{Feature, collect_lang_features, collect_lib_features};
910

1011
#[derive(Debug, Parser)]
@@ -29,7 +30,7 @@ struct FeaturesStatus {
2930
fn main() -> Result<()> {
3031
let Cli { compiler_path, library_path, output_path } = Cli::parse();
3132

32-
let lang_features_status = collect_lang_features(&compiler_path, &mut false);
33+
let lang_features_status = collect_lang_features(&compiler_path, &mut RunningCheck::new_noop());
3334
let lib_features_status = collect_lib_features(&library_path)
3435
.into_iter()
3536
.filter(|&(ref name, _)| !lang_features_status.contains_key(name))

src/tools/tidy/src/diagnostics.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ pub struct RunningCheck {
146146
}
147147

148148
impl RunningCheck {
149+
/// Creates a new instance of a running check without going through the diag
150+
/// context.
151+
/// Useful if you want to run some functions from tidy without configuring
152+
/// diagnostics.
153+
pub fn new_noop() -> Self {
154+
let ctx = DiagCtx::new(Path::new(""), false);
155+
ctx.start_check("noop")
156+
}
157+
149158
/// Immediately output an error and mark the check as failed.
150159
pub fn error<T: Display>(&mut self, msg: T) {
151160
self.mark_as_bad();

src/tools/unstable-book-gen/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::env;
55
use std::fs::{self, write};
66
use std::path::Path;
77

8+
use tidy::diagnostics::RunningCheck;
89
use tidy::features::{Features, collect_env_vars, collect_lang_features, collect_lib_features};
910
use tidy::t;
1011
use tidy::unstable_book::{
@@ -122,7 +123,7 @@ fn main() {
122123
let src_path = Path::new(&src_path_str);
123124
let dest_path = Path::new(&dest_path_str);
124125

125-
let lang_features = collect_lang_features(compiler_path, &mut false);
126+
let lang_features = collect_lang_features(compiler_path, &mut RunningCheck::new_noop());
126127
let lib_features = collect_lib_features(library_path)
127128
.into_iter()
128129
.filter(|&(ref name, _)| !lang_features.contains_key(name))

0 commit comments

Comments
 (0)