Skip to content

Commit da91f06

Browse files
committed
Add span tracking to allow emitting diagnostics everywhere
1 parent 1ccd5a9 commit da91f06

File tree

11 files changed

+258
-124
lines changed

11 files changed

+258
-124
lines changed

Cargo.lock

Lines changed: 111 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/mdbook-goals/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ regex = "1.11.1"
1111
rust-project-goals = { version = "0.1.0", path = "../rust-project-goals" }
1212
semver = "1.0.23"
1313
serde_json = "1.0.133"
14+
spanned = "0.4.0"

crates/mdbook-goals/src/mdbook_preprocessor.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rust_project_goals::{
1616
goal::{self, GoalDocument, Status, TeamAsk},
1717
re, team,
1818
};
19+
use spanned::Spanned;
1920

2021
const LINKS: &str = "links";
2122
const LINKIFIERS: &str = "linkifiers";
@@ -293,18 +294,18 @@ impl<'c> GoalPreprocessorWithContext<'c> {
293294
}
294295
let config = Configuration::get();
295296
let rows = std::iter::once(vec![
296-
"Ask".to_string(),
297-
"aka".to_string(),
298-
"Description".to_string(),
297+
Spanned::here("Ask".to_string()),
298+
Spanned::here("aka".to_string()),
299+
Spanned::here("Description".to_string()),
299300
])
300301
.chain(config.team_asks.iter().map(|(name, details)| {
301302
vec![
302-
format!("{name:?}"),
303-
details.short.to_string(),
304-
details.about.to_string(),
303+
Spanned::here(format!("{name:?}")),
304+
Spanned::here(details.short.to_string()),
305+
Spanned::here(details.about.to_string()),
305306
]
306307
}))
307-
.collect::<Vec<Vec<String>>>();
308+
.collect::<Vec<Vec<Spanned<String>>>>();
308309
let table = util::format_table(&rows);
309310
let new_content = re::VALID_TEAM_ASKS.replace_all(&chapter.content, table);
310311
chapter.content = new_content.to_string();

crates/rust-project-goals-cli-llm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ comrak = "0.31.0"
1919
progress_bar = "1.0.6"
2020
tokio = { version = "1.42.0", features = ["full"] }
2121
rust-project-goals-json = { version = "0.1.0", path = "../rust-project-goals-json" }
22+
spanned = "0.4.0"

crates/rust-project-goals-cli-llm/src/updates.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rust_project_goals::markwaydown;
44
use rust_project_goals::re::{HELP_WANTED, TLDR};
55
use rust_project_goals::util::comma;
66
use rust_project_goals_json::GithubIssueState;
7+
use spanned::{Span, Spanned};
78
use std::io::Write;
89
use std::path::Path;
910
use std::process::{Command, Stdio};
@@ -219,7 +220,14 @@ fn help_wanted(
219220
}
220221

221222
fn why_this_goal(issue_id: &IssueId, issue: &ExistingGithubIssue) -> anyhow::Result<String> {
222-
let sections = markwaydown::parse_text(issue_id.url(), &issue.body)?;
223+
let sections = markwaydown::parse_text(Spanned::new(
224+
&issue.body,
225+
// FIXME: preexisting: this makes it appear as if the issue url is a file.
226+
Span {
227+
file: issue_id.url().into(),
228+
bytes: 0..0,
229+
},
230+
))?;
223231
for section in sections {
224232
if section.title == "Why this goal?" {
225233
return Ok(section.text.trim().to_string());

crates/rust-project-goals-cli/src/rfc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ fn task_items(goal_plan: &GoalPlan) -> anyhow::Result<Vec<String>> {
487487
let mut tasks = vec![];
488488

489489
if let Some(title) = &goal_plan.subgoal {
490-
tasks.push(format!("### {title}"));
490+
tasks.push(format!("### {}", **title));
491491
}
492492

493493
for plan_item in &goal_plan.plan_items {

crates/rust-project-goals/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ rust_team_data = { git = "https://github.com/rust-lang/team" }
1616
rust-project-goals-json = { version = "0.1.0", path = "../rust-project-goals-json" }
1717
toml = "0.8.19"
1818
indexmap = "2.7.1"
19+
spanned = "0.4.0"

crates/rust-project-goals/src/format_team_ask.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::{
33
path::PathBuf,
44
};
55

6+
use spanned::Spanned;
7+
68
use crate::{
79
config::Configuration,
810
goal::TeamAsk,
@@ -117,19 +119,20 @@ pub fn format_team_asks(asks_of_any_team: &[&TeamAsk]) -> anyhow::Result<String>
117119

118120
// Create the table itself.
119121
let table = {
120-
let headings = std::iter::once("Goal".to_string())
122+
let headings = std::iter::once(Spanned::here("Goal".to_string()))
121123
.chain(ask_headings.iter().map(|&ask_kind| {
122-
format!(
124+
Spanned::here(format!(
123125
"[{team_ask_short}][valid_team_asks]", // HACK: This should not be hardcoded in the code.
124126
team_ask_short = config.team_asks[ask_kind].short,
125-
)
127+
))
126128
})) // e.g. "discussion and moral support"
127-
.collect::<Vec<String>>();
129+
.collect::<Vec<Spanned<String>>>();
128130

129131
let rows = goal_rows.into_iter().map(|(goal_data, goal_columns)| {
130132
std::iter::once(goal_data.goal_title())
131133
.chain(goal_columns)
132-
.collect::<Vec<String>>()
134+
.map(Spanned::here)
135+
.collect::<Vec<Spanned<String>>>()
133136
});
134137

135138
std::iter::once(headings).chain(rows).collect::<Vec<_>>()

0 commit comments

Comments
 (0)