Tweak output
This commit is contained in:
parent
fb5d215347
commit
317adda649
@ -587,7 +587,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
// Find all the requirements that come from a local `impl` block.
|
||||
let mut skip_list: FxHashSet<_> = Default::default();
|
||||
let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
|
||||
let mut spanned_predicates = FxHashMap::default();
|
||||
for (p, parent_p, impl_def_id, cause) in unsatisfied_predicates
|
||||
.iter()
|
||||
.filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
|
||||
@ -615,13 +615,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
) =>
|
||||
{
|
||||
let span = self_ty.span.ctxt().outer_expn_data().call_site;
|
||||
let mut spans: MultiSpan = span.into();
|
||||
spans.push_span_label(
|
||||
let entry = spanned_predicates.entry(span);
|
||||
let entry = entry.or_insert_with(|| {
|
||||
(FxHashSet::default(), FxHashSet::default(), Vec::new())
|
||||
});
|
||||
entry.0.insert(span);
|
||||
entry.1.insert((
|
||||
span,
|
||||
"unsatisfied trait bound introduced in this `derive` macro",
|
||||
);
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| Vec::new()).push(p);
|
||||
));
|
||||
entry.2.push(p);
|
||||
skip_list.insert(p);
|
||||
}
|
||||
|
||||
// Unmet obligation coming from an `impl`.
|
||||
@ -659,28 +663,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let _ = format_pred(*pred);
|
||||
}
|
||||
skip_list.insert(p);
|
||||
let mut spans = if cause.span != *item_span {
|
||||
let mut spans: MultiSpan = cause.span.into();
|
||||
spans.push_span_label(
|
||||
cause.span,
|
||||
"unsatisfied trait bound introduced here",
|
||||
);
|
||||
spans
|
||||
let entry = spanned_predicates.entry(self_ty.span);
|
||||
let entry = entry.or_insert_with(|| {
|
||||
(FxHashSet::default(), FxHashSet::default(), Vec::new())
|
||||
});
|
||||
entry.2.push(p);
|
||||
if cause.span != *item_span {
|
||||
entry.0.insert(cause.span);
|
||||
entry.1.insert((cause.span, "unsatisfied trait bound introduced here"));
|
||||
} else {
|
||||
let mut spans = Vec::with_capacity(2);
|
||||
if let Some(trait_ref) = of_trait {
|
||||
spans.push(trait_ref.path.span);
|
||||
entry.0.insert(trait_ref.path.span);
|
||||
}
|
||||
spans.push(self_ty.span);
|
||||
spans.into()
|
||||
entry.0.insert(self_ty.span);
|
||||
};
|
||||
if let Some(trait_ref) = of_trait {
|
||||
spans.push_span_label(trait_ref.path.span, "");
|
||||
entry.1.insert((trait_ref.path.span, ""));
|
||||
}
|
||||
spans.push_span_label(self_ty.span, "");
|
||||
|
||||
let entry = spanned_predicates.entry(spans);
|
||||
entry.or_insert_with(|| Vec::new()).push(p);
|
||||
entry.1.insert((self_ty.span, ""));
|
||||
}
|
||||
Some(Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Trait(rustc_ast::ast::IsAuto::Yes, ..),
|
||||
@ -697,8 +697,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
let mut spanned_predicates: Vec<_> = spanned_predicates.into_iter().collect();
|
||||
spanned_predicates.sort_by_key(|(span, _)| span.primary_span());
|
||||
for (span, predicates) in spanned_predicates {
|
||||
spanned_predicates.sort_by_key(|(span, _)| *span);
|
||||
for (_, (primary_spans, span_labels, predicates)) in spanned_predicates {
|
||||
let mut preds: Vec<_> = predicates
|
||||
.iter()
|
||||
.filter_map(|pred| format_pred(**pred))
|
||||
@ -711,6 +711,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
} else {
|
||||
format!("the following trait bounds were not satisfied:\n{}", preds.join("\n"),)
|
||||
};
|
||||
let mut span: MultiSpan = primary_spans.into_iter().collect::<Vec<_>>().into();
|
||||
for (sp, label) in span_labels {
|
||||
span.push_span_label(sp, label);
|
||||
}
|
||||
err.span_note(span, &msg);
|
||||
unsatisfied_bounds = true;
|
||||
}
|
||||
|
@ -18,9 +18,6 @@ note: trait bound `NotClone: Clone` was not satisfied
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NotClone: Clone`
|
||||
which is required by `Bar<NotClone>: Clone`
|
||||
= help: items from traits can only be used if the trait is implemented and in scope
|
||||
= note: the following trait defines an item `clone`, perhaps you need to implement it:
|
||||
candidate #1: `Clone`
|
||||
|
@ -81,20 +81,16 @@ LL | struct Object<T>(T);
|
||||
LL | foo.use_ord_and_partial_ord();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `NoDerives: Ord` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`NoDerives: Ord`
|
||||
`NoDerives: PartialOrd`
|
||||
--> $DIR/issue-91550.rs:21:9
|
||||
|
|
||||
LL | impl<T: Ord + PartialOrd> Object<T> {
|
||||
| ^^^ ---------
|
||||
| |
|
||||
| ^^^ ^^^^^^^^^^ ---------
|
||||
| | |
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `NoDerives: PartialOrd` was not satisfied
|
||||
--> $DIR/issue-91550.rs:21:15
|
||||
|
|
||||
LL | impl<T: Ord + PartialOrd> Object<T> {
|
||||
| ^^^^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
help: consider annotating `NoDerives` with `#[derive(Eq, Ord, PartialEq, PartialOrd)]`
|
||||
|
|
||||
LL | #[derive(Eq, Ord, PartialEq, PartialOrd)]
|
||||
|
@ -88,20 +88,16 @@ LL | struct Struct<T> {
|
||||
LL | s.method();
|
||||
| ^^^^^^ method cannot be called on `Struct<f64>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `f64: Eq` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`f64: Eq`
|
||||
`f64: Ord`
|
||||
--> $DIR/method-not-found-generic-arg-elision.rs:74:36
|
||||
|
|
||||
LL | impl<T: Clone + Copy + PartialEq + Eq + PartialOrd + Ord> Struct<T> {
|
||||
| ^^ ---------
|
||||
| |
|
||||
| ^^ ^^^ ---------
|
||||
| | |
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `f64: Ord` was not satisfied
|
||||
--> $DIR/method-not-found-generic-arg-elision.rs:74:54
|
||||
|
|
||||
LL | impl<T: Clone + Copy + PartialEq + Eq + PartialOrd + Ord> Struct<T> {
|
||||
| ^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
@ -7,20 +7,16 @@ LL | struct Foo<T> {
|
||||
LL | self.foo();
|
||||
| ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `T: Default` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`T: Bar`
|
||||
`T: Default`
|
||||
--> $DIR/missing-trait-bounds-for-method-call.rs:10:9
|
||||
|
|
||||
LL | impl<T: Default + Bar> Bar for Foo<T> {}
|
||||
| ^^^^^^^ --- ------
|
||||
| |
|
||||
| ^^^^^^^ ^^^ --- ------
|
||||
| | |
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `T: Bar` was not satisfied
|
||||
--> $DIR/missing-trait-bounds-for-method-call.rs:10:19
|
||||
|
|
||||
LL | impl<T: Default + Bar> Bar for Foo<T> {}
|
||||
| ^^^ --- ------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
help: consider restricting the type parameters to satisfy the trait bounds
|
||||
|
|
||||
LL | struct Foo<T> where T: Bar, T: Default {
|
||||
|
@ -16,27 +16,18 @@ LL | struct Foo<X, Y> (X, Y);
|
||||
LL | let y = x.test();
|
||||
| ^^^^ method cannot be called on `Foo<Enum, CloneEnum>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `Enum: Clone` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`CloneEnum: Default`
|
||||
`Enum: Clone`
|
||||
`Enum: Default`
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:9
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^ ---------
|
||||
| |
|
||||
| ^^^^^ ^^^^^^^ ^^^^^^^ ---------
|
||||
| | | |
|
||||
| | | unsatisfied trait bound introduced here
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `Enum: Default` was not satisfied
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:17
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `CloneEnum: Default` was not satisfied
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:40
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: the trait `Default` must be implemented
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
help: consider annotating `Enum` with `#[derive(Clone)]`
|
||||
@ -62,27 +53,18 @@ LL | struct Foo<X, Y> (X, Y);
|
||||
LL | let y = x.test();
|
||||
| ^^^^ method cannot be called on `Foo<Struct, CloneStruct>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: trait bound `Struct: Clone` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`CloneStruct: Default`
|
||||
`Struct: Clone`
|
||||
`Struct: Default`
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:9
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^ ---------
|
||||
| |
|
||||
| ^^^^^ ^^^^^^^ ^^^^^^^ ---------
|
||||
| | | |
|
||||
| | | unsatisfied trait bound introduced here
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `Struct: Default` was not satisfied
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:17
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `CloneStruct: Default` was not satisfied
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:40
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
help: consider annotating `CloneStruct` with `#[derive(Default)]`
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
@ -107,20 +89,16 @@ LL | let y = x.test();
|
||||
|
|
||||
= note: doesn't satisfy `Vec<Enum>: Clone`
|
||||
|
|
||||
note: trait bound `Vec<Enum>: Clone` was not satisfied
|
||||
note: the following trait bounds were not satisfied:
|
||||
`Instant: Default`
|
||||
`Vec<Enum>: Clone`
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:9
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^ ---------
|
||||
| |
|
||||
| ^^^^^ ^^^^^^^ ---------
|
||||
| | |
|
||||
| | unsatisfied trait bound introduced here
|
||||
| unsatisfied trait bound introduced here
|
||||
note: trait bound `Instant: Default` was not satisfied
|
||||
--> $DIR/derive-trait-for-method-call.rs:20:40
|
||||
|
|
||||
LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> {
|
||||
| ^^^^^^^ ---------
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -32,9 +32,6 @@ note: trait bound `CloneNoCopy: Copy` was not satisfied
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`CloneNoCopy: Copy`
|
||||
which is required by `U5<CloneNoCopy>: Clone`
|
||||
help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]`
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
|
@ -32,9 +32,6 @@ note: trait bound `CloneNoCopy: Copy` was not satisfied
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`CloneNoCopy: Copy`
|
||||
which is required by `U5<CloneNoCopy>: Clone`
|
||||
help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]`
|
||||
|
|
||||
LL | #[derive(Clone, Copy)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user