Skip to content

codegen: Make comments indentation-aware. #799

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

Merged
merged 2 commits into from
Jul 10, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Jul 8, 2017

This commit moves comment processing to a central place (well, two, because of
field docs, but that's fine).

Also, it makes comments indentation aware, so multiline comments don't appear
garbled.

Finally, it also fixes an out-of-bounds panic when processing an empty multiline
comment.

@highfive
Copy link

highfive commented Jul 8, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@emilio
Copy link
Contributor Author

emilio commented Jul 8, 2017

r? @fitzgen

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

r=me with a couple nitpicks below

Thanks!

src/ir/item.rs Outdated
ctx.options().conservative_inline_namespaces
})
})
.fold(1, |i, _| i + 1)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this fold just <iterator>.count() + 1? Better not to make readers verify that the fold is just counting, when there's a std method for counting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved code around, but sure :)

"/// hello\n/// world\n/// foo");

assert_eq!(preprocess("/**\nhello\n*world\n*foo\n*/".to_owned()),
assert_eq!(preprocess("/**\nhello\n*world\n*foo\n*/", 0),
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have a unit test with nonzero indent for comment preprocessing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a super-fan of unit tests, but will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(err, for stuff that can be integration-tested, I mean)

emilio added 2 commits July 10, 2017 23:16
This commit moves comment processing to a central place (well, two, because of
field docs, but that's fine).

Also, it makes comments indentation aware, so multiline comments don't appear
garbled.

Finally, it also fixes an out-of-bounds panic when processing an empty multiline
comment.
@emilio
Copy link
Contributor Author

emilio commented Jul 10, 2017

@bors-servo r=fitzgen

@bors-servo
Copy link

📌 Commit 96304f9 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit 96304f9 with merge a00db04...

bors-servo pushed a commit that referenced this pull request Jul 10, 2017
codegen: Make comments indentation-aware.

This commit moves comment processing to a central place (well, two, because of
field docs, but that's fine).

Also, it makes comments indentation aware, so multiline comments don't appear
garbled.

Finally, it also fixes an out-of-bounds panic when processing an empty multiline
comment.
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing a00db04 to master...

@bors-servo bors-servo merged commit 96304f9 into rust-lang:master Jul 10, 2017
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.

4 participants