Auto merge of #69255 - estebank:e0599-details, r=varkor

Add more context to E0599 errors

Point at the intermediary unfulfilled trait bounds.

Fix #52523, fix #61661, cc #36513, fix #68131, fix #64417, fix #61768, cc #57457, cc #9082, fix #57994, cc #64934, cc #65149.
This commit is contained in:
bors 2020-02-29 03:52:53 +00:00
commit 55aee8d496
44 changed files with 635 additions and 158 deletions

View File

@ -581,6 +581,20 @@ impl<'tcx, N> Vtable<'tcx, N> {
} }
} }
pub fn borrow_nested_obligations(&self) -> &[N] {
match &self {
VtableImpl(i) => &i.nested[..],
VtableParam(n) => &n[..],
VtableBuiltin(i) => &i.nested[..],
VtableAutoImpl(d) => &d.nested[..],
VtableClosure(c) => &c.nested[..],
VtableGenerator(c) => &c.nested[..],
VtableObject(d) => &d.nested[..],
VtableFnPointer(d) => &d.nested[..],
VtableTraitAlias(d) => &d.nested[..],
}
}
pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M> pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M>
where where
F: FnMut(N) -> M, F: FnMut(N) -> M,

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

@ -1,7 +1,6 @@
use super::Parser; use super::Parser;
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_span::source_map::DUMMY_SP;
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{kw, sym};
use syntax::ast::{self, Attribute, GenericBounds, GenericParam, GenericParamKind, WhereClause}; use syntax::ast::{self, Attribute, GenericBounds, GenericParam, GenericParamKind, WhereClause};
use syntax::token; use syntax::token;
@ -157,7 +156,10 @@ impl<'a> Parser<'a> {
}; };
Ok(ast::Generics { Ok(ast::Generics {
params, params,
where_clause: WhereClause { predicates: Vec::new(), span: DUMMY_SP }, where_clause: WhereClause {
predicates: Vec::new(),
span: self.prev_span.shrink_to_hi(),
},
span, span,
}) })
} }

View File

