Skip to content

Do not suggest deriving Clone on foreign types in noop_method_call - #165420

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zakrad:noop-derive-non-local
Nov 9, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zakrad:noop-derive-non-local

Conversation

@zakrad

@zakrad zakrad commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #134471

Only suggest the derive for local types. The test uses an aux crate because UI tests hide suggestions that point into std #131782

@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 Nov 3, 2026
@rustbot

rustbot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 77 candidates
  • Random selection from 22 candidates

if receiver_ty == expr_ty {
let suggest_derive = match orig_ty.kind() {
ty::Adt(def, _) => Some(cx.tcx.def_span(def.did()).shrink_to_lo()),
ty::Adt(def, _) if def.did().is_local() => {

@wesleywiser wesleywiser Nov 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems unfortunate that we'll stop offering this suggestion for code in another crate in the same workspace. Do we have a way to detect in the compiler if the code is defined in a non-workspace dependency crate?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not that I can find. can_suggest_derive and suggest_derive have the same limit, they also check is_local(), so this matches them.

Comment on lines +6 to +7
//@ check-pass
//@ aux-build:noop-method-call-foreign.rs

@mejrs mejrs Nov 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
//@ check-pass
//@ aux-build:noop-method-call-foreign.rs
//@ check-pass
//@ aux-build:noop-method-call-foreign.rs
//@forbid-output:implement

Otherwise this test is a bit fragile, one could mess up in the compiler and simply bless the difference.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, added. I used derive(Clone) instead of implement cause the note says "does not implement Clone"

@zakrad
zakrad force-pushed the noop-derive-non-local branch from 7ac6d92 to e8e297e Compare November 8, 2026 22:40

@mejrs mejrs left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rust-bors

rust-bors Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e8e297e has been tentatively approved by mejrs

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
Rollup of 3 pull requests

Successful merges:

 - #164990 (declare_tool_lint: allow use without `default_field_values` feature)
 - #165420 (Do not suggest deriving Clone on foreign types in noop_method_call)
 - #165640 (Avoid Terminator:None in coroutine transform)
@rust-bors
rust-bors Bot merged commit 6604900 into rust-lang:main Nov 9, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 9, 2026
Rollup merge of #165420 - zakrad:noop-derive-non-local, r=mejrs

Do not suggest deriving Clone on foreign types in noop_method_call

Fixes #134471

Only suggest the derive for local types. The test uses an aux crate because UI tests hide suggestions that point into std #131782
@zakrad
zakrad deleted the noop-derive-non-local branch November 9, 2026 07:14
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Nov 10, 2026
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#164990 (declare_tool_lint: allow use without `default_field_values` feature)
 - rust-lang/rust#165420 (Do not suggest deriving Clone on foreign types in noop_method_call)
 - rust-lang/rust#165640 (Avoid Terminator:None in coroutine transform)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect suggestion to derive Clone on Vec directly

4 participants