Move cfg attrs up to the mod definitions to disable sourcegen

This commit is contained in:
Amos Wenger 2022-07-23 17:23:13 +02:00
parent 0bffdf2627
commit b351e115d6
8 changed files with 7 additions and 32 deletions

View file

@ -10,10 +10,11 @@
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
#[cfg(not(feature = "in-rust-tree"))]
mod sourcegen;
mod tidy;
mod testdir;
mod support;
mod testdir;
mod tidy;
use std::{collections::HashMap, path::PathBuf, time::Instant};

View file

@ -1,9 +1,7 @@
//! Generates `assists.md` documentation.
#[cfg(not(feature = "in-rust-tree"))]
use std::{fmt, fs, io, path::PathBuf};
#[cfg(not(feature = "in-rust-tree"))]
#[test]
fn sourcegen_feature_docs() {
let features = Feature::collect().unwrap();
@ -19,7 +17,6 @@ fn sourcegen_feature_docs() {
fs::write(&dst, &contents).unwrap();
}
#[cfg(not(feature = "in-rust-tree"))]
#[derive(Debug)]
struct Feature {
id: String,
@ -27,7 +24,6 @@ struct Feature {
doc: String,
}
#[cfg(not(feature = "in-rust-tree"))]
impl Feature {
fn collect() -> io::Result<Vec<Feature>> {
let crates_dir = sourcegen::project_root().join("crates");
@ -58,7 +54,6 @@ impl Feature {
}
}
#[cfg(not(feature = "in-rust-tree"))]
fn is_valid_feature_name(feature: &str) -> Result<(), String> {
'word: for word in feature.split_whitespace() {
for short in ["to", "and"] {
@ -78,7 +73,6 @@ fn is_valid_feature_name(feature: &str) -> Result<(), String> {
Ok(())
}
#[cfg(not(feature = "in-rust-tree"))]
impl fmt::Display for Feature {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)