Skip to content

Commit

Permalink
Use nicer utf8 characters for diagnostics (#675)
Browse files Browse the repository at this point in the history
This change (IMO) improves the diagnostic output by changing the
characters that codespan uses when outputting diagnostics.

Inspired by rust-lang/rust#126597.
  • Loading branch information
Jake-Shadle authored Jul 25, 2024
1 parent b69290e commit 33241a6
Show file tree
Hide file tree
Showing 12 changed files with 1,317 additions and 944 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ warning[deprecated]: this key will be removed in a future update, see https://gi
β”Œβ”€ tests/cfg/advisories.toml:4:1
β”‚
4 β”‚ vulnerability = "deny"
β”‚ ^^^^^^^^^^^^^
β”‚ ━━━━━━━━━━━━━

warning[deprecated]: this key will be removed in a future update, see https://github.com/EmbarkStudios/cargo-deny/pull/611 for details
β”Œβ”€ tests/cfg/advisories.toml:5:1
β”‚
5 β”‚ unmaintained = "warn"
β”‚ ^^^^^^^^^^^^
β”‚ ━━━━━━━━━━━━

warning[deprecated]: this key will be removed in a future update, see https://github.com/EmbarkStudios/cargo-deny/pull/611 for details
β”Œβ”€ tests/cfg/advisories.toml:6:1
β”‚
6 β”‚ unsound = "warn"
β”‚ ^^^^^^^
β”‚ ━━━━━━━

warning[deprecated]: this key will be removed in a future update, see https://github.com/EmbarkStudios/cargo-deny/pull/611 for details
β”Œβ”€ tests/cfg/advisories.toml:8:1
β”‚
8 β”‚ notice = "warn"
β”‚ ^^^^^^
β”‚ ━━━━━━

warning[deprecated]: this key will be removed in a future update, see https://github.com/EmbarkStudios/cargo-deny/pull/611 for details
β”Œβ”€ tests/cfg/advisories.toml:14:1
β”‚
14 β”‚ severity-threshold = "medium"
β”‚ ^^^^^^^^^^^^^^^^^^
β”‚ ━━━━━━━━━━━━━━━━━━
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ error: unable to obtain $HOME: HOME directory could not be obtained from the OS
β”Œβ”€ expansions.toml:3:6
β”‚
3 β”‚ "~/nope", # can't find $HOME
β”‚ ^
β”‚ ━


error: unable to obtain $HOME: non-utf8 path: PathBuf contains invalid UTF-8: οΏ½berraschung: Path contains invalid UTF-8
β”Œβ”€ expansions.toml:4:6
β”‚
4 β”‚ "~/not-utf8", # $HOME is not a utf-8 path
β”‚ ^
β”‚ ━


/this-home/works
Expand All @@ -23,29 +23,29 @@ error: opening `{` is unbalanced
β”Œβ”€ expansions.toml:8:6
β”‚
8 β”‚ "${no-end", # fails due to unclosed {
β”‚ ^^^^^^^^
β”‚ ━━━━━━━━
/missing/but i have a default/
error: failed to expand variable: '"\xDCberraschung"' is not utf-8
β”Œβ”€ expansions.toml:10:16
β”‚
10 β”‚ "/non-utf8/$NON_UTF8", # fails due to NON_UTF8
β”‚ ^^^^^^^^^
β”‚ ━━━━━━━━━
error: variable name cannot be empty
β”Œβ”€ expansions.toml:11:6
β”‚
11 β”‚ "$/empty", # fails due to empty variable
β”‚ ^
β”‚ ━
error: variable name cannot be empty
β”Œβ”€ expansions.toml:12:18
β”‚
12 β”‚ "/also-empty/${}", # ditto
β”‚ ^^^
β”‚ ━━━
/has-trailing/trail
Expand All @@ -54,14 +54,14 @@ error: variable name cannot be empty
β”Œβ”€ expansions.toml:15:6
β”‚
15 β”‚ "$!", # fails due to empty variable name
β”‚ ^
β”‚ ━
error: variable name is invalid
β”Œβ”€ expansions.toml:16:6
β”‚
16 β”‚ "${!}", # fails due to invalid character in variable name
β”‚ ^^^^
β”‚ ━━━━
/expands/stuff-in-the-middle-like-this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ warning: duplicate items detected
β”Œβ”€ duplicates:9:6
β”‚
9 β”‚ "RUSTSEC-0000-0001",
β”‚ -----------------
β”‚ ─────────────────
10 β”‚ { crate = "boop" },
11 β”‚ "RUSTSEC-0000-0001",
β”‚ -----------------
β”‚ ─────────────────

warning: duplicate items detected
β”Œβ”€ duplicates:10:5
β”‚
10 β”‚ { crate = "boop" },
β”‚ ------------------
β”‚ ──────────────────
11 β”‚ "RUSTSEC-0000-0001",
12 β”‚ "boop",
β”‚ ----
β”‚ ────

warning: duplicate items detected
β”Œβ”€ duplicates:5:6
β”‚
5 β”‚ "https://one.reg",
β”‚ ---------------
β”‚ ───────────────
6 β”‚ "https://one.reg",
β”‚ ---------------


β”‚ ───────────────
2 changes: 1 addition & 1 deletion src/cargo-deny/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ impl<'a> DiagPrinter<'a> {
which: OutputFormat::Human(Human {
stream,
grapher: krates.map(diag::InclusionGrapher::new),
config: term::Config::default(),
config: cargo_deny::diag::codespan_config(),
feature_depth,
}),
max_severity,
Expand Down
Loading

0 comments on commit 33241a6

Please sign in to comment.