Skip to content

Feedback #1

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

Closed
wants to merge 22 commits into from
Closed

Feedback #1

wants to merge 22 commits into from

Conversation

Muscraft
Copy link
Owner

No description provided.

@coveralls
Copy link

coveralls commented Mar 29, 2025

Pull Request Test Coverage Report for Build 14500512388

Details

  • 1246 of 1415 (88.06%) changed or added relevant lines in 7 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+1.4%) to 87.161%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/lib.rs 1 2 50.0%
src/level.rs 17 24 70.83%
src/snippet.rs 94 118 79.66%
src/renderer/source_map.rs 248 287 86.41%
src/renderer/mod.rs 858 956 89.75%
Files with Coverage Reduction New Missed Lines %
src/snippet.rs 2 81.43%
Totals Coverage Status
Change from base Build 14148835326: 1.4%
Covered Lines: 1351
Relevant Lines: 1550

💛 - Coveralls

@Muscraft Muscraft force-pushed the feedback branch 3 times, most recently from 6240e15 to ed8dfa6 Compare March 29, 2025 20:10
@Muscraft Muscraft marked this pull request as draft March 29, 2025 20:14
Copy link

Choose a reason for hiding this comment

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

note: doesn't get colored?

Copy link

Choose a reason for hiding this comment

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

Changes seem to be

  • We now bold the : in error:
  • We will no longer color the (whitespace) between the column and |

Copy link

Choose a reason for hiding this comment

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

If its not too much trouble, could this be hacked in to the old renderer in a commit before so the test changes are easier to see?

Copy link

Choose a reason for hiding this comment

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

We added a blank line between the first snippet and :::

Copy link

Choose a reason for hiding this comment

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

We are now folding lines between annotations

use margin::Margin;
use std::fmt::Display;
use rustc_hash::{FxHashMap, FxHasher};
Copy link

Choose a reason for hiding this comment

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

should we consider making this an optional feature or removing it?

src/snippet.rs Outdated
/// Primary structure provided for formatting
///
/// See [`Level::title`] to create a [`Message`]
#[derive(Debug)]
#[derive(Clone, Debug)]
Copy link

Choose a reason for hiding this comment

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

Could you split API changes like this into a commit before hand?

Copy link

Choose a reason for hiding this comment

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

refactor: Right align line numbers

That is not a refactor if its user visible

Copy link

Choose a reason for hiding this comment

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

refactor: Move to new API

its not a refactor if its user visible.

This is also a breaking change and should be called out

.label("expected enum `std::option::Option`"),
),
let message = Level::Error.message("mismatched types").id("E0308").group(
Group::new().element(
Copy link

Choose a reason for hiding this comment

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

Could you explain the new API in the commit or PR?

For example, why was a Group container chosen over group accepting a Vec or IntoIterator

src/snippet.rs Outdated
Comment on lines 13 to 25
fn newline_count(body: &str) -> usize {
#[cfg(feature = "simd")]
{
memchr::memchr_iter(b'\n', body.as_bytes())
.count()
.saturating_sub(1)
}
#[cfg(not(feature = "simd"))]
{
body.lines().count().saturating_sub(1)
}
}

Copy link

Choose a reason for hiding this comment

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

Generally, implementation details should be at the end.

@@ -38,104 +35,178 @@ impl<'a> Message<'a> {
self
}

pub fn snippet(mut self, slice: Snippet<'a>) -> Self {
self.snippets.push(slice);
pub fn group(mut self, group: Group<'a>) -> Self {
Copy link

Choose a reason for hiding this comment

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

One of the places where we deal with groups, we'll need to explain the difference between a single group vs many groups. Unsure whether a suggested policy belongs in this package or somewhere else but at least Cargo and Rustc will need to be consistent

src/snippet.rs Outdated
.map(|a| a.range.start)
.min()
.unwrap_or(0);
pub fn needs_col_separator(mut self, needs_col_separator: bool) -> Self {
Copy link

Choose a reason for hiding this comment

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

What role does this serve?

src/snippet.rs Outdated
self
}

pub fn annotations(mut self, annotation: impl IntoIterator<Item = Annotation<'a>>) -> Self {
self.annotations.extend(annotation);
pub fn col_separator(mut self, col_separator: bool) -> Self {
Copy link

Choose a reason for hiding this comment

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

What is this?

src/snippet.rs Outdated
Comment on lines 268 to 270
Primary, // in rustc terms, "primary"; color to message's level
Context, // in rustc terms, "secondary"; fixed color
// Level(Level), // from old API, dropped
Copy link

Choose a reason for hiding this comment

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

Please use doc comments

src/snippet.rs Outdated
Comment on lines 325 to 333
pub fn primary(mut self, primary: bool) -> Self {
self.primary = primary;
self
}

pub fn standalone(mut self, standalone: bool) -> Self {
self.standalone = standalone;
self
}
Copy link

Choose a reason for hiding this comment

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

What are these?

Comment on lines +315 to +362
pub fn line(mut self, line: usize) -> Self {
self.line = Some(line);
self
}

pub fn char_column(mut self, char_column: usize) -> Self {
self.char_column = Some(char_column);
self
}
Copy link

Choose a reason for hiding this comment

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

These are new. How do they relate to the rest of the API?

Should we make new parts of the API an extra commit on top of the existing API for easier comparison and discussion?

src/snippet.rs Outdated
Comment on lines 246 to 221
impl<'a> From<Snippet<'a, Annotation<'a>>> for Element<'a> {
fn from(value: Snippet<'a, Annotation<'a>>) -> Self {
Element::Cause(value)
}
}
Copy link

Choose a reason for hiding this comment

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

I'd put all of these Froms next to Element as this is about defining how to interact with an Element and not each of the other types

}

pub(crate) fn is_deletion(&self, sm: &SourceMap<'_>) -> bool {
self.replacement.trim().is_empty() && self.replaces_meaningful_content(sm)
Copy link

Choose a reason for hiding this comment

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

Why trim and only on this one?

Copy link

Choose a reason for hiding this comment

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

Could we add these tests in a prior commit, either without the patches or using annotations instead of patches?

Comment on lines +148 to +147
pub const fn theme(mut self, output_theme: OutputTheme) -> Self {
self.theme = output_theme;
self
}

Copy link

Choose a reason for hiding this comment

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

I feel like if I was looking for how to enable unicode support, I wouldn't be looking at theming.

@@ -1690,3 +1691,424 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized`
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input_new), expected);
}

#[test]
fn e0271() {
Copy link

Choose a reason for hiding this comment

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

what are these test names?

Can we add these tests without unicode support and then show how unicode support changes them?

Copy link

Choose a reason for hiding this comment

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

chore: Align more with rustc's output

"chore"s don't generally have user-visible impact. Isn't this a fix?

Copy link

Choose a reason for hiding this comment

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

And in what way?

Cargo.toml Outdated
Copy link

Choose a reason for hiding this comment

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

refactor: Better match rustc's internal renderer

Since this has end-user impact, this isn't just about better matching the internals but the result and that should be reflected in the commit type

Ideally, the commit description would cover expected changes, including regressions

Copy link

Choose a reason for hiding this comment

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

fix: Use display and char pos in draw_line

That says what its doing; not what its fixing

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.

3 participants