Skip to content

Invalid lifetime syntax in "conflicting implementation" error message #54690

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
dtolnay opened this issue Sep 30, 2018 · 2 comments
Closed

Invalid lifetime syntax in "conflicting implementation" error message #54690

dtolnay opened this issue Sep 30, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 30, 2018

I noticed error output like the following in the ui tests of #54687.

error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`:
  --> $DIR/coherence-impls-copy.rs:41:1
   |
   | impl Copy for &'static NotSync {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: conflicting implementation in crate `core`:
           - impl<'_, T> std::marker::Copy for &T
             where T: ?Sized;

The impl<'_, T> is not valid syntax. The error message should use impl<T>.

@dtolnay dtolnay added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Sep 30, 2018
@scottmcm
Copy link
Member

In case it helps, this doesn't seem to happen inside a single module:

trait Trait {}
impl Trait for &() {}
impl Trait for &'static () {}
error[E0119]: conflicting implementations of trait `Trait` for type `&()`:
 --> src/lib.rs:3:1
  |
2 | impl Trait for &() {}
  | ------------------ first implementation here
3 | impl Trait for &'static () {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&()`

Also, cc the impl_header_lifetime_elision tracking issue: #15872

@scottmcm
Copy link
Member

Look like this affects rustdoc too:

impl<'_, T> Borrow<T> for &'_ T 

https://doc.rust-lang.org/nightly/std/borrow/trait.Borrow.html#impl-Borrow%3CT%3E

kennytm added a commit to kennytm/rust that referenced this issue Nov 8, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Nov 9, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants