Rollup merge of #35355 - shri3k:E0046, r=jonathandturner
Updates compiler error E0046 with new format Addresses #35209 as part of #35233. r? @jonathandturner I've repeated the following in my code. If this is something not desirable then let me know if there's any process to make this any cleaner. Thank you. ```rust missing_items.iter() .map(|name| name.to_string()) .collect::<Vec<_>>().join("`, `")) ```
This commit is contained in:
commit
0b567c68da
6 changed files with 18 additions and 5 deletions
|
@ -1136,11 +1136,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !missing_items.is_empty() {
|
if !missing_items.is_empty() {
|
||||||
span_err!(tcx.sess, impl_span, E0046,
|
struct_span_err!(tcx.sess, impl_span, E0046,
|
||||||
"not all trait items implemented, missing: `{}`",
|
"not all trait items implemented, missing: `{}`",
|
||||||
missing_items.iter()
|
missing_items.iter()
|
||||||
.map(|name| name.to_string())
|
.map(|name| name.to_string())
|
||||||
.collect::<Vec<_>>().join("`, `"))
|
.collect::<Vec<_>>().join("`, `"))
|
||||||
|
.span_label(impl_span, &format!("missing `{}` in implementation",
|
||||||
|
missing_items.iter()
|
||||||
|
.map(|name| name.to_string())
|
||||||
|
.collect::<Vec<_>>().join("`, `"))
|
||||||
|
).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !invalidated_items.is_empty() {
|
if !invalidated_items.is_empty() {
|
||||||
|
|
|
@ -14,7 +14,9 @@ trait Foo {
|
||||||
|
|
||||||
struct Bar;
|
struct Bar;
|
||||||
|
|
||||||
impl Foo for Bar {} //~ ERROR E0046
|
impl Foo for Bar {}
|
||||||
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `foo` in implementation
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub struct FooConstForMethod;
|
||||||
|
|
||||||
impl Foo for FooConstForMethod {
|
impl Foo for FooConstForMethod {
|
||||||
//~^ ERROR E0046
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `bar` in implementation
|
||||||
const bar: u64 = 1;
|
const bar: u64 = 1;
|
||||||
//~^ ERROR E0323
|
//~^ ERROR E0323
|
||||||
//~| NOTE does not match trait
|
//~| NOTE does not match trait
|
||||||
|
@ -31,6 +32,7 @@ pub struct FooMethodForConst;
|
||||||
|
|
||||||
impl Foo for FooMethodForConst {
|
impl Foo for FooMethodForConst {
|
||||||
//~^ ERROR E0046
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `MY_CONST` in implementation
|
||||||
fn bar(&self) {}
|
fn bar(&self) {}
|
||||||
fn MY_CONST() {}
|
fn MY_CONST() {}
|
||||||
//~^ ERROR E0324
|
//~^ ERROR E0324
|
||||||
|
@ -41,6 +43,7 @@ pub struct FooTypeForMethod;
|
||||||
|
|
||||||
impl Foo for FooTypeForMethod {
|
impl Foo for FooTypeForMethod {
|
||||||
//~^ ERROR E0046
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `bar` in implementation
|
||||||
type bar = u64;
|
type bar = u64;
|
||||||
//~^ ERROR E0325
|
//~^ ERROR E0325
|
||||||
//~| NOTE does not match trait
|
//~| NOTE does not match trait
|
||||||
|
|
|
@ -18,7 +18,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for Recurrence {
|
impl Iterator for Recurrence {
|
||||||
//~^ ERROR not all trait items implemented, missing: `Item` [E0046]
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `Item` in implementation
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<u64> {
|
fn next(&mut self) -> Option<u64> {
|
||||||
if self.pos < 2 {
|
if self.pos < 2 {
|
||||||
|
|
|
@ -34,7 +34,8 @@ impl<C: Component> FnMut<(C,)> for Prototype {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: Component> FnOnce<(C,)> for Prototype {
|
impl<C: Component> FnOnce<(C,)> for Prototype {
|
||||||
//~^ ERROR not all trait items implemented, missing: `Output` [E0046]
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `Output` in implementation
|
||||||
extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
|
extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
|
||||||
Fn::call(&self, (comp,))
|
Fn::call(&self, (comp,))
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ fn main() {
|
||||||
|
|
||||||
// Causes ICE
|
// Causes ICE
|
||||||
impl Deref for Thing {
|
impl Deref for Thing {
|
||||||
//~^ ERROR not all trait items implemented, missing: `Target` [E0046]
|
//~^ ERROR E0046
|
||||||
|
//~| NOTE missing `Target` in implementation
|
||||||
fn deref(&self) -> i8 { self.0 }
|
fn deref(&self) -> i8 { self.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue