1
Fork 0

Add more context to E0599 errors

Point at the intermediary unfullfilled trait bounds.
This commit is contained in:
Esteban Küber 2020-02-17 23:22:19 -08:00
parent eaa02f599f
commit f037d5ca1b
27 changed files with 203 additions and 56 deletions

View file

@ -645,8 +645,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.tcx.sess, self.tcx.sess,
span, span,
E0491, E0491,
"in type `{}`, reference has a longer lifetime \ "in type `{}`, reference has a longer lifetime than the data it references",
than the data it references",
self.ty_to_string(ty) self.ty_to_string(ty)
); );
note_and_explain_region( note_and_explain_region(

View file

@ -1404,6 +1404,30 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// `potentially_unsatisfied_predicates`. // `potentially_unsatisfied_predicates`.
return ProbeResult::NoMatch; return ProbeResult::NoMatch;
} else { } else {
self.probe(|_| {
match self.select_trait_candidate(trait_ref) {
Ok(Some(traits::VtableImpl(traits::VtableImplData {
nested,
..
}))) if !nested.is_empty() => {
for obligation in nested {
// Determine exactly which obligation wasn't met, so
// that we can give more context in the error.
if !self.predicate_may_hold(&obligation) {
result = ProbeResult::NoMatch;
if let Some(poly_trait_ref) =
obligation.predicate.to_opt_poly_trait_ref()
{
let trait_ref = poly_trait_ref.clone();
let trait_ref = trait_ref.skip_binder();
possibly_unsatisfied_predicates
.push(*trait_ref);
}
}
}
}
_ => {}
}
// Some nested subobligation of this predicate // Some nested subobligation of this predicate
// failed. // failed.
// //
@ -1413,6 +1437,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
result = ProbeResult::NoMatch; result = ProbeResult::NoMatch;
let trait_ref = self.resolve_vars_if_possible(&trait_ref); let trait_ref = self.resolve_vars_if_possible(&trait_ref);
possibly_unsatisfied_predicates.push(trait_ref); possibly_unsatisfied_predicates.push(trait_ref);
});
} }
} }
vec![] vec![]

View file

