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

fix: between span derivation on cast exprs #4536

Merged

Conversation

calebcartwright
Copy link
Member

Fixes #4534

@@ -236,10 +236,10 @@ pub(crate) fn format_expr(
/* Retrieving the comments before and after cast */
let prefix_span = mk_sp(
subexpr.span.hi(),
context.snippet_provider.span_before(expr.span, "as"),
context.snippet_provider.span_before_last(expr.span, "as") - BytePos(1),
Copy link
Member Author

Choose a reason for hiding this comment

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

Think there's a separate bug in this util function that only backs the position off by one, but feels like it should be the length of the needle. Our needle is the as keyword, so moving it back by one to avoid snagging the a in the keyword

@calebcartwright calebcartwright changed the title fix: between span derviation on cast exprs fix: between span derivation on cast exprs Nov 19, 2020
@calebcartwright calebcartwright merged commit 30bda45 into rust-lang:master Nov 19, 2020
@calebcartwright calebcartwright deleted the fix-cast-expr-comment-span branch November 19, 2020 03:24
@ytmimi ytmimi mentioned this pull request Apr 3, 2022
@ytmimi ytmimi added 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release and removed backport-triage labels Apr 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustfmt regression: produces duplicated subexpressions and unparseable output involving as casts
3 participants