-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.F-negative_impls#![feature(negative_impls)]#![feature(negative_impls)]T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#![allow(unused)]
#![feature(negative_impls)]
trait MyTrait {}
#[derive(Clone)]
struct MyString {
string: String,
}
impl<T: Copy> !MyTrait for T { }
// Works
impl MyTrait for MyString { }
// Throws error but it should work
impl MyTrait for String { }
fn main() {
}rustc --version --verbose:
rustc 1.85.0-nightly (5f23ef7d3 2024-12-20)
binary: rustc
commit-hash: 5f23ef7d3f7a8c3e0ca5c4e1978829c0448a3686
commit-date: 2024-12-20
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6
Error output
error[E0751]: found both positive and negative implementation of trait `MyTrait` for type `String`:
--> src/main.rs:16:1
|
11 | impl<T: Copy> !MyTrait for T { }
| ---------------------------- negative implementation here
...
16 | impl MyTrait for String { }
| ^^^^^^^^^^^^^^^^^^^^^^^ positive implementation here
Metadata
Metadata
Assignees
Labels
A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.F-negative_impls#![feature(negative_impls)]#![feature(negative_impls)]T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.