@ -394,6 +394,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
tcx.sess.diagnostic().struct_dummy() tcx.sess.diagnostic().struct_dummy()
}; };
// FIXME: Unify with unmet bound label.
if let Some(def) = actual.ty_adt_def() { if let Some(def) = actual.ty_adt_def() {
if let Some(full_sp) = tcx.hir().span_if_local(def.did) { if let Some(full_sp) = tcx.hir().span_if_local(def.did) {
let def_sp = tcx.sess.source_map().def_span(full_sp); let def_sp = tcx.sess.source_map().def_span(full_sp);
@ -535,16 +536,54 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
if !unsatisfied_predicates.is_empty() { if !unsatisfied_predicates.is_empty() {
let mut bound_spans = vec![];
let mut bound_list = unsatisfied_predicates let mut bound_list = unsatisfied_predicates
.iter() .iter()
.map(|p| format!("`{} : {}`", p.self_ty(), p.print_only_trait_path())) .map(|p| {
let self_ty = p.self_ty();
match &self_ty.kind {
ty::Adt(def, _) => bound_spans.push((
self.tcx.sess.source_map().def_span(self.tcx.def_span(def.did)),
format!(
"this type doesn't satisfy the bound `{}`",
p.print_only_trait_path()
),
)),
ty::Dynamic(preds, _) => {
for pred in *preds.skip_binder() {
match pred {
ty::ExistentialPredicate::Trait(tr) => bound_spans
.push((
self.tcx
.sess
.source_map()
.def_span(self.tcx.def_span(tr.def_id)),
format!(
"this trait doesn't satisfy the bound `{}`",
p.print_only_trait_path()
),
)),
ty::ExistentialPredicate::Projection(_)
| ty::ExistentialPredicate::AutoTrait(_) => {}
}
}
}
_ => {}
};
format!("`{}: {}`", p.self_ty(), p.print_only_trait_path())
})
.collect::<Vec<_>>(); .collect::<Vec<_>>();
bound_list.sort(); bound_list.sort();
bound_list.dedup(); // #35677 bound_list.dedup(); // #35677
bound_spans.sort();
bound_spans.dedup(); // #35677
for (span, msg) in bound_spans.into_iter() {
err.span_label(span, &msg);
}
let bound_list = bound_list.join("\n"); let bound_list = bound_list.join("\n");
err.note(&format!( err.note(&format!(
"the method `{}` exists but the following trait bounds \ "the method `{}` exists but the following trait bounds were not \
were not satisfied:\n{}", satisfied:\n{}",
item_name, bound_list item_name, bound_list
)); ));
} }

View file

@ -8,8 +8,8 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
| ^^^^^^^^^ associated item not found in `Foo<A, B>` | ^^^^^^^^^ associated item not found in `Foo<A, B>`
| |
= note: the method `HOST_SIZE` exists but the following trait bounds were not satisfied: = note: the method `HOST_SIZE` exists but the following trait bounds were not satisfied:
`A : std::marker::Sized` `A: std::marker::Sized`
`B : std::marker::Sized` `B: std::marker::Sized`
error[E0277]: the size for values of type `A` cannot be known at compilation time error[E0277]: the size for values of type `A` cannot be known at compilation time
--> $DIR/too_generic_eval_ice.rs:7:13 --> $DIR/too_generic_eval_ice.rs:7:13

View file

@ -2,13 +2,20 @@ error[E0599]: no method named `clone` found for struct `Bar<NotClone>` in the cu
--> $DIR/derive-assoc-type-not-impl.rs:18:30 --> $DIR/derive-assoc-type-not-impl.rs:18:30
| |
LL | struct Bar<T: Foo> { LL | struct Bar<T: Foo> {
| ------------------ method `clone` not found for this | ------------------
| |
| method `clone` not found for this
| this type doesn't satisfy the bound `std::clone::Clone`
...
LL | struct NotClone;
| ---------------- this type doesn't satisfy the bound `std::clone::Clone`
... ...
LL | Bar::<NotClone> { x: 1 }.clone(); LL | Bar::<NotClone> { x: 1 }.clone();
| ^^^^^ method not found in `Bar<NotClone>` | ^^^^^ method not found in `Bar<NotClone>`
| |
= note: the method `clone` exists but the following trait bounds were not satisfied: = note: the method `clone` exists but the following trait bounds were not satisfied:
`Bar<NotClone> : std::clone::Clone` `Bar<NotClone>: std::clone::Clone`
`NotClone: std::clone::Clone`
= help: items from traits can only be used if the trait is implemented and in scope = 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: = note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone` candidate #1: `std::clone::Clone`

View file

@ -7,7 +7,8 @@ LL | println!("{}", z.to_string());
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
= note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
= note: the method `to_string` exists but the following trait bounds were not satisfied: = note: the method `to_string` exists but the following trait bounds were not satisfied:
`*const u8 : std::string::ToString` `*const u8: std::fmt::Display`
`*const u8: std::string::ToString`
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,3 +1,7 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
use std::vec::IntoIter; use std::vec::IntoIter;
pub fn get_tok(it: &mut IntoIter<u8>) { pub fn get_tok(it: &mut IntoIter<u8>) {

View file

@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]> as std::iter::Iterator>::Item == &_` error[E0271]: type mismatch resolving `<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]> as std::iter::Iterator>::Item == &_`
--> $DIR/issue-31173.rs:10:10 --> $DIR/issue-31173.rs:14:10
| |
LL | .cloned() LL | .cloned()
| ^^^^^^ expected `u8`, found reference | ^^^^^^ expected `u8`, found reference
@ -7,15 +7,20 @@ LL | .cloned()
= note: expected type `u8` = note: expected type `u8`
found reference `&_` found reference `&_`
error[E0599]: no method named `collect` found for struct `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>>` in the current scope error[E0599]: no method named `collect` found for struct `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>` in the current scope
--> $DIR/issue-31173.rs:14:10 --> $DIR/issue-31173.rs:18:10
| |
LL | .collect(); LL | .collect();
| ^^^^^^^ method not found in `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>>` | ^^^^^^^ method not found in `std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>`
|
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
LL | pub struct Cloned<I> {
| -------------------- this type doesn't satisfy the bound `std::iter::Iterator`
| |
= 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:
`&mut std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator` `&mut 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::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator` `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`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -5,8 +5,8 @@ LL | this.is_subset(other)
| ^^^^^^^^^ method not found in `&std::collections::HashSet<T>` | ^^^^^^^^^ method not found in `&std::collections::HashSet<T>`
| |
= note: the method `is_subset` exists but the following trait bounds were not satisfied: = note: the method `is_subset` exists but the following trait bounds were not satisfied:
`T : std::cmp::Eq` `T: std::cmp::Eq`
`T : std::hash::Hash` `T: std::hash::Hash`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &Some(42).as_deref();
| ^^^^^^^^ help: there is a method with a similar name: `as_ref` | ^^^^^^^^ help: there is a method with a similar name: `as_ref`
| |
= note: the method `as_deref` exists but the following trait bounds were not satisfied: = note: the method `as_deref` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::Deref` `{integer}: std::ops::Deref`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &mut Some(42).as_deref_mut();
| ^^^^^^^^^^^^ method not found in `std::option::Option<{integer}>` | ^^^^^^^^^^^^ method not found in `std::option::Option<{integer}>`
| |
= note: the method `as_deref_mut` exists but the following trait bounds were not satisfied: = note: the method `as_deref_mut` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::DerefMut` `{integer}: std::ops::DerefMut`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &Ok(42).as_deref();
| ^^^^^^^^ help: there is a method with a similar name: `as_ref` | ^^^^^^^^ help: there is a method with a similar name: `as_ref`
| |
= note: the method `as_deref` exists but the following trait bounds were not satisfied: = note: the method `as_deref` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::Deref` `{integer}: std::ops::Deref`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &Err(41).as_deref_err();
| ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut` | ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut`
| |
= note: the method `as_deref_err` exists but the following trait bounds were not satisfied: = note: the method `as_deref_err` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::Deref` `{integer}: std::ops::Deref`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &mut Ok(42).as_deref_mut();
| ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_err` | ^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_err`
| |
= note: the method `as_deref_mut` exists but the following trait bounds were not satisfied: = note: the method `as_deref_mut` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::DerefMut` `{integer}: std::ops::DerefMut`
error: aborting due to previous error error: aborting due to previous error

View file

@ -5,7 +5,7 @@ LL | let _result = &mut Err(41).as_deref_mut_err();
| ^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut` | ^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `as_deref_mut`
| |
= note: the method `as_deref_mut_err` exists but the following trait bounds were not satisfied: = note: the method `as_deref_mut_err` exists but the following trait bounds were not satisfied:
`{integer} : std::ops::DerefMut` `{integer}: std::ops::DerefMut`
error: aborting due to previous error error: aborting due to previous error

View file

@ -35,13 +35,17 @@ error[E0599]: no method named `take` found for struct `Foo` in the current scope
--> $DIR/method-call-err-msg.rs:19:7 --> $DIR/method-call-err-msg.rs:19:7
| |
LL | pub struct Foo; LL | pub struct Foo;
| --------------- method `take` not found for this | ---------------
| |
| method `take` not found for this
| this type doesn't satisfy the bound `std::iter::Iterator`
... ...
LL | .take() LL | .take()
| ^^^^ method not found in `Foo` | ^^^^ method not found in `Foo`
| |
= note: the method `take` exists but the following trait bounds were not satisfied: = note: the method `take` exists but the following trait bounds were not satisfied:
`&mut Foo : std::iter::Iterator` `&mut Foo: std::iter::Iterator`
`Foo: std::iter::Iterator`
= help: items from traits can only be used if the trait is implemented and in scope = help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `take`, perhaps you need to implement one of them: = note: the following traits define an item `take`, perhaps you need to implement one of them:
candidate #1: `std::io::Read` candidate #1: `std::io::Read`

View file

@ -1,3 +1,7 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
// Regression test for #36053. ICE was caused due to obligations // Regression test for #36053. ICE was caused due to obligations
// being added to a special, dedicated fulfillment cx during // being added to a special, dedicated fulfillment cx during
// a probe. // a probe.

View file

@ -1,15 +1,21 @@
error[E0599]: no method named `count` found for struct `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` in the current scope error[E0599]: no method named `count` found for struct `std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>` in the current scope
--> $DIR/issue-36053-2.rs:7: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:7:39: 7: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]>`
|
::: $SRC_DIR/libcore/iter/adapters/mod.rs:LL:COL
|
LL | pub struct Filter<I, P> {
| ----------------------- this type doesn't satisfy the bound `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:
`&mut std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` `&mut std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` `[closure@$DIR/issue-36053-2.rs:11:39: 11:53]: std::ops::FnMut<(&_,)>`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
error[E0631]: type mismatch in closure arguments error[E0631]: type mismatch in closure arguments
--> $DIR/issue-36053-2.rs:7:32 --> $DIR/issue-36053-2.rs:11:32
| |
LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
| ^^^^^^ -------------- found signature of `for<'r> fn(&'r str) -> _` | ^^^^^^ -------------- found signature of `for<'r> fn(&'r str) -> _`

View file

@ -1,11 +1,14 @@
error[E0599]: no method named `unwrap` found for enum `std::result::Result<(), Foo>` in the current scope error[E0599]: no method named `unwrap` found for enum `std::result::Result<(), Foo>` in the current scope
--> $DIR/method-help-unsatisfied-bound.rs:5:7 --> $DIR/method-help-unsatisfied-bound.rs:5:7
| |
LL | struct Foo;
| ----------- this type doesn't satisfy the bound `std::fmt::Debug`
...
LL | a.unwrap(); LL | a.unwrap();
| ^^^^^^ method not found in `std::result::Result<(), Foo>` | ^^^^^^ method not found in `std::result::Result<(), Foo>`
| |
= note: the method `unwrap` exists but the following trait bounds were not satisfied: = note: the method `unwrap` exists but the following trait bounds were not satisfied:
`Foo : std::fmt::Debug` `Foo: std::fmt::Debug`
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,13 +2,16 @@ error[E0599]: no method named `foo_one` found for struct `MyStruct` in the curre
--> $DIR/specialization-trait-not-implemented.rs:22:29 --> $DIR/specialization-trait-not-implemented.rs:22:29
| |
LL | struct MyStruct; LL | struct MyStruct;
| ---------------- method `foo_one` not found for this | ----------------
| |
| method `foo_one` not found for this
| this type doesn't satisfy the bound `Foo`
... ...
LL | println!("{}", MyStruct.foo_one()); LL | println!("{}", MyStruct.foo_one());
| ^^^^^^^ method not found in `MyStruct` | ^^^^^^^ method not found in `MyStruct`
| |
= note: the method `foo_one` exists but the following trait bounds were not satisfied: = note: the method `foo_one` exists but the following trait bounds were not satisfied:
`MyStruct : Foo` `MyStruct: Foo`
= help: items from traits can only be used if the trait is implemented and in scope = help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo_one`, perhaps you need to implement it: = note: the following trait defines an item `foo_one`, perhaps you need to implement it:
candidate #1: `Foo` candidate #1: `Foo`

View file

@ -1,3 +1,7 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
use std::env::args; use std::env::args;
use std::fs::File; use std::fs::File;
use std::io::{stdout, Write, BufWriter}; use std::io::{stdout, Write, BufWriter};

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
--> $DIR/mut-borrow-needed-by-trait.rs:17:29 --> $DIR/mut-borrow-needed-by-trait.rs:21:29
| |
LL | let fp = BufWriter::new(fp); LL | let fp = BufWriter::new(fp);
| ^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` | ^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
@ -8,7 +8,7 @@ LL | let fp = BufWriter::new(fp);
= note: required by `std::io::BufWriter::<W>::new` = note: required by `std::io::BufWriter::<W>::new`
error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
--> $DIR/mut-borrow-needed-by-trait.rs:17:14 --> $DIR/mut-borrow-needed-by-trait.rs:21:14
| |
LL | let fp = BufWriter::new(fp); LL | let fp = BufWriter::new(fp);
| ^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` | ^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
@ -17,7 +17,7 @@ LL | let fp = BufWriter::new(fp);
= note: required by `std::io::BufWriter` = note: required by `std::io::BufWriter`
error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
--> $DIR/mut-borrow-needed-by-trait.rs:17:14 --> $DIR/mut-borrow-needed-by-trait.rs:21:14
| |
LL | let fp = BufWriter::new(fp); LL | let fp = BufWriter::new(fp);
| ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
@ -26,13 +26,19 @@ LL | let fp = BufWriter::new(fp);
= note: required by `std::io::BufWriter` = note: required by `std::io::BufWriter`
error[E0599]: no method named `write_fmt` found for struct `std::io::BufWriter<&dyn std::io::Write>` in the current scope error[E0599]: no method named `write_fmt` found for struct `std::io::BufWriter<&dyn std::io::Write>` in the current scope
--> $DIR/mut-borrow-needed-by-trait.rs:22:5 --> $DIR/mut-borrow-needed-by-trait.rs:26:5
| |
LL | writeln!(fp, "hello world").unwrap(); LL | writeln!(fp, "hello world").unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::io::BufWriter<&dyn std::io::Write>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `std::io::BufWriter<&dyn std::io::Write>`
| |
::: $SRC_DIR/libstd/io/buffered.rs:LL:COL
|
LL | pub struct BufWriter<W: Write> {
| ------------------------------ this type doesn't satisfy the bound `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:
`std::io::BufWriter<&dyn std::io::Write> : std::io::Write` `&dyn std::io::Write: std::io::Write`
`std::io::BufWriter<&dyn std::io::Write>: std::io::Write`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -11,13 +11,20 @@ error[E0599]: no method named `clone` found for union `U5<CloneNoCopy>` in the c
--> $DIR/union-derive-clone.rs:37:15 --> $DIR/union-derive-clone.rs:37:15
| |
LL | union U5<T> { LL | union U5<T> {
| ----------- method `clone` not found for this | -----------
| |
| method `clone` not found for this
| this type doesn't satisfy the bound `std::clone::Clone`
...
LL | struct CloneNoCopy;
| ------------------- this type doesn't satisfy the bound `std::marker::Copy`
... ...
LL | let w = u.clone(); LL | let w = u.clone();
| ^^^^^ method not found in `U5<CloneNoCopy>` | ^^^^^ method not found in `U5<CloneNoCopy>`
| |
= note: the method `clone` exists but the following trait bounds were not satisfied: = note: the method `clone` exists but the following trait bounds were not satisfied:
`U5<CloneNoCopy> : std::clone::Clone` `CloneNoCopy: std::marker::Copy`
`U5<CloneNoCopy>: std::clone::Clone`
= help: items from traits can only be used if the trait is implemented and in scope = 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: = note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone` candidate #1: `std::clone::Clone`

View file

@ -1,3 +1,7 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
#![feature(box_syntax)] #![feature(box_syntax)]
trait Foo { trait Foo {

View file

@ -1,11 +1,24 @@
error[E0599]: no method named `clone` found for struct `std::boxed::Box<dyn Foo>` in the current scope error[E0599]: no method named `clone` found for struct `std::boxed::Box<dyn Foo>` in the current scope
--> $DIR/unique-object-noncopyable.rs:24:16 --> $DIR/unique-object-noncopyable.rs:28:16
| |
LL | trait Foo {
| ---------
| |
| this trait doesn't satisfy the bound `std::clone::Clone`
| this trait doesn't satisfy the bound `std::marker::Sized`
...
LL | let _z = y.clone(); LL | let _z = y.clone();
| ^^^^^ method not found in `std::boxed::Box<dyn Foo>` | ^^^^^ method not found in `std::boxed::Box<dyn Foo>`
| |
::: $SRC_DIR/liballoc/boxed.rs:LL:COL
|
LL | pub struct Box<T: ?Sized>(Unique<T>);
| ------------------------------------- this type doesn't satisfy the bound `std::clone::Clone`
|
= note: the method `clone` exists but the following trait bounds were not satisfied: = note: the method `clone` exists but the following trait bounds were not satisfied:
`std::boxed::Box<dyn Foo> : std::clone::Clone` `dyn Foo: std::clone::Clone`
`dyn Foo: std::marker::Sized`
`std::boxed::Box<dyn Foo>: std::clone::Clone`
= help: items from traits can only be used if the trait is implemented and in scope = 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: = note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone` candidate #1: `std::clone::Clone`

View file

@ -1,3 +1,7 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
#[derive(Debug)] #[derive(Debug)]
struct R { struct R {
b: bool, b: bool,

View file

@ -1,11 +1,20 @@
error[E0599]: no method named `clone` found for struct `std::boxed::Box<R>` in the current scope error[E0599]: no method named `clone` found for struct `std::boxed::Box<R>` in the current scope
--> $DIR/unique-pinned-nocopy.rs:12:16 --> $DIR/unique-pinned-nocopy.rs:16:16
| |
LL | struct R {
| -------- this type doesn't satisfy the bound `std::clone::Clone`
...
LL | let _j = i.clone(); LL | let _j = i.clone();
| ^^^^^ method not found in `std::boxed::Box<R>` | ^^^^^ method not found in `std::boxed::Box<R>`
| |
::: $SRC_DIR/liballoc/boxed.rs:LL:COL
|
LL | pub struct Box<T: ?Sized>(Unique<T>);
| ------------------------------------- this type doesn't satisfy the bound `std::clone::Clone`
|
= note: the method `clone` exists but the following trait bounds were not satisfied: = note: the method `clone` exists but the following trait bounds were not satisfied:
`std::boxed::Box<R> : std::clone::Clone` `R: std::clone::Clone`
`std::boxed::Box<R>: std::clone::Clone`
= help: items from traits can only be used if the trait is implemented and in scope = 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: = note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone` candidate #1: `std::clone::Clone`