close
Skip to content

fix issue-144595#155375

Draft
bb1yd wants to merge 2 commits intorust-lang:mainfrom
bb1yd:issue-144595
Draft

fix issue-144595#155375
bb1yd wants to merge 2 commits intorust-lang:mainfrom
bb1yd:issue-144595

Conversation

@bb1yd
Copy link
Copy Markdown
Contributor

@bb1yd bb1yd commented Apr 16, 2026

relevant issue:#144595
I implement this issue by simply find every colon in the tuple struct.

This method has a problem that it might mislead the user when the user type something likestruct Foo(std::string:String); (accidentally type :: as :). The compiler will print:

help: if you wanted to create a tuple struct, remove field names:
 --> test.rs:3:21
  |
3 |     struct Foo(std::string:String);
  |                     -------

I'm not sure if this is acceptable. Maybe a better way is to parse the field as a record struct field again, but I don't know how to revert the parser to the beginning of the tuple field.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 16, 2026
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustc_parse v0.0.0 (/checkout/compiler/rustc_parse)
error: this if-then-else expression returns a bool literal
    --> compiler/rustc_parse/src/parser/item.rs:2146:21
     |
2146 | /                     if t.kind == token::Colon || t.kind == token::Comma {
2147 | |                         false
2148 | |                     } else {
2149 | |                         true
2150 | |                     }
     | |_____________________^ help: you can reduce it to: `!(t.kind == token::Colon || t.kind == token::Comma)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool
     = note: requested on the command line with `-D clippy::needless-bool`

[RUSTC-TIMING] rustc_parse test:false 3.730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants