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

Attribute.Custom.render() is stripping comment line chars // #1465

Closed
crisidev opened this issue Jun 14, 2022 · 2 comments · Fixed by #1467
Closed

Attribute.Custom.render() is stripping comment line chars // #1465

crisidev opened this issue Jun 14, 2022 · 2 comments · Fixed by #1467

Comments

@crisidev
Copy link
Contributor

I am facing a weird issue with the Attribute class:

I am trying to render a Custom attribute before structures and enums and if there is a comment line rendered just after my call to Attribute.Custom.render(), the // is eaten away.

I have tracked it down to this line of code: https://github.com/awslabs/smithy-rs/blob/15e1b3425f56ff2606121e99dff11de38424c744/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/RustTypes.kt#L377

If I change the line from writer.raw("#$bang[$annotation]") to writer.rust("##$bang[$annotation]") it start rendering as I would expect, but I am not sure of the implications of changing this line of code.

@crisidev
Copy link
Contributor Author

@david-perez pointed out it'd fail if bang or annotation contains # but it looks like it shouldn't be possible: https://doc.rust-lang.org/reference/attributes.html

@rcoh
Copy link
Collaborator

rcoh commented Jun 15, 2022

so the relevant difference here is that raw uses writeInline and rust uses write. docs then uses newlinePrefix to set ///.

So when the writer isn't on a newline, that get suppressed. Let me see if I can make a fix

rcoh added a commit that referenced this issue Jun 15, 2022
rcoh added a commit that referenced this issue Jun 15, 2022
rcoh added a commit that referenced this issue Jun 15, 2022
Velfi pushed a commit that referenced this issue Jun 15, 2022
* Fixes for RustWriter bugs #1465 & #1459

* Fix behavior causing extra newlines in docs
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 a pull request may close this issue.

2 participants