Closed
Description
(Spotted in https://users.rust-lang.org/t/the-trait-clone-is-not-implemented-for-mut-t/51989?u=scottmcm)
I tried this code https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6c22f56bb7cfec1e8e04a79fc078cdd6:
#![feature(negative_impls)]
trait Foo {
fn foo(&self) {}
}
impl Foo for u64 {}
impl !Foo for i32 {}
fn main() {
let x = 4_i32;
x.foo();
}
Which of course fails to compile. And it gives the following:
error[E0599]: no method named `foo` found for type `i32` in the current scope
--> src/main.rs:12:7
|
12 | x.foo();
| ^^^ method not found in `i32`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `Foo` defines an item `foo`, perhaps you need to implement it
--> src/main.rs:3:1
|
3 | trait Foo {
| ^^^^^^^^^
It would be nice to take advantage of the negative implementation to not say "perhaps you need to implement it" and in fact to say that it explicitly is not implemented. Other good similar cases would be things like Foo::foo(&x)
.
(This is a follow-up issue to #79458, as the bug part was fixed, so this is the lower-priority improvement part.)
cc #68318