Skip to content

Use a dummy TypeckResults instead of Option<TypeckResults> when linting#158000

Open
Jarcho wants to merge 6 commits into
rust-lang:mainfrom
Jarcho:ownerless_typeck
Open

Use a dummy TypeckResults instead of Option<TypeckResults> when linting#158000
Jarcho wants to merge 6 commits into
rust-lang:mainfrom
Jarcho:ownerless_typeck

Conversation

@Jarcho

@Jarcho Jarcho commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Based on #157928

This brings the typeck results when linting back to what it was before #73743. The first four commits are from the first PR and handle eagerly fetching the typeck results and the workaround needed for rustdoc. The fifth commit adds a dummy ownerless typeck results and uses that as the initial value for the lint pass. The final commit just removes the now useless typeck_results method.

The dummy table is added to the global context more for convenience. It can't be a static since the lifetime argument is invariant. It could be created just for the linting, but that would need to add an extra lifetime parameter to LateContext and a lot of places downstream of that which would be a huge pain.

@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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 Jun 17, 2026
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling rustc_lint v0.0.0 (/checkout/compiler/rustc_lint)
error[E0599]: no method named `typeck_results` found for reference `&LateContext<'tcx>` in the current scope
   --> compiler/rustc_lint/src/noop_method_call.rs:149:41
    |
149 |             let unadjusted_expr_ty = cx.typeck_results().expr_ty(expr);
    |                                         ^^^^^^^^^^^^^^ field, not a method
    |
help: remove the arguments
    |
149 -             let unadjusted_expr_ty = cx.typeck_results().expr_ty(expr);
149 +             let unadjusted_expr_ty = cx.typeck_results.expr_ty(expr);
    |
help: there is a method `to_result` with a similar name
    |
149 -             let unadjusted_expr_ty = cx.typeck_results().expr_ty(expr);
149 +             let unadjusted_expr_ty = cx.to_result().expr_ty(expr);
    |

For more information about this error, try `rustc --explain E0599`.
[RUSTC-TIMING] rustc_lint test:false 3.257
error: could not compile `rustc_lint` (lib) due to 1 previous error

@folkertdev

Copy link
Copy Markdown
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jun 17, 2026
@rustbot rustbot assigned nikomatsakis and unassigned folkertdev Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants