Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print: fix a couple bugs in the initial diagnostics PR. #27

Merged
merged 2 commits into from
May 1, 2023
Merged
Changes from all commits
Commits
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
46 changes: 25 additions & 21 deletions src/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ impl Print for Attr {
let bug_location_prefix = match level {
DiagLevel::Bug(location) => {
let location = location.to_string();
let location = match location.split_once("/src/") {
let location = match location.rsplit_once("/src/") {
Some((_path_prefix, intra_src)) => intra_src,
None => &location,
};
Expand All @@ -1825,27 +1825,31 @@ impl Print for Attr {
// HACK(eddyb) this would ideally use line comments,
// but adding the line prefix properly to everything
// is a bit of a pain without special `pretty` support.
pretty::Node::InlineOrIndentedBlock(vec![pretty::Fragment::new([
comment_style.clone().apply("/* ").into(),
pretty::Styles {
thickness: Some(3),

// HACK(eddyb) this allows larger "icons"
// without adding gaps via `line-height`.
subscript: true,
size: Some(2),

..pretty::Styles::color(icon_color)
}
.apply(icon)
.into(),
" ".into(),
bug_location_prefix,
printed_message,
comment_style.apply(" */").into(),
])])
pretty::Fragment::new([
comment_style.clone().apply("/*"),
pretty::Node::BreakingOnlySpace,
pretty::Node::InlineOrIndentedBlock(vec![pretty::Fragment::new([
pretty::Styles {
thickness: Some(3),

// HACK(eddyb) this allows larger "icons"
// without adding gaps via `line-height`.
subscript: true,
size: Some(2),

..pretty::Styles::color(icon_color)
}
.apply(icon)
.into(),
" ".into(),
bug_location_prefix,
printed_message,
])]),
pretty::Node::BreakingOnlySpace,
comment_style.apply("*/"),
])
})
.intersperse(pretty::Node::ForceLineSeparation),
.intersperse(pretty::Node::ForceLineSeparation.into()),
),
),

Expand Down