Closed
Description
I tried this code on nightly:
#![feature(negative_impls)]
use std::rc::Rc;
struct Foo {
rc: Rc<u32>,
}
impl !Copy for Foo { }
fn main() {
println!("Hello, world!");
}
I expected to see this happen: the code should compile successfully, or print a better diagnostic
Instead, this happened: The following compile error:
Compiling playground v0.0.1 (/playground)
error[[E0204]](https://doc.rust-lang.org/nightly/error-index.html#E0204): the trait `Copy` may not be implemented for this type
--> src/main.rs:9:7
|
6 | rc: Rc<u32>,
| ----------- this field does not implement `Copy`
...
9 | impl !Copy for Foo { }
| ^^^^
For more information about this error, try `rustc --explain E0204`.
error: could not compile `playground` due to previous error
I think this is a bug, and that the code ought to compile.
If not, then at the very least, the error message could be improved.
Currently, the error message explains why rustc is not able to implement Copy
. But of course, I am trying to implement !Copy
, as a declaration that Copy
should not or will not ever be implemented for Foo
. So I expect the error message should explain why I cannot implement !Copy
.
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=546c5fb5b177ac8a111ff2c9bceec503