Skip to content
Merged
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e7bd340
Switch missing_abi lint to warn-by-default.
m-ou-se Oct 31, 2024
585c976
Update tests.
m-ou-se Oct 31, 2024
2f5a3d4
Convert `struct FromBytesWithNulError` into enum
nyurik Dec 10, 2024
86b86fa
Rename `pos` to `position`
nyurik Jan 11, 2025
9cbd177
Detect unstable lint docs that dont enable their feature
compiler-errors Jan 12, 2025
3d54764
ci: Enable opt-dist for dist-aarch64-linux builds
mrkajetanp Dec 3, 2024
3d9dcf4
Un-spaghettify the control flow of generate_lint_output
compiler-errors Jan 12, 2025
a911da1
Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics
tgross35 Dec 15, 2024
f6a2db8
Update compiler-builtins to 0.1.143
tgross35 Jan 15, 2025
c89ee08
Make sure we actually use the right trivial lifetime substs when eage…
compiler-errors Jan 15, 2025
58d6301
Update ReadDir::next in std::sys::pal::unix::fs to use `&raw const (*…
zachs18 Dec 23, 2024
285df03
Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=Nadrieril
jhpratt Jan 15, 2025
f9d8b65
Rollup merge of #133807 - mrkajetanp:ci-aarch64-opt-dist, r=Kobzol
jhpratt Jan 15, 2025
229c91b
Rollup merge of #134143 - nyurik:err-nul, r=dtolnay
jhpratt Jan 15, 2025
bf4aeeb
Rollup merge of #134338 - tgross35:overflowing-c-safe-ret, r=bjorn3,a…
jhpratt Jan 15, 2025
56eb7bd
Rollup merge of #134678 - zachs18:offset-ptr-update, r=tgross35
jhpratt Jan 15, 2025
f35ff74
Rollup merge of #135424 - compiler-errors:unstable-lint, r=ehuss
jhpratt Jan 15, 2025
8e91327
Rollup merge of #135520 - compiler-errors:mono-impossible-drop-with-l…
jhpratt Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions src/tools/lint-docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,37 +473,64 @@ impl<'a> LintExtractor<'a> {
.filter(|line| line.starts_with('{'))
.map(serde_json::from_str)
.collect::<Result<Vec<serde_json::Value>, _>>()?;

// First try to find the messages with the `code` field set to our lint.
let matches: Vec<_> = msgs
.iter()
.filter(|msg| matches!(&msg["code"]["code"], serde_json::Value::String(s) if s==name))
.map(|msg| msg["rendered"].as_str().expect("rendered field should exist").to_string())
.collect();
if matches.is_empty() {
// Some lints override their code to something else (E0566).
// Try to find something that looks like it could be our lint.
let matches: Vec<_> = msgs.iter().filter(|msg|
matches!(&msg["rendered"], serde_json::Value::String(s) if s.contains(name)))
.map(|msg| msg["rendered"].as_str().expect("rendered field should exist").to_string())
.collect();
if matches.is_empty() {
let rendered: Vec<&str> =
msgs.iter().filter_map(|msg| msg["rendered"].as_str()).collect();
let non_json: Vec<&str> =
stderr.lines().filter(|line| !line.starts_with('{')).collect();
Err(format!(
"did not find lint `{}` in output of example, got:\n{}\n{}",
name,
non_json.join("\n"),
rendered.join("\n")
)
.into())
} else {
Ok(matches.join("\n"))
}
} else {
Ok(matches.join("\n"))
if !matches.is_empty() {
return Ok(matches.join("\n"));
}

// Try to detect if an unstable lint forgot to enable a `#![feature(..)]`.
// Specifically exclude `test_unstable_lint` which exercises this on purpose.
if name != "test_unstable_lint"
&& msgs.iter().any(|msg| {
matches!(&msg["code"]["code"], serde_json::Value::String(s) if s=="unknown_lints")
&& matches!(&msg["message"], serde_json::Value::String(s) if s.contains(name))
})
{
let rendered: Vec<&str> =
msgs.iter().filter_map(|msg| msg["rendered"].as_str()).collect();
let non_json: Vec<&str> =
stderr.lines().filter(|line| !line.starts_with('{')).collect();
return Err(format!(
"did not find lint `{}` in output of example (got unknown_lints)\n\
Is the lint possibly misspelled, or does it need a `#![feature(...)]`?\n\
Output was:\n\
{}\n{}",
name,
rendered.join("\n"),
non_json.join("\n"),
)
.into());
}

// Some lints override their code to something else (E0566).
// Try to find something that looks like it could be our lint.
let matches: Vec<_> = msgs
.iter()
.filter(
|msg| matches!(&msg["rendered"], serde_json::Value::String(s) if s.contains(name)),
)
.map(|msg| msg["rendered"].as_str().expect("rendered field should exist").to_string())
.collect();
if !matches.is_empty() {
return Ok(matches.join("\n"));
}

// Otherwise, give a descriptive error.
let rendered: Vec<&str> = msgs.iter().filter_map(|msg| msg["rendered"].as_str()).collect();
let non_json: Vec<&str> = stderr.lines().filter(|line| !line.starts_with('{')).collect();
Err(format!(
"did not find lint `{}` in output of example, got:\n{}\n{}",
name,
non_json.join("\n"),
rendered.join("\n")
)
.into())
}

/// Saves the mdbook lint chapters at the given path.
Expand Down