@ -14,7 +14,7 @@ use crate::check::FnCtxt;
use rustc::ty::subst::Subst; use rustc::ty::subst::Subst;
use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::subst::{InternalSubsts, SubstsRef};
use rustc::ty::GenericParamDefKind; use rustc::ty::GenericParamDefKind;
use rustc::ty::{self, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TypeFoldable, WithConstness}; use rustc::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TypeFoldable, WithConstness};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir; use rustc_hir as hir;
@ -67,7 +67,7 @@ pub enum MethodError<'tcx> {
// could lead to matches if satisfied, and a list of not-in-scope traits which may work. // could lead to matches if satisfied, and a list of not-in-scope traits which may work.
pub struct NoMatchData<'tcx> { pub struct NoMatchData<'tcx> {
pub static_candidates: Vec<CandidateSource>, pub static_candidates: Vec<CandidateSource>,
pub unsatisfied_predicates: Vec<TraitRef<'tcx>>, pub unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
pub out_of_scope_traits: Vec<DefId>, pub out_of_scope_traits: Vec<DefId>,
pub lev_candidate: Option<ty::AssocItem>, pub lev_candidate: Option<ty::AssocItem>,
pub mode: probe::Mode, pub mode: probe::Mode,
@ -76,7 +76,7 @@ pub struct NoMatchData<'tcx> {
impl<'tcx> NoMatchData<'tcx> { impl<'tcx> NoMatchData<'tcx> {
pub fn new( pub fn new(
static_candidates: Vec<CandidateSource>, static_candidates: Vec<CandidateSource>,
unsatisfied_predicates: Vec<TraitRef<'tcx>>, unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
out_of_scope_traits: Vec<DefId>, out_of_scope_traits: Vec<DefId>,
lev_candidate: Option<ty::AssocItem>, lev_candidate: Option<ty::AssocItem>,
mode: probe::Mode, mode: probe::Mode,

View File

@ -14,8 +14,7 @@ use rustc::session::config::nightly_options;
use rustc::ty::subst::{InternalSubsts, Subst, SubstsRef}; use rustc::ty::subst::{InternalSubsts, Subst, SubstsRef};
use rustc::ty::GenericParamDefKind; use rustc::ty::GenericParamDefKind;
use rustc::ty::{ use rustc::ty::{
self, ParamEnvAnd, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, self, ParamEnvAnd, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
WithConstness,
}; };
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
@ -78,7 +77,7 @@ struct ProbeContext<'a, 'tcx> {
/// Collects near misses when trait bounds for type parameters are unsatisfied and is only used /// Collects near misses when trait bounds for type parameters are unsatisfied and is only used
/// for error reporting /// for error reporting
unsatisfied_predicates: Vec<TraitRef<'tcx>>, unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
is_suggestion: IsSuggestion, is_suggestion: IsSuggestion,
} }
@ -1224,7 +1223,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
&self, &self,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
probes: ProbesIter, probes: ProbesIter,
possibly_unsatisfied_predicates: &mut Vec<TraitRef<'tcx>>, possibly_unsatisfied_predicates: &mut Vec<(
ty::Predicate<'tcx>,
Option<ty::Predicate<'tcx>>,
)>,
unstable_candidates: Option<&mut Vec<(&'b Candidate<'tcx>, Symbol)>>, unstable_candidates: Option<&mut Vec<(&'b Candidate<'tcx>, Symbol)>>,
) -> Option<PickResult<'tcx>> ) -> Option<PickResult<'tcx>>
where where
@ -1343,7 +1345,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
&self, &self,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
probe: &Candidate<'tcx>, probe: &Candidate<'tcx>,
possibly_unsatisfied_predicates: &mut Vec<TraitRef<'tcx>>, possibly_unsatisfied_predicates: &mut Vec<(
ty::Predicate<'tcx>,
Option<ty::Predicate<'tcx>>,
)>,
) -> ProbeResult { ) -> ProbeResult {
debug!("consider_probe: self_ty={:?} probe={:?}", self_ty, probe); debug!("consider_probe: self_ty={:?} probe={:?}", self_ty, probe);
@ -1398,21 +1403,45 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
let predicate = trait_ref.without_const().to_predicate(); let predicate = trait_ref.without_const().to_predicate();
let obligation = traits::Obligation::new(cause, self.param_env, predicate); let obligation = traits::Obligation::new(cause, self.param_env, predicate);
if !self.predicate_may_hold(&obligation) { if !self.predicate_may_hold(&obligation) {
if self.probe(|_| self.select_trait_candidate(trait_ref).is_err()) { if self.probe(|_| {
match self.select_trait_candidate(trait_ref) {
Err(_) => return true,
Ok(Some(vtable))
if !vtable.borrow_nested_obligations().is_empty() =>
{
for obligation in vtable.borrow_nested_obligations() {
// 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;
let o = self.resolve_vars_if_possible(obligation);
let predicate =
self.resolve_vars_if_possible(&predicate);
let p = if predicate == o.predicate {
// Avoid "`MyStruct: Foo` which is required by
// `MyStruct: Foo`" in E0599.
None
} else {
Some(predicate)
};
possibly_unsatisfied_predicates.push((o.predicate, p));
}
}
}
_ => {
// Some nested subobligation of this predicate
// failed.
result = ProbeResult::NoMatch;
let predicate = self.resolve_vars_if_possible(&predicate);
possibly_unsatisfied_predicates.push((predicate, None));
}
}
false
}) {
// This candidate's primary obligation doesn't even // This candidate's primary obligation doesn't even
// select - don't bother registering anything in // select - don't bother registering anything in
// `potentially_unsatisfied_predicates`. // `potentially_unsatisfied_predicates`.
return ProbeResult::NoMatch; return ProbeResult::NoMatch;
} else {
// Some nested subobligation of this predicate
// failed.
//
// FIXME: try to find the exact nested subobligation
// and point at it rather than reporting the entire
// trait-ref?
result = ProbeResult::NoMatch;
let trait_ref = self.resolve_vars_if_possible(&trait_ref);
possibly_unsatisfied_predicates.push(trait_ref);
} }
} }
vec![] vec![]
@ -1429,9 +1458,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
let o = self.resolve_vars_if_possible(&o); let o = self.resolve_vars_if_possible(&o);
if !self.predicate_may_hold(&o) { if !self.predicate_may_hold(&o) {
result = ProbeResult::NoMatch; result = ProbeResult::NoMatch;
if let &ty::Predicate::Trait(ref pred, _) = &o.predicate { possibly_unsatisfied_predicates.push((o.predicate, None));
possibly_unsatisfied_predicates.push(pred.skip_binder().trait_ref);
}
} }
} }

View File

