loco-rs/loco · error

found no ```rust blocks under

Error message

found no ```rust blocks under {} — the extractor is broken, not the docs

What it means

The docs-syntax checker found the `docs/` tree but zero ```rust code blocks in it. Since Loco's documentation is expected to be full of Rust examples, an empty extraction means the markdown parsing/extractor logic is broken rather than the docs genuinely having no Rust code.

Solutions

  1. Check the ```rust fence detection regex/`collect` function in xtask/src/docs_syntax.rs for regressions
  2. Verify docs/ actually contains markdown files with ```rust fenced blocks
  3. Diff the extractor against the last known-good version of docs_syntax.rs

Example fix

// before
let closing = Regex::new(r"^```").unwrap(); // too narrow, never matches
// after
let closing = Regex::new(r"^\s*```\s*$").unwrap();
Defensive patterns

Strategy: validation

Validate before calling

let n = count_rust_fences("docs"); assert!(n > 0, "docs tree has no ```rust blocks");

Prevention

When it happens

Trigger: Running the checker when `collect()` returns no blocks from `docs/` — typically after a change to the markdown parsing (closing-fence regex, opening fence detection) or after docs were replaced with non-markdown content.

Common situations: After refactoring `docs_syntax.rs` and breaking fence matching; after bulk-converting docs to another format; git history surgery that emptied the docs tree.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of loco-rs/loco@23639d1e36 (2026-09-12). Data as JSON: /api/errors/b740b73229ae8d93. Report an issue: GitHub.

Appendix: source

Thrown at xtask/src/docs_syntax.rs:65

    /// 1-based line of the opening fence, so the report is clickable.
    line: usize,
    code: String,
    skipped: bool,
}

/// # Errors
/// when the docs tree is missing, a file cannot be read, or any block that
/// did not opt out fails to parse as Rust
pub fn run(project_dir: &Path) -> Result<()> {
    let root = project_dir.join(DOCS_DIR);
    if !root.is_dir() {
        bail!("{} does not exist", root.display());
    }

    let mut blocks = Vec::new();
    collect(&root, &mut blocks)?;
    if blocks.is_empty() {
        bail!(
            "found no ```rust blocks under {} — the extractor is broken, not the docs",
            root.display()
        );
    }

    let before_sources = blocks.len();
    for dir in RUST_DIRS {
        collect(&project_dir.join(dir), &mut blocks)?;
    }
    if blocks.len() == before_sources {
        bail!("found no ```rust blocks in {RUST_DIRS:?} — the extractor is broken, not the docs");
    }

    let mut failures = Vec::new();
    let mut checked = 0;
    let mut skipped = 0;

    for block in &blocks {

View on GitHub (pinned to 23639d1e36)