Repository navigation
Do not suggest deriving Clone on foreign types in noop_method_call - #165420
Conversation
|
r? @mejrs rustbot has assigned @mejrs. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| 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() => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Not that I can find. can_suggest_derive and suggest_derive have the same limit, they also check is_local(), so this matches them.
| //@ check-pass | ||
| //@ aux-build:noop-method-call-foreign.rs |
There was a problem hiding this comment.
| //@ 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.
There was a problem hiding this comment.
Thanks, added. I used derive(Clone) instead of implement cause the note says "does not implement Clone"
7ac6d92 to
e8e297e
Compare
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)
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