Point at closure definitions
This commit is contained in:
parent
9a64c3f5cb
commit
89e96e9bc5
4 changed files with 32 additions and 22 deletions
|
@ -538,28 +538,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let def_span =
|
let def_span =
|
||||||
|def_id| self.tcx.sess.source_map().def_span(self.tcx.def_span(def_id));
|
|def_id| self.tcx.sess.source_map().def_span(self.tcx.def_span(def_id));
|
||||||
let mut bound_spans = vec![];
|
let mut bound_spans = vec![];
|
||||||
let mut bound_span_label = |self_ty: Ty<'_>, obligation: &str| {
|
let mut bound_span_label = |self_ty: Ty<'_>, obligation: &str, quiet: &str| {
|
||||||
|
let msg = format!(
|
||||||
|
"doesn't satisfy {}",
|
||||||
|
if obligation.len() > 50 { quiet } else { obligation }
|
||||||
|
);
|
||||||
match &self_ty.kind {
|
match &self_ty.kind {
|
||||||
ty::Adt(def, _) => {
|
|
||||||
// Point at the type that couldn't satisfy the bound.
|
// Point at the type that couldn't satisfy the bound.
|
||||||
bound_spans.push((
|
ty::Adt(def, _) => bound_spans.push((def_span(def.did), msg)),
|
||||||
def_span(def.did),
|
|
||||||
format!("doesn't satisfy {}", obligation),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
ty::Dynamic(preds, _) => {
|
|
||||||
// Point at the trait object that couldn't satisfy the bound.
|
// Point at the trait object that couldn't satisfy the bound.
|
||||||
|
ty::Dynamic(preds, _) => {
|
||||||
for pred in *preds.skip_binder() {
|
for pred in *preds.skip_binder() {
|
||||||
match pred {
|
match pred {
|
||||||
ty::ExistentialPredicate::Trait(tr) => bound_spans.push((
|
ty::ExistentialPredicate::Trait(tr) => {
|
||||||
def_span(tr.def_id),
|
bound_spans.push((def_span(tr.def_id), msg.clone()))
|
||||||
format!("doesn't satisfy {}", obligation),
|
}
|
||||||
)),
|
|
||||||
ty::ExistentialPredicate::Projection(_)
|
ty::ExistentialPredicate::Projection(_)
|
||||||
| ty::ExistentialPredicate::AutoTrait(_) => {}
|
| ty::ExistentialPredicate::AutoTrait(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Point at the closure that couldn't satisfy the bound.
|
||||||
|
ty::Closure(def_id, _) => bound_spans
|
||||||
|
.push((def_span(*def_id), format!("doesn't satisfy {}", quiet))),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -573,9 +574,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.tcx
|
.tcx
|
||||||
.associated_item(pred.skip_binder().projection_ty.item_def_id);
|
.associated_item(pred.skip_binder().projection_ty.item_def_id);
|
||||||
let ty = pred.skip_binder().ty;
|
let ty = pred.skip_binder().ty;
|
||||||
let obligation =
|
let msg = format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
|
||||||
format!("`{}::{} = {}`", trait_ref, assoc.ident, ty);
|
let quiet = format!(
|
||||||
bound_span_label(trait_ref.self_ty(), &obligation);
|
"`<_ as {}>::{} = {}`",
|
||||||
|
trait_ref.print_only_trait_path(),
|
||||||
|
assoc.ident,
|
||||||
|
ty
|
||||||
|
);
|
||||||
|
bound_span_label(trait_ref.self_ty(), &msg, &quiet);
|
||||||
Some(obligation)
|
Some(obligation)
|
||||||
}
|
}
|
||||||
ty::Predicate::Trait(poly_trait_ref, _) => {
|
ty::Predicate::Trait(poly_trait_ref, _) => {
|
||||||
|
@ -583,7 +589,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let self_ty = p.self_ty();
|
let self_ty = p.self_ty();
|
||||||
let path = p.print_only_trait_path();
|
let path = p.print_only_trait_path();
|
||||||
let obligation = format!("`{}: {}`", self_ty, path);
|
let obligation = format!("`{}: {}`", self_ty, path);
|
||||||
bound_span_label(self_ty, &obligation);
|
let quiet = format!("`_: {}`", path);
|
||||||
|
bound_span_label(self_ty, &obligation, &quiet);
|
||||||
Some(obligation)
|
Some(obligation)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -16,10 +16,10 @@ LL | .collect();
|
||||||
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
||||||
|
|
|
|
||||||
LL | pub struct Cloned<I> {
|
LL | pub struct Cloned<I> {
|
||||||
| -------------------- doesn't satisfy `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>: std::iter::Iterator`
|
| -------------------- doesn't satisfy `_: std::iter::Iterator`
|
||||||
...
|
...
|
||||||
LL | pub struct TakeWhile<I, P> {
|
LL | pub struct TakeWhile<I, P> {
|
||||||
| -------------------------- doesn't satisfy `<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]> as std::iter::Iterator>::Item = &_`
|
| -------------------------- doesn't satisfy `<_ as std::iter::Iterator>::Item = &_`
|
||||||
|
|
|
|
||||||
= note: the method `collect` exists but the following trait bounds were not satisfied:
|
= note: the method `collect` exists but the following trait bounds were not satisfied:
|
||||||
`<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]> as std::iter::Iterator>::Item = &_` which is required by `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>: std::iter::Iterator`
|
`<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]> as std::iter::Iterator>::Item = &_` which is required by `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>: std::iter::Iterator`
|
||||||
|
|
|
@ -2,12 +2,15 @@ error[E0599]: no method named `count` found for struct `std::iter::Filter<std::i
|
||||||
--> $DIR/issue-36053-2.rs:11:55
|
--> $DIR/issue-36053-2.rs:11:55
|
||||||
|
|
|
|
||||||
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
|
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
|
||||||
| ^^^^^ method not found in `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>`
|
| -------------- ^^^^^ method not found in `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>`
|
||||||
|
| |
|
||||||
|
| doesn't satisfy `<_ as std::ops::FnOnce<(&&str,)>>::Output = bool`
|
||||||
|
| doesn't satisfy `_: std::ops::FnMut<(&&str,)>`
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
||||||
|
|
|
|
||||||
LL | pub struct Filter<I, P> {
|
LL | pub struct Filter<I, P> {
|
||||||
| ----------------------- doesn't satisfy `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
|
| ----------------------- doesn't satisfy `_: std::iter::Iterator`
|
||||||
|
|
|
|
||||||
= note: the method `count` exists but the following trait bounds were not satisfied:
|
= note: the method `count` exists but the following trait bounds were not satisfied:
|
||||||
`<[closure@$DIR/issue-36053-2.rs:11:39: 11:53] as std::ops::FnOnce<(&&str,)>>::Output = bool` which is required by `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
|
`<[closure@$DIR/issue-36053-2.rs:11:39: 11:53] as std::ops::FnOnce<(&&str,)>>::Output = bool` which is required by `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
|
||||||
|
|
|
@ -34,7 +34,7 @@ LL | writeln!(fp, "hello world").unwrap();
|
||||||
::: $SRC_DIR/libstd/io/buffered.rs:LL:COL
|
::: $SRC_DIR/libstd/io/buffered.rs:LL:COL
|
||||||
|
|
|
|
||||||
LL | pub struct BufWriter<W: Write> {
|
LL | pub struct BufWriter<W: Write> {
|
||||||
| ------------------------------ doesn't satisfy `std::io::BufWriter<&dyn std::io::Write>: std::io::Write`
|
| ------------------------------ doesn't satisfy `_: std::io::Write`
|
||||||
|
|
|
|
||||||
= note: the method `write_fmt` exists but the following trait bounds were not satisfied:
|
= note: the method `write_fmt` exists but the following trait bounds were not satisfied:
|
||||||
`&dyn std::io::Write: std::io::Write` which is required by `std::io::BufWriter<&dyn std::io::Write>: std::io::Write`
|
`&dyn std::io::Write: std::io::Write` which is required by `std::io::BufWriter<&dyn std::io::Write>: std::io::Write`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue