Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
52 changes: 26 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.22.0", default-features = false }
foundry-compilers = { version = "0.19.1", default-features = false, features = [
foundry-compilers = { version = "0.19.4", default-features = false, features = [
"rustls",
"svm-solc",
] }
foundry-fork-db = "0.18"
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
solar = { package = "solar-compiler", version = "=0.1.7", default-features = false }
solar = { package = "solar-compiler", version = "=0.1.8", default-features = false }
svm = { package = "svm-rs", version = "0.5", default-features = false, features = [
"rustls",
] }
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/coverage/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl<'ast> ast::Visit<'ast> for SourceVisitor<'_> {
stmt.span,
);
}
StmtKind::For { body, .. } => {
StmtKind::For(yul::StmtFor { body, .. }) => {
self.push_stmt(body.span);
}
StmtKind::Switch(switch) => {
Expand Down
62 changes: 32 additions & 30 deletions crates/fmt/src/state/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<'ast> State<'_, 'ast> {
format: ListFormat,
) where
P: FnMut(&mut Self, &'a T),
S: FnMut(&T) -> Option<Span> + Copy,
S: FnMut(&T) -> Span,
{
if self.handle_span(Span::new(pos_lo, pos_hi), true) {
return;
Expand All @@ -232,26 +232,24 @@ impl<'ast> State<'_, 'ast> {
}

// Format single-item inline lists directly without boxes
self.print_inside_parens(|state| match get_span(&values[0]) {
Some(span) => {
state.s.cbox(state.ind);
let mut skip_break = true;
if state.peek_comment_before(span.hi()).is_some() {
state.hardbreak();
skip_break = false;
}
self.print_inside_parens(|state| {
let span = get_span(&values[0]);
state.s.cbox(state.ind);
let mut skip_break = true;
if state.peek_comment_before(span.hi()).is_some() {
state.hardbreak();
skip_break = false;
}

state.print_comments(span.lo(), CommentConfig::skip_ws().mixed_prev_space());
print(state, &values[0]);
state.print_comments(span.lo(), CommentConfig::skip_ws().mixed_prev_space());
print(state, &values[0]);

if !state.print_trailing_comment(span.hi(), None) && skip_break {
state.neverbreak();
} else {
state.break_offset_if_not_bol(0, -state.ind, false);
}
state.end();
if !state.print_trailing_comment(span.hi(), None) && skip_break {
state.neverbreak();
} else {
state.break_offset_if_not_bol(0, -state.ind, false);
}
None => print(state, &values[0]),
state.end();
});
}

Expand All @@ -263,7 +261,7 @@ impl<'ast> State<'_, 'ast> {
get_span: S,
) where
P: FnMut(&mut Self, &'a T),
S: FnMut(&T) -> Option<Span>,
S: FnMut(&T) -> Span,
{
if self.handle_span(span, false) {
return;
Expand All @@ -281,9 +279,9 @@ impl<'ast> State<'_, 'ast> {
format: ListFormat,
) -> bool
where
S: FnMut(&T) -> Option<Span>,
S: FnMut(&T) -> Span,
{
let Some(span) = values.first().and_then(&mut get_span) else {
let Some(span) = values.first().map(&mut get_span) else {
return false;
};

Expand Down Expand Up @@ -357,7 +355,7 @@ impl<'ast> State<'_, 'ast> {
format: ListFormat,
) where
P: FnMut(&mut Self, &'a T),
S: FnMut(&T) -> Option<Span>,
S: FnMut(&T) -> Span,
{
if values.is_empty() {
return;
Expand All @@ -366,8 +364,8 @@ impl<'ast> State<'_, 'ast> {
let first = get_span(&values[0]);
// we can't simply check `peek_comment_before(pos_hi)` cause we would also account for
// comments in the child expression, and those don't matter.
let has_comments = self.peek_comment_before(first.map_or(pos_hi, |s| s.lo())).is_some()
|| self.peek_comment_between(first.map_or(pos_hi, |s| s.hi()), pos_hi).is_some();
let has_comments = self.peek_comment_before(first.lo()).is_some()
|| self.peek_comment_between(first.hi(), pos_hi).is_some();
let is_single_without_cmnts = values.len() == 1 && !format.break_single && !has_comments;

let skip_first_break = if format.with_delimiters || format.is_inline() {
Expand Down Expand Up @@ -399,10 +397,9 @@ impl<'ast> State<'_, 'ast> {
is_single_without_cmnts || !format.with_delimiters || format.is_inline();
for (i, value) in values.iter().enumerate() {
let is_last = i == values.len() - 1;
if let Some(span) = get_span(value)
&& self
.print_comments(span.lo(), CommentConfig::skip_ws().mixed_prev_space())
.is_some_and(|cmnt| cmnt.is_mixed())
if self
.print_comments(get_span(value).lo(), CommentConfig::skip_ws().mixed_prev_space())
.is_some_and(|cmnt| cmnt.is_mixed())
&& format.breaks_cmnts
{
self.hardbreak(); // trailing and isolated comments already hardbreak
Expand All @@ -414,7 +411,7 @@ impl<'ast> State<'_, 'ast> {
self.print_word(",");
}

let next_span = if is_last { None } else { get_span(&values[i + 1]) };
let next_span = if is_last { None } else { Some(get_span(&values[i + 1])) };
let next_pos = next_span.map(Span::lo).unwrap_or(pos_hi);

if !is_last
Expand Down Expand Up @@ -447,7 +444,12 @@ impl<'ast> State<'_, 'ast> {
&& !self.is_bol_or_only_ind()
&& !self.inline_config.is_disabled(next_span)
{
format.print_break(false, values.len(), &mut self.s);
if next_span.is_dummy() && !matches!(format.kind, ListFormatKind::AlwaysBreak) {
// Don't add spaces between uninformed items (commas)
self.zerobreak();
} else {
format.print_break(false, values.len(), &mut self.s);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion crates/fmt/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,9 @@ impl<'sess> State<'sess, '_> {
}
CommentStyle::Isolated => {
let Some(mut prefix) = cmnt.prefix() else { return };
config.hardbreak_if_not_bol(self.is_bol_or_only_ind(), &mut self.s);
if !config.iso_no_break {
config.hardbreak_if_not_bol(self.is_bol_or_only_ind(), &mut self.s);
}

if self.config.wrap_comments {
// Merge and wrap comments
Expand Down
Loading
Loading