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

emit the suspicious_auto_trait_impls for negative impls as well #108804

Closed
lcnr opened this issue Mar 6, 2023 · 1 comment · Fixed by #108807
Closed

emit the suspicious_auto_trait_impls for negative impls as well #108804

lcnr opened this issue Mar 6, 2023 · 1 comment · Fixed by #108807
Assignees
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Mar 6, 2023

#![feature(negative_impls)]

struct Foo<T, U>(T, U);
impl<T> !Send for Foo<T, T> {}

struct Bar<T, U>(T, U);
unsafe impl<T> Send for Bar<T, T> {}

results in the following:

warning: cross-crate traits with a default impl, like `Send`, should not be specialized
 --> src/lib.rs:7:1
  |
7 | unsafe impl<T> Send for Bar<T, T> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this will change its meaning in a future release!
  = note: for more information, [see issue #93367 <https://github.com/rust-lang/rust/issues/93367>](https://github.com/rust-lang/rust/issues/93367)
  = note: `T` is mentioned multiple times
note: try using the same sequence of generic parameters as the struct definition
 --> src/lib.rs:6:1
  |
6 | struct Bar<T, U>(T, U);
  | ^^^^^^^^^^^^^^^^
  = note: `#[warn(suspicious_auto_trait_impls)]` on by default

the lint should also be emitted for the negative impl. The lint was implemented in #93267. To fix that remove the following line and add a test:

if tcx.impl_polarity(impl_def_id) != ImplPolarity::Positive {
return;
}

@lcnr lcnr added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Mar 6, 2023
@mu001999
Copy link
Contributor

mu001999 commented Mar 6, 2023

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 6, 2023
…t_impls, r=lcnr

Emit the suspicious_auto_trait_impls for negative impls as well

Fixes rust-lang#108804
@bors bors closed this as completed in 3279f7e Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants