)],
) {
let mut derives = Vec::<(String, Span, Symbol)>::new();
- let mut traits = Vec::<Span>::new();
+ let mut traits = Vec::new();
for (pred, _, _) in unsatisfied_predicates {
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = pred.kind().skip_binder() else { continue };
let adt = match trait_pred.self_ty().ty_adt_def() {
}
derives.push((self_name, self_span, diagnostic_name));
} else {
- traits.push(self.tcx.def_span(trait_pred.def_id()));
+ traits.push(trait_pred.def_id());
}
} else {
- traits.push(self.tcx.def_span(trait_pred.def_id()));
+ traits.push(trait_pred.def_id());
}
}
traits.sort();
let len = traits.len();
if len > 0 {
- let span: MultiSpan = traits.into();
+ let span =
+ MultiSpan::from_spans(traits.iter().map(|&did| self.tcx.def_span(did)).collect());
+ let mut names = format!("`{}`", self.tcx.def_path_str(traits[0]));
+ for (i, &did) in traits.iter().enumerate().skip(1) {
+ if len > 2 {
+ names.push_str(", ");
+ }
+ if i == len - 1 {
+ names.push_str(" and ");
+ }
+ names.push('`');
+ names.push_str(&self.tcx.def_path_str(did));
+ names.push('`');
+ }
err.span_note(
span,
- &format!("the following trait{} must be implemented", pluralize!(len),),
+ &format!("the trait{} {} must be implemented", pluralize!(len), names),
);
}
|
LL | struct A;
| ^^^^^^^^ must implement `Add<_>`
-note: the following trait must be implemented
+note: the trait `Add` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: cannot subtract `A` from `A`
|
LL | struct A;
| ^^^^^^^^ must implement `Sub<_>`
-note: the following trait must be implemented
+note: the trait `Sub` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: cannot multiply `A` by `A`
|
LL | struct A;
| ^^^^^^^^ must implement `Mul<_>`
-note: the following trait must be implemented
+note: the trait `Mul` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: cannot divide `A` by `A`
|
LL | struct A;
| ^^^^^^^^ must implement `Div<_>`
-note: the following trait must be implemented
+note: the trait `Div` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: cannot mod `A` by `A`
|
LL | struct A;
| ^^^^^^^^ must implement `Rem<_>`
-note: the following trait must be implemented
+note: the trait `Rem` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: no implementation for `A & A`
|
LL | struct A;
| ^^^^^^^^ must implement `BitAnd<_>`
-note: the following trait must be implemented
+note: the trait `BitAnd` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0369]: no implementation for `A | A`
|
LL | struct A;
| ^^^^^^^^ must implement `BitOr<_>`
-note: the following trait must be implemented
+note: the trait `BitOr` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0369]: no implementation for `A << A`
|
LL | struct A;
| ^^^^^^^^ must implement `Shl<_>`
-note: the following trait must be implemented
+note: the trait `Shl` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0369]: no implementation for `A >> A`
|
LL | struct A;
| ^^^^^^^^ must implement `Shr<_>`
-note: the following trait must be implemented
+note: the trait `Shr` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0369]: binary operation `==` cannot be applied to type `A`
|
LL | struct Thing {
| ^^^^^^^^^^^^ must implement `Mul<_>`
-note: the following trait must be implemented
+note: the trait `Mul` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error: aborting due to previous error
|
LL | struct S { x: u8, y: u8 }
| ^^^^^^^^ must implement `AddAssign<_>`
-note: the following trait must be implemented
+note: the trait `AddAssign` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0067]: invalid left-hand side of assignment
|
LL | enum Question {
| ^^^^^^^^^^^^^ must implement `Not`
-note: the following trait must be implemented
+note: the trait `Not` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0604]: only `u8` can be cast as `char`, not `u32`
|
= note: the following trait bounds were not satisfied:
`RawImpl<()>: Raw<()>`
-note: the following trait must be implemented
+note: the trait `Raw` must be implemented
--> $DIR/issue-62742.rs:12:1
|
LL | pub trait Raw<T: ?Sized> {
|
LL | pub struct BytePos(pub u32);
| ^^^^^^^^^^^^^^^^^^ must implement `Not`
-note: the following trait must be implemented
+note: the trait `Not` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: the following trait bounds were not satisfied:
`Foo: Iterator`
which is required by `&mut Foo: Iterator`
-note: the following trait must be implemented
+note: the trait `Iterator` must be implemented
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `take`, perhaps you need to implement it:
|
LL | struct Foo;
| ^^^^^^^^^^ must implement `AddAssign<_>`
-note: the following trait must be implemented
+note: the trait `AddAssign` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error: aborting due to previous error
|
LL | enum E { A, B }
| ^^^^^^ must implement `BitOr<_>`
-note: the following trait must be implemented
+note: the trait `BitOr` must be implemented
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error: aborting due to 5 previous errors
|
LL | enum World {
| ^^^^^^^^^^ must implement `Add<_>`
-note: the following trait must be implemented
+note: the trait `Add` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0369]: cannot add `String` to `&str`
| ^^^^^^^^^^^^^^^^---^^^^^-
| |
| unsatisfied trait bound introduced here
-note: the following trait must be implemented
+note: the trait `Foo` must be implemented
--> $DIR/specialization-trait-not-implemented.rs:7:1
|
LL | trait Foo {
`Enum: Clone`
`Enum: Default`
`CloneEnum: Default`
-note: the following trait must be implemented
+note: the trait `Default` must be implemented
--> $SRC_DIR/core/src/default.rs:LL:COL
help: consider annotating `Enum` with `#[derive(Clone)]`
|
|
LL | struct Wrapper<T>(T);
| ^^^^^^^^^^^^^^^^^ must implement `Add<_>`
-note: the following trait must be implemented
+note: the trait `Add` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
|
LL | struct Z;
| ^^^^^^^^ must implement `std::ops::Neg`
-note: the following trait must be implemented
+note: the trait `std::ops::Neg` must be implemented
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0308]: mismatched types