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

fix: avoid adding enum parens in use path #12473

Merged
merged 1 commit into from Jun 10, 2022

Conversation

yue4u
Copy link
Contributor

@yue4u yue4u commented Jun 5, 2022

close #12420

Comment on lines +54 to +61
let should_add_parens = match completion.path_context() {
Some(PathCompletionCtx { has_call_parens: true, .. }) => false,
Some(PathCompletionCtx { kind: PathKind::Use | PathKind::Type { .. }, .. }) => {
cov_mark::hit!(no_parens_in_use_item);
false
}
_ => true,
};
Copy link
Contributor Author

@yue4u yue4u Jun 5, 2022

Choose a reason for hiding this comment

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

This is similar to

match ctx.path_context() {
Some(PathCompletionCtx { kind: PathKind::Expr { .. }, has_call_parens: true, .. }) => {
return false
}
Some(PathCompletionCtx { kind: PathKind::Use | PathKind::Type { .. }, .. }) => {
cov_mark::hit!(no_parens_in_use_item);
return false;
}
_ => {}
};
but that one limits has_call_parens: true to PathKind::Expr

Comment on lines +91 to +95
// only show name in label if not adding parens
if !should_add_parens {
kind = StructKind::Unit;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels strange to me when completion labels still have parens

@Veykril
Copy link
Member

Veykril commented Jun 10, 2022

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Jun 10, 2022

📌 Commit 11693da has been approved by Veykril

@bors
Copy link
Collaborator

bors commented Jun 10, 2022

⌛ Testing commit 11693da with merge 0bbead9...

@bors
Copy link
Collaborator

bors commented Jun 10, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 0bbead9 to master...

@bors bors merged commit 0bbead9 into rust-lang:master Jun 10, 2022
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.

Variant completions in use paths add parentheses and braces
3 participants