Skip to content

refactor(parse): separate self parameter parsing from general parameter parsing #145088

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xonx4l
Copy link
Contributor

@xonx4l xonx4l commented Aug 8, 2025

Fixes #144206

The changes-:
Moves self parameter parsing out of parse_param_general and into parse_fn_params
for better separation of concerns. This removes the first_param boolean and its
branching logic while maintaining identical behavior.

Benefits:

  • Cleaner separation of concerns
  • Improved readability and testability
  • More maintainable code structure

No behavioral changes introduced.

@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2025
@rust-log-analyzer

This comment has been minimized.

params.push(self_param);
}

let (mut reamining_params, _) = self.parse_paren_comma_seq(|p| {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/reamining_params/remaining_params/

@nnethercote
Copy link
Contributor

Please fix the errors, thanks!

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 9, 2025
@rust-log-analyzer

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Aug 9, 2025

(please also squash into one commit afterwards, thanks)

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
[TIMING] core::build_steps::tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 11.561
[TIMING] core::build_steps::tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/compiler/rustc_parse/src/parser/item.rs:2958:
                 .emit_err(errors::MissingFnParams { span: self.prev_token.span.shrink_to_hi() });
             return Ok(ThinVec::new());
         }
-        
+
         let mut params = ThinVec::new();
 
         //Parse the self parameter as first parameter
Diff in /checkout/compiler/rustc_parse/src/parser/item.rs:2965:
-        if let Some(mut self_param) = self.parse_self_param()?{
+        if let Some(mut self_param) = self.parse_self_param()? {
             let self_attrs = self.parse_outer_attributes()?;
             self_param.attrs = self.attrs;
             params.push(self_param);
Diff in /checkout/compiler/rustc_parse/src/parser/item.rs:2969:
-        }    
+        }
 
         let (mut remaining_params, _) = self.parse_paren_comma_seq(|p| {
             p.recover_vcs_conflict_marker();
fmt: checked 6299 files
Build completed unsuccessfully in 0:00:49
  local time: Mon Aug 11 10:47:35 UTC 2025
  network time: Mon, 11 Aug 2025 10:47:35 GMT
##[error]Process completed with exit code 1.

@xonx4l
Copy link
Contributor Author

xonx4l commented Aug 13, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2025

let (mut params, _) = self.parse_paren_comma_seq(|p| {
//Parse the self parameter as first parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//Parse the self parameter as first parameter
// Parse the self parameter as first parameter


let (mut params, _) = self.parse_paren_comma_seq(|p| {
//Parse the self parameter as first parameter
if let Some(mut self_param) = self.parse_self_param()?{
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if let Some(mut self_param) = self.parse_self_param()?{
if let Some(mut self_param) = self.parse_self_param()? {

let (mut params, _) = self.parse_paren_comma_seq(|p| {
//Parse the self parameter as first parameter
if let Some(mut self_param) = self.parse_self_param()?{
let self_attrs = self.parse_outer_attributes()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Having the parse_outer_attributes after the parse_self_param is suspicious.

@nnethercote
Copy link
Contributor

Still more CI failures to be fixed.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2025
@bors
Copy link
Collaborator

bors commented Aug 15, 2025

☔ The latest upstream changes (presumably #145423) made this pull request unmergeable. Please resolve the merge conflicts.

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.

Refactor: Split self-param logic from parse_param_general
6 participants