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 naming in the lint API #120017

Merged
merged 11 commits into from
Jan 23, 2024
Merged

Fix naming in the lint API #120017

merged 11 commits into from
Jan 23, 2024

Conversation

nnethercote
Copy link
Contributor

Methods for emit lints are named very inconsistently. This PR fixes that up.

r? @compiler-errors

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 16, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2024

Some changes might have occurred in exhaustiveness checking

cc @Nadrieril

rustc_macros::diagnostics was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes might have occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@nnethercote
Copy link
Contributor Author

nnethercote commented Jan 16, 2024

Here is the table I worked from.

old name               args                                     new name
------                 -----------------------------------      --------
LintContext
- lint                 lint,               msg, decorate        // lint (unchanged)
- struct_span_lint     lint,         span, msg, decorate        // span_lint
- lookup_with_diags    lint,         span, msg, decorate, diags // span_lint_with_diags
- lookup               lint,     opt_span, msg, decorate        // opt_span_lint
- emit_lint            lint,                    decorator       // emit_lint (unchanged)
- emit_spanned_lint    lint,         span,      decorator       // emit_span_lint

LintLevelsBuilder (missing plain `lint`)
- struct_lint          lint,     opt_span, msg, decorate        // opt_span_lint
- emit_lint            lint,                    decorator       // emit_lint (unchanged)
- emit_spanned_lint    lint,         span,      decorator       // emit_span_lint

TyCtxt
- struct_lint_node     lint, hir_id,       msg, decorate        // node_lint
- struct_span_lint_hir lint, hir_id, span, msg, decorate        // node_span_lint
- emit_lint            lint, hir_id,            decorator       // emit_node_lint
- emit_spanned_lint    lint, hir_id, span,      decorator       // emit_node_span_lint

(top-level)
- struct_lint_level    lint,lvl,src, span, msg, decorate        // lint_level

Improvements:

  • Remove misleading struct_ prefixes. These functions don't return
    diagnostics, they emit!
  • Use span instead of spanned, for consistency with normal diagnostics.
  • Retain emit_ prefix for newer cases using decorator: DecorateLint, and
    use no prefix for older cases using decorate, similar to how it's done for
    normal diagnostics.
  • Use node consistently for the TyCtxt ones, not a mix of node and hir.
  • Replace lookup, which is so vague that it's meaningless.
  • Make the equivalent functions across the different types have the same name.

Now I can look at a method name and have a pretty good chance of understanding how to use it. That was not the case before!

@oli-obk
Copy link
Contributor

oli-obk commented Jan 16, 2024

the node part of the TyCtxt methods seems not useful to me. We could just leave it off, even if it then has the same name as LintContext methods.

@nnethercote
Copy link
Contributor Author

We could just leave it off, even if it then has the same name as LintContext methods.

That's exactly why I want a different name, because it has an extra argument. Different signature, different name.

@bors
Copy link
Contributor

bors commented Jan 16, 2024

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

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me after rebasing

@compiler-errors compiler-errors 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 Jan 22, 2024
@nnethercote
Copy link
Contributor Author

I rebased.

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jan 22, 2024

📌 Commit 0a03a9f has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 22, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 22, 2024
…rrors

Fix naming in the lint API

Methods for emit lints are named very inconsistently. This PR fixes that up.

r? `@compiler-errors`
@oli-obk
Copy link
Contributor

oli-obk commented Jan 22, 2024

@bors r- conflicts

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 22, 2024
@nnethercote
Copy link
Contributor Author

I rebased again. Bumping priority because this is conflict-prone.

@bors r=oli-obk p=1

@bors
Copy link
Contributor

bors commented Jan 22, 2024

📌 Commit 15a4c4f has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 22, 2024
@bors
Copy link
Contributor

bors commented Jan 23, 2024

⌛ Testing commit 15a4c4f with merge 0011fac...

@bors
Copy link
Contributor

bors commented Jan 23, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 0011fac to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 23, 2024
@bors bors merged commit 0011fac into rust-lang:master Jan 23, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 23, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0011fac): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.8% [2.5%, 3.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [2.5%, 3.0%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 663.509s -> 662.56s (-0.14%)
Artifact size: 308.32 MiB -> 308.33 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants