Skip to content

Rust: a parameter default containing /* (e.g. "src/**/*.rs") leaves the default-value comment unterminated, so rustc fails with E0758 #384

Closed

Description

@matt-edmondson

What's wrong

C, Go and Rust have no default arguments, so StandardLanguageGenerator.AppendDefaultValueComment (Coder/Languages/StandardLanguageGenerator.cs, around L1599-L1610) writes the default into a block comment: /* = <value> */. It breaks */ apart (Replace("*/", "* /")) so the comment cannot close early. That is enough for C and Go.

Rust block comments nest, though. A /* inside one opens a nested comment, and rustc does not recognise string literals inside comments. So a default whose spelling contains /* leaves the comment unterminated, and rustc rejects the whole file.

Breaking */ apart can itself create a /*: "src/**/*.rs" becomes "src/** /*.rs".

Repro

Take a FunctionDeclaration find(pattern: string = "src/**/*.rs") -> int { return 1 }, with DefaultValue = new LiteralExpression<string>("src/**/*.rs") and IsOptional = true.

The Rust output is:

pub fn find(pattern: String /* = "src/** /*.rs" */) -> i32 {

rustc (edition 2021) reports error[E0758]: unterminated block comment. A default of "/*" alone fails the same way. Glob and path defaults such as "**/*.cs" or "src/*" are realistic inputs. Go and C compile the same text, because their comments do not nest.

Suggested fix / acceptance criteria

  • In the Rust path, also break /* apart (for example / *), or let each generator override how the comment text is sanitised. A line comment is not an option here, because the default sits inside the parameter list.
  • Add Rust compile-test cases (alongside the existing real-toolchain tests) for a string default containing /* and one containing */.

Activity

  1. added
    bug
    on Oct 30, 2026
  2. matt-edmondson commented on Oct 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

  3. added a commit that references this issue on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions