Skip to content

uucore: draw diagnostics against any line of text - #15532

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:uucore-diag-source-line
Oct 20, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:uucore-diag-source-line

Conversation

@sylvestre

@sylvestre sylvestre commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The caret diagnostics only know how to point into the command line. sed, grep and findutils want the same reports, but sed's script errors and grep's `-f` patterns live in a script or a file, not in argv, so sed carried its own copy of the layout.

Add SourceLine, for utilities whose instructions come from a script or a
pattern file rather than the command line (sed, grep), and share the
ariadne drawing with Snapshot. Also make use_color() public, decide
enabled() once, and keep ariadne's "Help" when no localizer is set up.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The stub’s lifetime mismatch breaks feature-disabled callers, and rendering allocates memory proportional to the source line number.

2 open issues
What changed in this PR

Extends uucore’s shared caret diagnostics to named source lines, supporting script and pattern-file errors outside command-line arguments.

Changes:

  • Adds SourceLine rendering and a feature-disabled stub.
  • Shares rendering logic and exposes color detection.
  • Caches diagnostic enablement and preserves “Help” without a localizer.
File Description
src/​uucore/​src/​lib/​features/​diagnostics.rs Adds source-line reports, shared rendering, and regression tests.
src/​uucore/​src/​lib/​features/​diagnostics_stub.rs Adds no-op source-line and color APIs.

Review effort: Balanced

Comment thread src/uucore/src/lib/features/diagnostics_stub.rs Outdated
Comment on lines +866 to +867
let padding = self.line_number - 1;
let text = format!("{}{} ", "\n".repeat(padding), self.text);
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:16
@sylvestre
sylvestre force-pushed the uucore-diag-source-line branch from 7009cae to 7ed959c Compare October 19, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Colored header parsing and empty-line handling can suppress valid source-line reports.

3 open issues
1 resolved since last review

Review effort: Balanced

help: Option<&str>,
color: bool,
) -> Option<String> {
if self.line_number == 0 || self.text.is_empty() {
Comment on lines +879 to +880
let open = header.find("[ ")? + 2;
let close = header.rfind(" ]")?;
@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 11.61%

⚠️ 120 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 regressed benchmarks
✅ 399 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation true_consecutive_calls 294.7 ns 350.2 ns -15.86%
❌ Memory du_deep_tree[(100, 3)] 76.5 KB 82.4 KB -7.14%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:uucore-diag-source-line (2dbcf99) with main (5fda18e)2

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (865e575) during the generation of this report, so 5fda18e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Copilot AI balanced review requested due to automatic review settings October 19, 2026 20:47
@sylvestre
sylvestre force-pushed the uucore-diag-source-line branch from 7ed959c to 2dbcf99 Compare October 19, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues

Review effort: Lite

Comment on lines +105 to 108
/// Whether a drawn report is colored: at a terminal, unless `NO_COLOR` is set.
pub fn use_color() -> bool {
env::var_os("NO_COLOR").is_none() && std::io::stderr().is_terminal()
}
@sylvestre
sylvestre merged commit ae34722 into uutils:main Oct 20, 2026
189 of 190 checks passed
@sylvestre
sylvestre deleted the uucore-diag-source-line branch October 20, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants