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

Cosmetic improvements to comments #58524

Closed
wants to merge 4 commits into from

Conversation

alexreg
Copy link
Contributor

@alexreg alexreg commented Feb 16, 2019

This has been factored out from #58036.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2019
@rust-highfive

This comment has been minimized.

@alexreg
Copy link
Contributor Author

alexreg commented Feb 16, 2019

@matthewjasper I see you got auto-chosen, but please don’t feel obliged to review. (Or maybe just review part, if you're not too averse to it.)

@@ -986,7 +986,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
}
} else {
// Types in signatures.
// FIXME: This is very ineffective. Ideally each HIR type should be converted
// FIXME: this is very ineffective. Ideally, each HIR type should be converted
Copy link
Contributor

Choose a reason for hiding this comment

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

Controversial, please don't change this.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Case after FIXME.)

@@ -369,7 +369,7 @@ impl VisibilityLike for Option<AccessLevel> {
const MAX: Self = Some(AccessLevel::Public);
// Type inference is very smart sometimes.
// It can make an impl reachable even some components of its type or trait are unreachable.
// E.g. methods of `impl ReachableTrait<UnreachableTy> for ReachableTy<UnreachableTy> { ... }`
// E.g., methods of `impl ReachableTrait<UnreachableTy> for ReachableTy<UnreachableTy> { ... }`
Copy link
Contributor

Choose a reason for hiding this comment

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

E.g.,

Another uglification that we shouldn't do IMO.

// but metadata cannot encode gensyms currently, so we create it here.
// This is only a guess, two equivalent idents may incorrectly get different gensyms here.
let ident = ident.gensym_if_underscore();
let def_id = def.def_id();
let expansion = Mark::root(); // FIXME(jseyfried) intercrate hygiene
// FIXME(jseyfried): inter-crate hygiene.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't move trailing comments into separate lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, trailing comments are discouraged in all the codebases I have contributed to, I'll say that much. It decreases readability and is especially problematic when there's a line length cap, I find. It may be worth a brief debate.

@petrochenkov
Copy link
Contributor

petrochenkov commented Feb 17, 2019

Ok, I think I'm personally converged on encouraging @alexreg to stop this activity, which is a waste of everyone's (including alexreg himself) time and disruption for the codebase.
We need to treat PRs like this as we would treat manual formatting PRs.

Everything that can be automated should go into rustfmt, and be performed on each commit/PR when the corresponding infra is up.
Typos are caught by occasional codespell runs.
Drive-by non-automatable changes can be done in code the PR author changes for non-cosmetic reasons.

Personal projects may satisfy the irresistible urge to style code in non-automated ways, if necessary.

EDIT: I'm sufficiently sure that if #58036 and friends are merged, we'll see further similar over 1000 diff PRs, e.g. tweaking variable naming across the codebase to match the author's preferred style, because there are always things to "improve" if you have the right attitude. That's why I think this needs to be nipped in the bud.

EDIT2: Previous comment removed since this wasn't my primary point.

@bors
Copy link
Contributor

bors commented Feb 17, 2019

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

@petrochenkov
Copy link
Contributor

petrochenkov commented Feb 18, 2019

Since I already got involved into this, I'll try to move this into more constructive direction and describe what I think would be an acceptable way to make changes like this.

Adding a Style Rule, The Process

Suppose you want Rust codebase to follow a certain stylistic rule, for example a rule that comments describing functions should use third person verbs (// Builds a thing) rather than imperative (// Build a thing). Here are the steps to follow.

  • Add implementation of the rule to the Style Checker (1).
    The implementation should enforce the style rule automatically, but can perhaps be more conservative than a human would be (90%).
    For example, // VERB would be replaced with // VERBs only for some subset of verbs that can be commonly encountered in comments describing functions (like "builds", "ensures", etc).

  • Open a PR adding description of the rule to the Rustc Guide Page (2).

  • Open a PR applying that single rule to the codebase.

  • ruts-lang/compiler is pinged and the PR enters the waiting-on-team state for ~7 days (something similar to FCPs). ruts-lang/compiler members are free to ignore the PR, leave an approving comment, or leave a disapproving comment.

  • PRs are merged if they have consensus after the "FCP" period (the new style rule is adopted), or not merged otherwise (the new style rule is rejected).

  • Once the rule is approved and merged, the remaining 10% may be applied manually, but improving the Style Checker is preferable.

Components

  1. Style Checker.
    A tool (Python script, tidy rule, rustfmt rule, whatever) that can be run to enforce the Style Rules automatically. It's not necessarily run on CI for a start, and can be run once a week/month/quarter by any interested person, similarly to codespell. It could be integrated into CI in the future.
  2. Rustc Guide Page.
    A page in https://github.com/rust-lang/rustc-guide cataloging the adopted Style Rules.

@petrochenkov
Copy link
Contributor

This PR is not meeting any of the requirements so far - the rules are 1) not described anywhere, 2) not applicable automatically, 3) lumped into a single batch and 4) have controversies.

@alexreg
Copy link
Contributor Author

alexreg commented Feb 18, 2019

@petrochenkov Thanks for trying to be more constructive with your feedback regarding this all. I think going forwards that makes a lot of sense. However, because of the way I worked on this PR, the changes are all mixed together a bit much and very hard to separate either mechanically or by hand. I think that unless there are changes in this PR that are particularly controversial, and exhibit styles that don't already exist in the codebase, they should be permitted for the sake of getting the uncontroversial and universally beneficial aspects of this PR merged. Would appreciate thoughts on this however.

@petrochenkov
Copy link
Contributor

@alexreg
I'm quite strongly against landing this as is, because that would mean encouraging waste of time and bad practices.
Non-controversial parts of the PR are not bug fixes or features, they are low-benefit stylistic changes and cannot counterbalance that.

because of the way I worked on this PR, the changes are all mixed together a bit much and very hard to separate either mechanically or by hand

This is unfortunate, but sunk cost is not a good base for making decisions.
The way this was worked on is exactly the reason why I don't want this merged.
This problem would not exist if the changes were automated, then you could simply rerun the checker and submit PRs proposing individual style rules.

I think that unless there are changes in this PR that are particularly controversial

The changes I mentioned in the inline comments are controversial.
We could discuss details in individual PRs proposing style rules for them.

@petrochenkov
Copy link
Contributor

I'm going to nominate this to discuss the proposed process (#58524 (comment)) on Thursday and hopefully close this question.

@petrochenkov petrochenkov added I-nominated S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 19, 2019
@petrochenkov petrochenkov added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed I-nominated S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 23, 2019
@petrochenkov
Copy link
Contributor

Blocked on #58619

@petrochenkov
Copy link
Contributor

Closing as decided in #58619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants