Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 7 additions & 10 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ impl Rewrite for ast::Local {
return Err(RewriteError::SkipFormatting);
}

// FIXME(super_let): Implement formatting
if self.super_.is_some() {
return Err(RewriteError::SkipFormatting);
}

let super_ = self.super_.is_some();
// FIXME: deletes any comments in between super and let
let let_ = if super_ { "super let " } else { "let " };
Comment on lines +68 to +70

@ytmimi ytmimi Jun 26, 2026

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.

not something we need to resolve now, but if the user wrote super /* comment */ let, then this reformatting would completely remove the comment. Might be worth adding a FIXME comment for the potential comment loss.

View changes since the review

let attrs_str = self.attrs.rewrite_result(context, shape)?;
let mut result = if attrs_str.is_empty() {
"let ".to_owned()
let_.to_owned()
} else {
combine_strs_with_missing_comments(
context,
&attrs_str,
"let ",
let_,
mk_sp(
self.attrs.last().map(|a| a.span.hi()).unwrap(),
self.span.lo(),
Expand All @@ -86,10 +84,9 @@ impl Rewrite for ast::Local {
false,
)?
};
let let_kw_offset = result.len() - "let ".len();
let let_kw_offset = result.len() - let_.len();

// 4 = "let ".len()
let pat_shape = shape.offset_left(4, self.span())?;
let pat_shape = shape.offset_left(let_.len(), self.span())?;
// 1 = ;
let pat_shape = pat_shape.sub_width(1, self.span())?;
let pat_str = self.pat.rewrite_result(context, pat_shape)?;
Expand Down
7 changes: 7 additions & 0 deletions tests/source/super_let.rs

@ytmimi ytmimi Jun 26, 2026

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.

Let's add a #![feature(super_let)] annotation here so that it's easier for us to tell that this is for an unstable feature.

View changes since the review

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(super_let)]
fn main() {
super let x =(
&1,

) else { 3};
}
4 changes: 4 additions & 0 deletions tests/target/super_let.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(super_let)]
fn main() {
super let x = (&1,) else { 3 };
}
Loading