@ -7,7 +7,7 @@ use rustc::hir::map as hir_map;
use rustc::hir::map::Map; use rustc::hir::map::Map;
use rustc::ty::print::with_crate_prefix; use rustc::ty::print::with_crate_prefix;
use rustc::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; use rustc::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace, Res}; use rustc_hir::def::{DefKind, Namespace, Res};
@ -16,6 +16,7 @@ use rustc_hir::intravisit;
use rustc_hir::{ExprKind, Node, QPath}; use rustc_hir::{ExprKind, Node, QPath};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::traits::Obligation; use rustc_infer::traits::Obligation;
use rustc_span::symbol::kw;
use rustc_span::{source_map, FileName, Span}; use rustc_span::{source_map, FileName, Span};
use syntax::ast; use syntax::ast;
use syntax::util::lev_distance; use syntax::util::lev_distance;
@ -496,7 +497,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !static_sources.is_empty() { if !static_sources.is_empty() {
err.note( err.note(
"found the following associated functions; to be used as methods, \ "found the following associated functions; to be used as methods, \
functions must have a `self` parameter", functions must have a `self` parameter",
); );
err.span_label(span, "this is an associated function, not a method"); err.span_label(span, "this is an associated function, not a method");
} }
@ -534,22 +535,159 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
report_candidates(span, &mut err, static_sources, sugg_span); report_candidates(span, &mut err, static_sources, sugg_span);
} }
let mut restrict_type_params = false;
if !unsatisfied_predicates.is_empty() { if !unsatisfied_predicates.is_empty() {
let def_span =
|def_id| self.tcx.sess.source_map().def_span(self.tcx.def_span(def_id));
let mut type_params = FxHashMap::default();
let mut bound_spans = vec![];
let mut collect_type_param_suggestions =
|self_ty: Ty<'_>, parent_pred: &ty::Predicate<'_>, obligation: &str| {
if let (ty::Param(_), ty::Predicate::Trait(p, _)) =
(&self_ty.kind, parent_pred)
{
if let ty::Adt(def, _) = p.skip_binder().trait_ref.self_ty().kind {
let id = self.tcx.hir().as_local_hir_id(def.did).unwrap();
let node = self.tcx.hir().get(id);
match node {
hir::Node::Item(hir::Item { kind, .. }) => {
if let Some(g) = kind.generics() {
let key = match &g.where_clause.predicates[..] {
[.., pred] => {
(pred.span().shrink_to_hi(), false)
}
[] => (
g.where_clause
.span_for_predicates_or_empty_place(),
true,
),
};
type_params
.entry(key)
.or_insert_with(FxHashSet::default)
.insert(obligation.to_owned());
}
}
_ => {}
}
}
}
};
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 {
// Point at the type that couldn't satisfy the bound.
ty::Adt(def, _) => bound_spans.push((def_span(def.did), msg)),
// Point at the trait object that couldn't satisfy the bound.
ty::Dynamic(preds, _) => {
for pred in *preds.skip_binder() {
match pred {
ty::ExistentialPredicate::Trait(tr) => {
bound_spans.push((def_span(tr.def_id), msg.clone()))
}
ty::ExistentialPredicate::Projection(_)
| 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))),
_ => {}
}
};
let mut format_pred = |pred| {
match pred {
ty::Predicate::Projection(pred) => {
// `<Foo as Iterator>::Item = String`.
let trait_ref =
pred.skip_binder().projection_ty.trait_ref(self.tcx);
let assoc = self
.tcx
.associated_item(pred.skip_binder().projection_ty.item_def_id);
let ty = pred.skip_binder().ty;
let obligation = format!("{}::{} = {}", trait_ref, assoc.ident, ty);
let quiet = format!(
"<_ as {}>::{} = {}",
trait_ref.print_only_trait_path(),
assoc.ident,
ty
);
bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
Some((obligation, trait_ref.self_ty()))
}
ty::Predicate::Trait(poly_trait_ref, _) => {
let p = poly_trait_ref.skip_binder().trait_ref;
let self_ty = p.self_ty();
let path = p.print_only_trait_path();
let obligation = format!("{}: {}", self_ty, path);
let quiet = format!("_: {}", path);
bound_span_label(self_ty, &obligation, &quiet);
Some((obligation, self_ty))
}
_ => None,
}
};
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())) .filter_map(|(pred, parent_pred)| {
.collect::<Vec<_>>(); format_pred(*pred).map(|(p, self_ty)| match parent_pred {
bound_list.sort(); None => format!("`{}`", p),
bound_list.dedup(); // #35677 Some(parent_pred) => match format_pred(*parent_pred) {
let bound_list = bound_list.join("\n"); None => format!("`{}`", p),
err.note(&format!( Some((parent_p, _)) => {
"the method `{}` exists but the following trait bounds \ collect_type_param_suggestions(self_ty, parent_pred, &p);
were not satisfied:\n{}", format!("`{}`\nwhich is required by `{}`", p, parent_p)
item_name, bound_list }
)); },
})
})
.enumerate()
.collect::<Vec<(usize, String)>>();
for ((span, empty_where), obligations) in type_params.into_iter() {
restrict_type_params = true;
err.span_suggestion_verbose(
span,
&format!(
"consider restricting the type parameter{s} to satisfy the \
trait bound{s}",
s = pluralize!(obligations.len())
),
format!(
"{} {}",
if empty_where { " where" } else { "," },
obligations.into_iter().collect::<Vec<_>>().join(", ")
),
Applicability::MaybeIncorrect,
);
}
bound_list.sort_by(|(_, a), (_, b)| a.cmp(&b)); // Sort alphabetically.
bound_list.dedup_by(|(_, a), (_, b)| a == b); // #35677
bound_list.sort_by_key(|(pos, _)| *pos); // Keep the original predicate order.
bound_spans.sort();
bound_spans.dedup();
for (span, msg) in bound_spans.into_iter() {
err.span_label(span, &msg);
}
if !bound_list.is_empty() {
let bound_list = bound_list
.into_iter()
.map(|(_, path)| path)
.collect::<Vec<_>>()
.join("\n");
err.note(&format!(
"the method `{}` exists but the following trait bounds were not \
satisfied:\n{}",
item_name, bound_list
));
}
} }
if actual.is_numeric() && actual.is_fresh() { if actual.is_numeric() && actual.is_fresh() || restrict_type_params {
} else { } else {
self.suggest_traits_to_import( self.suggest_traits_to_import(
&mut err, &mut err,
@ -558,6 +696,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_name, item_name,
source, source,
out_of_scope_traits, out_of_scope_traits,
&unsatisfied_predicates,
); );
} }
@ -757,6 +896,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_name: ast::Ident, item_name: ast::Ident,
source: SelfSource<'b>, source: SelfSource<'b>,
valid_out_of_scope_traits: Vec<DefId>, valid_out_of_scope_traits: Vec<DefId>,
unsatisfied_predicates: &[(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)],
) { ) {
if self.suggest_valid_traits(err, valid_out_of_scope_traits) { if self.suggest_valid_traits(err, valid_out_of_scope_traits) {
return; return;
@ -764,6 +904,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let type_is_local = self.type_derefs_to_local(span, rcvr_ty, source); let type_is_local = self.type_derefs_to_local(span, rcvr_ty, source);
let mut arbitrary_rcvr = vec![];
// There are no traits implemented, so lets suggest some traits to // There are no traits implemented, so lets suggest some traits to
// implement, by finding ones that have the item name, and are // implement, by finding ones that have the item name, and are
// legal to implement. // legal to implement.
@ -776,16 +917,71 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this isn't perfect (that is, there are cases when // this isn't perfect (that is, there are cases when
// implementing a trait would be legal but is rejected // implementing a trait would be legal but is rejected
// here). // here).
(type_is_local || info.def_id.is_local()) !unsatisfied_predicates.iter().any(|(p, _)| match p {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
ty::Predicate::Trait(t, _) => t.def_id() != info.def_id,
ty::Predicate::Projection(p) => p.item_def_id() != info.def_id,
_ => true,
}) && (type_is_local || info.def_id.is_local())
&& self && self
.associated_item(info.def_id, item_name, Namespace::ValueNS) .associated_item(info.def_id, item_name, Namespace::ValueNS)
.filter(|item| { .filter(|item| {
if let ty::AssocKind::Method = item.kind {
let id = self.tcx.hir().as_local_hir_id(item.def_id);
if let Some(hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(fn_sig, method),
..
})) = id.map(|id| self.tcx.hir().get(id))
{
let self_first_arg = match method {
hir::TraitMethod::Required([ident, ..]) => {
ident.name == kw::SelfLower
}
hir::TraitMethod::Provided(body_id) => {
match &self.tcx.hir().body(*body_id).params[..] {
[hir::Param {
pat:
hir::Pat {
kind:
hir::PatKind::Binding(
_,
_,
ident,
..,
),
..
},
..
}, ..] => ident.name == kw::SelfLower,
_ => false,
}
}
_ => false,
};
if !fn_sig.decl.implicit_self.has_implicit_self()
&& self_first_arg
{
if let Some(ty) = fn_sig.decl.inputs.get(0) {
arbitrary_rcvr.push(ty.span);
}
return false;
}
}
}
// We only want to suggest public or local traits (#45781). // We only want to suggest public or local traits (#45781).
item.vis == ty::Visibility::Public || info.def_id.is_local() item.vis == ty::Visibility::Public || info.def_id.is_local()
}) })
.is_some() .is_some()
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for span in &arbitrary_rcvr {
err.span_label(
*span,
"the method might not be found because of this arbitrary self type",
);
}
if !candidates.is_empty() { if !candidates.is_empty() {
// Sort from most relevant to least relevant. // Sort from most relevant to least relevant.
@ -808,7 +1004,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let message = |action| { let message = |action| {
format!( format!(
"the following {traits_define} an item `{name}`, perhaps you need to {action} \ "the following {traits_define} an item `{name}`, perhaps you need to {action} \
{one_of_them}:", {one_of_them}:",
traits_define = traits_define =
if candidates.len() == 1 { "trait defines" } else { "traits define" }, if candidates.len() == 1 { "trait defines" } else { "traits define" },
action = action, action = action,
@ -906,19 +1102,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
if !suggested { if !suggested {
let mut msg = message(if let Some(param) = param_type { let action = if let Some(param) = param_type {
format!("restrict type parameter `{}` with", param) format!("restrict type parameter `{}` with", param)
} else { } else {
// FIXME: it might only need to be imported into scope, not implemented.
"implement".to_string() "implement".to_string()
}); };
for (i, trait_info) in candidates.iter().enumerate() { let mut use_note = true;
msg.push_str(&format!( if let [trait_info] = &candidates[..] {
"\ncandidate #{}: `{}`", if let Some(span) = self.tcx.hir().span_if_local(trait_info.def_id) {
i + 1, err.span_note(
self.tcx.def_path_str(trait_info.def_id), self.tcx.sess.source_map().def_span(span),
)); &format!(
"`{}` defines an item `{}`, perhaps you need to {} it",
self.tcx.def_path_str(trait_info.def_id),
item_name,
action
),
);
use_note = false
}
}
if use_note {
let mut msg = message(action);
for (i, trait_info) in candidates.iter().enumerate() {
msg.push_str(&format!(
"\ncandidate #{}: `{}`",
i + 1,
self.tcx.def_path_str(trait_info.def_id),
));
}
err.note(&msg[..]);
} }
err.note(&msg[..]);
} }
} }
} }

View File

@ -5,8 +5,11 @@ LL | const X: i32 = <i32>::ID;
| ^^ associated item not found in `i32` | ^^ associated item not found in `i32`
| |
= 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 `ID`, perhaps you need to implement it: note: `Foo` defines an item `ID`, perhaps you need to implement it
candidate #1: `Foo` --> $DIR/associated-const-no-item.rs:1:1
|
LL | trait Foo {
| ^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,8 +5,11 @@ LL | a.test_mut();
| ^^^^^^^^ help: there is a method with a similar name: `get_mut` | ^^^^^^^^ help: there is a method with a similar name: `get_mut`
| |
= 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 `test_mut`, perhaps you need to implement it: note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
candidate #1: `MyIter` --> $DIR/auto-ref-slice-plus-ref.rs:14:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error[E0599]: no method named `test` found for struct `std::vec::Vec<{integer}>` in the current scope error[E0599]: no method named `test` found for struct `std::vec::Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:8:7 --> $DIR/auto-ref-slice-plus-ref.rs:8:7
@ -15,8 +18,11 @@ LL | a.test();
| ^^^^ method not found in `std::vec::Vec<{integer}>` | ^^^^ method not found in `std::vec::Vec<{integer}>`
| |
= 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 `test`, perhaps you need to implement it: note: `MyIter` defines an item `test`, perhaps you need to implement it
candidate #1: `MyIter` --> $DIR/auto-ref-slice-plus-ref.rs:14:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:10:11 --> $DIR/auto-ref-slice-plus-ref.rs:10:11
@ -25,8 +31,11 @@ LL | ([1]).test();
| ^^^^ method not found in `[{integer}; 1]` | ^^^^ method not found in `[{integer}; 1]`
| |
= 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 `test`, perhaps you need to implement it: note: `MyIter` defines an item `test`, perhaps you need to implement it
candidate #1: `MyIter` --> $DIR/auto-ref-slice-plus-ref.rs:14:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:11:12 --> $DIR/auto-ref-slice-plus-ref.rs:11:12
@ -35,8 +44,11 @@ LL | (&[1]).test();
| ^^^^ method not found in `&[{integer}; 1]` | ^^^^ method not found in `&[{integer}; 1]`
| |
= 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 `test`, perhaps you need to implement it: note: `MyIter` defines an item `test`, perhaps you need to implement it
candidate #1: `MyIter` --> $DIR/auto-ref-slice-plus-ref.rs:14:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

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
| doesn't satisfy `Bar<NotClone>: std::clone::Clone`
...
LL | struct NotClone;
| ---------------- doesn't satisfy `NotClone: 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` `NotClone: std::clone::Clone`
which is required by `Bar<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

@ -8,8 +8,11 @@ LL | f1.foo(1usize);
| ^^^ method not found in `Bar` | ^^^ method not found in `Bar`
| |
= 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`, perhaps you need to implement it: note: `Foo` defines an item `foo`, perhaps you need to implement it
candidate #1: `Foo` --> $DIR/issue-21659-show-relevant-trait-impls-3.rs:1:1
|
LL | trait Foo<A> {
| ^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -126,8 +126,11 @@ LL | 1u64.method2();
| ^^^^^^^ method not found in `u64` | ^^^^^^^ method not found in `u64`
| |
= 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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&u64>>` in the current scope error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&u64>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:47:44 --> $DIR/no-method-suggested-traits.rs:47:44
@ -136,8 +139,11 @@ LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>` | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>`
| |
= 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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method2` found for struct `no_method_suggested_traits::Foo` in the current scope error[E0599]: no method named `method2` found for struct `no_method_suggested_traits::Foo` in the current scope
--> $DIR/no-method-suggested-traits.rs:50:37 --> $DIR/no-method-suggested-traits.rs:50:37
@ -146,8 +152,11 @@ LL | no_method_suggested_traits::Foo.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Foo` | ^^^^^^^ method not found in `no_method_suggested_traits::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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:52:71 --> $DIR/no-method-suggested-traits.rs:52:71
@ -156,8 +165,11 @@ LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).metho
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method2` found for enum `no_method_suggested_traits::Bar` in the current scope error[E0599]: no method named `method2` found for enum `no_method_suggested_traits::Bar` in the current scope
--> $DIR/no-method-suggested-traits.rs:54:40 --> $DIR/no-method-suggested-traits.rs:54:40
@ -166,8 +178,11 @@ LL | no_method_suggested_traits::Bar::X.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Bar` | ^^^^^^^ method not found in `no_method_suggested_traits::Bar`
| |
= 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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:56:74 --> $DIR/no-method-suggested-traits.rs:56:74
@ -176,8 +191,11 @@ LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).me
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>`
| |
= 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 `method2`, perhaps you need to implement it: note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
candidate #1: `foo::Bar` --> $DIR/no-method-suggested-traits.rs:8:5
|
LL | pub trait Bar {
| ^^^^^^^^^^^^^
error[E0599]: no method named `method3` found for struct `Foo` in the current scope error[E0599]: no method named `method3` found for struct `Foo` in the current scope
--> $DIR/no-method-suggested-traits.rs:59:9 --> $DIR/no-method-suggested-traits.rs:59:9

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`
which is required by `*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,25 @@ 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> {
| -------------------- doesn't satisfy `_: std::iter::Iterator`
...
LL | pub struct TakeWhile<I, P> {
| -------------------------- 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:
`&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` `<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]> as std::iter::Iterator>::Item = &_`
`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` 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::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:10:39: 13:6 found_e:_]>>: std::iter::Iterator`
which is required by `&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`
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,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,8 @@ 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`
`<{integer} as std::ops::Deref>::Target = _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,12 +1,11 @@
error[E0599]: no method named `foo` found for reference `&dyn Foo` in the current scope error[E0599]: no method named `foo` found for reference `&dyn Foo` in the current scope
--> $DIR/issue-5153.rs:10:27 --> $DIR/issue-5153.rs:10:27
| |
LL | fn foo(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | (&5isize as &dyn Foo).foo(); LL | (&5isize as &dyn Foo).foo();
| ^^^ method not found in `&dyn Foo` | ^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `Foo`
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,8 +6,11 @@ LL | a.f();
| |
= note: `a` is a function, perhaps you wish to call it = note: `a` is a function, perhaps you wish to call it
= 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 `f`, perhaps you need to implement it: note: `Trait` defines an item `f`, perhaps you need to implement it
candidate #1: `Trait` --> $DIR/issue-57362-1.rs:8:1
|
LL | trait Trait {
| ^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,8 +5,11 @@ LL | let x = <fn (&())>::make_g();
| ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`
| |
= 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 `make_g`, perhaps you need to implement it: note: `X` defines an item `make_g`, perhaps you need to implement it
candidate #1: `X` --> $DIR/issue-57362-2.rs:8:1
|
LL | trait X {
| ^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -35,17 +35,20 @@ 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
| doesn't satisfy `Foo: 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` `Foo: std::iter::Iterator`
which is required by `&mut 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 trait defines an item `take`, perhaps you need to implement it:
candidate #1: `std::io::Read` candidate #1: `std::iter::Iterator`
candidate #2: `std::iter::Iterator`
error[E0061]: this function takes 3 arguments but 0 arguments were supplied error[E0061]: this function takes 3 arguments but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:21:7 --> $DIR/method-call-err-msg.rs:21:7

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,27 @@
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]>`
| |
| 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
|
LL | pub struct Filter<I, P> {
| ----------------------- 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:
`&mut 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] as std::ops::FnOnce<(&&str,)>>::Output = bool`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` 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]: std::ops::FnMut<(&&str,)>`
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`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:11:39: 11:53]>: std::iter::Iterator`
which is required by `&mut 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;
| ----------- doesn't satisfy `Foo: 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

@ -13,8 +13,11 @@ LL | ["hi"].bind(|x| [x] );
| ^^^^ method not found in `[&str; 1]` | ^^^^ method not found in `[&str; 1]`
| |
= 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 `bind`, perhaps you need to implement it: note: `VecMonad` defines an item `bind`, perhaps you need to implement it
candidate #1: `VecMonad` --> $DIR/issue-2149.rs:1:1
|
LL | trait VecMonad<A> {
| ^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -1,22 +1,20 @@
error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:11:7 --> $DIR/object-pointer-types.rs:11:7
| |
LL | fn owned(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | x.owned(); LL | x.owned();
| ^^^^^ method not found in `&dyn Foo` | ^^^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `owned`, perhaps you need to implement it:
candidate #1: `Foo`
error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:17:7 --> $DIR/object-pointer-types.rs:17:7
| |
LL | fn owned(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | x.owned(); LL | x.owned();
| ^^^^^ method not found in `&mut dyn Foo` | ^^^^^ method not found in `&mut dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `owned`, perhaps you need to implement it:
candidate #1: `Foo`
error[E0599]: no method named `managed` found for struct `std::boxed::Box<(dyn Foo + 'static)>` in the current scope error[E0599]: no method named `managed` found for struct `std::boxed::Box<(dyn Foo + 'static)>` in the current scope
--> $DIR/object-pointer-types.rs:23:7 --> $DIR/object-pointer-types.rs:23:7

View File

@ -2,16 +2,14 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
--> $DIR/point-at-arbitrary-self-type-trait-method.rs:9:7 --> $DIR/point-at-arbitrary-self-type-trait-method.rs:9:7
| |
LL | trait B { fn foo(self: Box<Self>); } LL | trait B { fn foo(self: Box<Self>); }
| --- the method is available for `std::boxed::Box<A>` here | --- --------- the method might not be found because of this arbitrary self type
| |
| the method is available for `std::boxed::Box<A>` here
LL | struct A; LL | struct A;
| --------- method `foo` not found for this | --------- method `foo` not found for this
... ...
LL | A.foo() LL | A.foo()
| ^^^ method not found in `A` | ^^^ method not found in `A`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `B`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,16 +2,22 @@ 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
| doesn't satisfy `MyStruct: 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: `Foo` defines an item `foo_one`, perhaps you need to implement it
candidate #1: `Foo` --> $DIR/specialization-trait-not-implemented.rs:7:1
|
LL | trait Foo {
| ^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -0,0 +1,31 @@
#[derive(Default, PartialEq)]
struct Foo<T> {
bar: Box<[T]>,
}
trait Bar {
fn foo(&self) {}
}
impl<T: Default + Bar> Bar for Foo<T> {}
impl<T> Foo<T> {
fn bar(&self) {
self.foo();
//~^ ERROR no method named `foo` found for reference `&Foo<T>` in the current scope
}
}
struct Fin<T> where T: Bar {
bar: Box<[T]>,
}
impl<T: Default + Bar> Bar for Fin<T> {}
impl<T: Bar> Fin<T> {
fn bar(&self) {
self.foo();
//~^ ERROR no method named `foo` found for reference `&Fin<T>` in the current scope
}
}
fn main() {}

View File

@ -0,0 +1,39 @@
error[E0599]: no method named `foo` found for reference `&Foo<T>` in the current scope
--> $DIR/missing-trait-bounds-for-method-call.rs:14:14
|
LL | struct Foo<T> {
| ------------- doesn't satisfy `Foo<T>: Bar`
...
LL | self.foo();
| ^^^ method not found in `&Foo<T>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`T: Bar`
which is required by `Foo<T>: Bar`
`T: std::default::Default`
which is required by `Foo<T>: Bar`
help: consider restricting the type parameters to satisfy the trait bounds
|
LL | struct Foo<T> where T: Bar, T: std::default::Default {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `foo` found for reference `&Fin<T>` in the current scope
--> $DIR/missing-trait-bounds-for-method-call.rs:27:14
|
LL | struct Fin<T> where T: Bar {
| -------------------------- doesn't satisfy `Fin<T>: Bar`
...
LL | self.foo();
| ^^^ method not found in `&Fin<T>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`T: std::default::Default`
which is required by `Fin<T>: Bar`
help: consider restricting the type parameter to satisfy the trait bound
|
LL | struct Fin<T> where T: Bar, T: std::default::Default {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.

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> {
| ------------------------------ 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:
`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`
= 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

@ -8,8 +8,11 @@ LL | S.a();
| ^ method not found in `S` | ^ method not found in `S`
| |
= 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 `a`, perhaps you need to implement it: note: `method::A` defines an item `a`, perhaps you need to implement it
candidate #1: `method::A` --> $DIR/trait-item-privacy.rs:6:5
|
LL | trait A {
| ^^^^^^^
error[E0599]: no method named `b` found for struct `S` in the current scope error[E0599]: no method named `b` found for struct `S` in the current scope
--> $DIR/trait-item-privacy.rs:68:7 --> $DIR/trait-item-privacy.rs:68:7
@ -49,8 +52,11 @@ LL | S::a(&S);
| ^ function or associated item not found in `S` | ^ function or associated item not found in `S`
| |
= 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 `a`, perhaps you need to implement it: note: `method::A` defines an item `a`, perhaps you need to implement it
candidate #1: `method::A` --> $DIR/trait-item-privacy.rs:6:5
|
LL | trait A {
| ^^^^^^^
error[E0599]: no function or associated item named `b` found for struct `S` in the current scope error[E0599]: no function or associated item named `b` found for struct `S` in the current scope
--> $DIR/trait-item-privacy.rs:80:8 --> $DIR/trait-item-privacy.rs:80:8
@ -83,8 +89,11 @@ LL | S::A;
| ^ associated item not found in `S` | ^ associated item not found in `S`
| |
= 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 `A`, perhaps you need to implement it: note: `assoc_const::A` defines an item `A`, perhaps you need to implement it
candidate #1: `assoc_const::A` --> $DIR/trait-item-privacy.rs:24:5
|
LL | trait A {
| ^^^^^^^
error[E0599]: no associated item named `B` found for struct `S` in the current scope error[E0599]: no associated item named `B` found for struct `S` in the current scope
--> $DIR/trait-item-privacy.rs:98:8 --> $DIR/trait-item-privacy.rs:98:8

View File

@ -15,8 +15,11 @@ LL | 3i32.test();
| ^^^^ method not found in `i32` | ^^^^ method not found in `i32`
| |
= 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 `test`, perhaps you need to implement it: note: `Foo` defines an item `test`, perhaps you need to implement it
candidate #1: `Foo` --> $DIR/trivial-bounds-leak.rs:4:1
|
LL | pub trait Foo {
| ^^^^^^^^^^^^^
error[E0277]: the trait bound `i32: Foo` is not satisfied error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/trivial-bounds-leak.rs:25:15 --> $DIR/trivial-bounds-leak.rs:25:15

View File

@ -11,16 +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
| doesn't satisfy `U5<CloneNoCopy>: std::clone::Clone`
...
LL | struct CloneNoCopy;
| ------------------- doesn't satisfy `CloneNoCopy: 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`
= help: items from traits can only be used if the trait is implemented and in scope which is required by `U5<CloneNoCopy>: std::clone::Clone`
= note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

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,14 +1,25 @@
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 {
| ---------
| |
| doesn't satisfy `dyn Foo: std::clone::Clone`
| doesn't satisfy `dyn Foo: 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>);
| ------------------------------------- doesn't satisfy `std::boxed::Box<dyn Foo>: 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::marker::Sized`
= help: items from traits can only be used if the trait is implemented and in scope which is required by `std::boxed::Box<dyn Foo>: std::clone::Clone`
= note: the following trait defines an item `clone`, perhaps you need to implement it: `dyn Foo: std::clone::Clone`
candidate #1: `std::clone::Clone` which is required by `std::boxed::Box<dyn Foo>: std::clone::Clone`
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
#[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 {
| -------- doesn't satisfy `R: 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>);
| ------------------------------------- doesn't satisfy `std::boxed::Box<R>: 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`
which is required by `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`