Fix ICE that occurs when an associated const is ambiguous.

Also change several error messages to refer to "items" rather than
"methods", since associated items that require resolution during type
checking are not always methods.
This commit is contained in:
Sean Patrick Santos 2015-05-02 23:30:59 -06:00
parent 4774d5d9a1
commit b4bbf3a88d
34 changed files with 182 additions and 148 deletions

View File

@ -16,12 +16,10 @@ use middle::def;
use middle::privacy::{AllPublic, DependsOn, LastPrivate, LastMod};
use middle::subst;
use middle::traits;
use middle::ty::*;
use middle::ty;
use middle::ty::{self, AsPredicate, ToPolyTraitRef};
use middle::infer;
use util::ppaux::Repr;
use std::rc::Rc;
use syntax::ast::DefId;
use syntax::ast;
use syntax::codemap::Span;
@ -39,7 +37,7 @@ pub enum MethodError {
// Did not find an applicable method, but we did find various
// static methods that may apply, as well as a list of
// not-in-scope traits which may work.
NoMatch(Vec<CandidateSource>, Vec<ast::DefId>),
NoMatch(Vec<CandidateSource>, Vec<ast::DefId>, probe::Mode),
// Multiple methods might apply.
Ambiguity(Vec<CandidateSource>),
@ -62,7 +60,7 @@ type ItemIndex = usize; // just for doc purposes
pub fn exists<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
method_name: ast::Name,
self_ty: Ty<'tcx>,
self_ty: ty::Ty<'tcx>,
call_expr_id: ast::NodeId)
-> bool
{
@ -92,11 +90,11 @@ pub fn exists<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
pub fn lookup<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
method_name: ast::Name,
self_ty: Ty<'tcx>,
supplied_method_types: Vec<Ty<'tcx>>,
self_ty: ty::Ty<'tcx>,
supplied_method_types: Vec<ty::Ty<'tcx>>,
call_expr: &'tcx ast::Expr,
self_expr: &'tcx ast::Expr)
-> Result<MethodCallee<'tcx>, MethodError>
-> Result<ty::MethodCallee<'tcx>, MethodError>
{
debug!("lookup(method_name={}, self_ty={}, call_expr={}, self_expr={})",
method_name.repr(fcx.tcx()),
@ -115,9 +113,9 @@ pub fn lookup_in_trait<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
self_expr: Option<&ast::Expr>,
m_name: ast::Name,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
self_ty: ty::Ty<'tcx>,
opt_input_types: Option<Vec<ty::Ty<'tcx>>>)
-> Option<ty::MethodCallee<'tcx>>
{
lookup_in_trait_adjusted(fcx, span, self_expr, m_name, trait_def_id,
0, false, self_ty, opt_input_types)
@ -139,9 +137,9 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
trait_def_id: DefId,
autoderefs: usize,
unsize: bool,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
self_ty: ty::Ty<'tcx>,
opt_input_types: Option<Vec<ty::Ty<'tcx>>>)
-> Option<ty::MethodCallee<'tcx>>
{
debug!("lookup_in_trait_adjusted(self_ty={}, self_expr={}, m_name={}, trait_def_id={})",
self_ty.repr(fcx.tcx()),
@ -186,7 +184,9 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// Trait must have a method named `m_name` and it should not have
// type parameters or early-bound regions.
let tcx = fcx.tcx();
let (method_num, method_ty) = trait_method(tcx, trait_def_id, m_name).unwrap();
let (method_num, method_ty) = trait_item(tcx, trait_def_id, m_name)
.and_then(|(idx, item)| item.as_opt_method().map(|m| (idx, m)))
.unwrap();
assert_eq!(method_ty.generics.types.len(subst::FnSpace), 0);
assert_eq!(method_ty.generics.regions.len(subst::FnSpace), 0);
@ -288,10 +288,10 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
}
let callee = MethodCallee {
origin: MethodTypeParam(MethodParam{trait_ref: trait_ref.clone(),
method_num: method_num,
impl_def_id: None}),
let callee = ty::MethodCallee {
origin: ty::MethodTypeParam(ty::MethodParam{trait_ref: trait_ref.clone(),
method_num: method_num,
impl_def_id: None}),
ty: fty,
substs: trait_ref.substs.clone()
};
@ -304,7 +304,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
pub fn resolve_ufcs<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
method_name: ast::Name,
self_ty: Ty<'tcx>,
self_ty: ty::Ty<'tcx>,
expr_id: ast::NodeId)
-> Result<(def::Def, LastPrivate), MethodError>
{
@ -322,9 +322,9 @@ pub fn resolve_ufcs<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
_ => def::FromTrait(pick.item.container().id())
};
let def_result = match pick.item {
ImplOrTraitItem::MethodTraitItem(..) => def::DefMethod(def_id, provenance),
ImplOrTraitItem::ConstTraitItem(..) => def::DefAssociatedConst(def_id, provenance),
ImplOrTraitItem::TypeTraitItem(..) => {
ty::ImplOrTraitItem::MethodTraitItem(..) => def::DefMethod(def_id, provenance),
ty::ImplOrTraitItem::ConstTraitItem(..) => def::DefAssociatedConst(def_id, provenance),
ty::ImplOrTraitItem::TypeTraitItem(..) => {
fcx.tcx().sess.span_bug(span, "resolve_ufcs: probe picked associated type");
}
};
@ -332,31 +332,30 @@ pub fn resolve_ufcs<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
/// Find method with name `method_name` defined in `trait_def_id` and return it, along with its
/// index (or `None`, if no such method).
fn trait_method<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_def_id: ast::DefId,
method_name: ast::Name)
-> Option<(usize, Rc<ty::Method<'tcx>>)>
/// Find item with name `item_name` defined in `trait_def_id` and return it, along with its
/// index (or `None`, if no such item).
fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_def_id: ast::DefId,
item_name: ast::Name)
-> Option<(usize, ty::ImplOrTraitItem<'tcx>)>
{
let trait_items = ty::trait_items(tcx, trait_def_id);
trait_items
.iter()
.enumerate()
.find(|&(_, ref item)| item.name() == method_name)
.and_then(|(idx, item)| item.as_opt_method().map(|m| (idx, m)))
.find(|&(_, ref item)| item.name() == item_name)
.map(|(num, item)| (num, (*item).clone()))
}
fn impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
impl_def_id: ast::DefId,
method_name: ast::Name)
-> Option<Rc<ty::Method<'tcx>>>
fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>,
impl_def_id: ast::DefId,
item_name: ast::Name)
-> Option<ty::ImplOrTraitItem<'tcx>>
{
let impl_items = tcx.impl_items.borrow();
let impl_items = impl_items.get(&impl_def_id).unwrap();
impl_items
.iter()
.map(|&did| ty::impl_or_trait_item(tcx, did.def_id()))
.find(|m| m.name() == method_name)
.and_then(|item| item.as_opt_method())
.find(|m| m.name() == item_name)
}

View File

@ -136,7 +136,7 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let steps = if mode == Mode::MethodCall {
match create_steps(fcx, span, self_ty) {
Some(steps) => steps,
None => return Err(MethodError::NoMatch(Vec::new(), Vec::new())),
None => return Err(MethodError::NoMatch(Vec::new(), Vec::new(), mode)),
}
} else {
vec![CandidateStep {
@ -866,7 +866,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
}
}
}).collect(),
Some(Err(MethodError::NoMatch(_, others))) => {
Some(Err(MethodError::NoMatch(_, others, _))) => {
assert!(others.is_empty());
vec![]
}
@ -877,7 +877,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
None => vec![],
};
Err(MethodError::NoMatch(static_candidates, out_of_scope_traits))
Err(MethodError::NoMatch(static_candidates, out_of_scope_traits, self.mode))
}
fn pick_core(&mut self) -> Option<PickResult<'tcx>> {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Give useful errors and suggestions to users when a method can't be
//! Give useful errors and suggestions to users when an item can't be
//! found or is otherwise invalid.
use CrateCtxt;
@ -27,12 +27,13 @@ use syntax::print::pprust;
use std::cell;
use std::cmp::Ordering;
use super::{MethodError, CandidateSource, impl_method, trait_method};
use super::{MethodError, CandidateSource, impl_item, trait_item};
use super::probe::Mode;
pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
rcvr_ty: Ty<'tcx>,
method_name: ast::Name,
item_name: ast::Name,
rcvr_expr: Option<&ast::Expr>,
error: MethodError)
{
@ -42,28 +43,30 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
match error {
MethodError::NoMatch(static_sources, out_of_scope_traits) => {
MethodError::NoMatch(static_sources, out_of_scope_traits, mode) => {
let cx = fcx.tcx();
let method_ustring = method_name.user_string(cx);
let item_ustring = item_name.user_string(cx);
fcx.type_error_message(
span,
|actual| {
format!("type `{}` does not implement any \
method in scope named `{}`",
actual,
method_ustring)
format!("no {} named `{}` found for type `{}` \
in the current scope",
if mode == Mode::MethodCall { "method" }
else { "associated item" },
item_ustring,
actual)
},
rcvr_ty,
None);
// If the method has the name of a field, give a help note
// If the item has the name of a field, give a help note
if let (&ty::ty_struct(did, _), Some(_)) = (&rcvr_ty.sty, rcvr_expr) {
let fields = ty::lookup_struct_fields(cx, did);
if fields.iter().any(|f| f.name == method_name) {
if fields.iter().any(|f| f.name == item_name) {
cx.sess.span_note(span,
&format!("use `(s.{0})(...)` if you meant to call the \
function stored in the `{0}` field", method_ustring));
function stored in the `{0}` field", item_ustring));
}
}
@ -72,25 +75,25 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span,
"found defined static methods, maybe a `self` is missing?");
report_candidates(fcx, span, method_name, static_sources);
report_candidates(fcx, span, item_name, static_sources);
}
suggest_traits_to_import(fcx, span, rcvr_ty, method_name,
suggest_traits_to_import(fcx, span, rcvr_ty, item_name,
rcvr_expr, out_of_scope_traits)
}
MethodError::Ambiguity(sources) => {
span_err!(fcx.sess(), span, E0034,
"multiple applicable methods in scope");
"multiple applicable items in scope");
report_candidates(fcx, span, method_name, sources);
report_candidates(fcx, span, item_name, sources);
}
MethodError::ClosureAmbiguity(trait_def_id) => {
let msg = format!("the `{}` method from the `{}` trait cannot be explicitly \
invoked on this closure as we have not yet inferred what \
kind of closure it is",
method_name.user_string(fcx.tcx()),
item_name.user_string(fcx.tcx()),
ty::item_path_str(fcx.tcx(), trait_def_id));
let msg = if let Some(callee) = rcvr_expr {
format!("{}; use overloaded call notation instead (e.g., `{}()`)",
@ -104,7 +107,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fn report_candidates(fcx: &FnCtxt,
span: Span,
method_name: ast::Name,
item_name: ast::Name,
mut sources: Vec<CandidateSource>) {
sources.sort();
sources.dedup();
@ -112,11 +115,11 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
for (idx, source) in sources.iter().enumerate() {
match *source {
CandidateSource::ImplSource(impl_did) => {
// Provide the best span we can. Use the method, if local to crate, else
// the impl, if local to crate (method may be defaulted), else the call site.
let method = impl_method(fcx.tcx(), impl_did, method_name).unwrap();
// Provide the best span we can. Use the item, if local to crate, else
// the impl, if local to crate (item may be defaulted), else the call site.
let item = impl_item(fcx.tcx(), impl_did, item_name).unwrap();
let impl_span = fcx.tcx().map.def_id_span(impl_did, span);
let method_span = fcx.tcx().map.def_id_span(method.def_id, impl_span);
let item_span = fcx.tcx().map.def_id_span(item.def_id(), impl_span);
let impl_ty = check::impl_self_ty(fcx, span, impl_did).ty;
@ -127,16 +130,16 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
trait_ref.def_id)),
};
span_note!(fcx.sess(), method_span,
span_note!(fcx.sess(), item_span,
"candidate #{} is defined in an impl{} for the type `{}`",
idx + 1,
insertion,
impl_ty.user_string(fcx.tcx()));
}
CandidateSource::TraitSource(trait_did) => {
let (_, method) = trait_method(fcx.tcx(), trait_did, method_name).unwrap();
let method_span = fcx.tcx().map.def_id_span(method.def_id, span);
span_note!(fcx.sess(), method_span,
let (_, item) = trait_item(fcx.tcx(), trait_did, item_name).unwrap();
let item_span = fcx.tcx().map.def_id_span(item.def_id(), span);
span_note!(fcx.sess(), item_span,
"candidate #{} is defined in the trait `{}`",
idx + 1,
ty::item_path_str(fcx.tcx(), trait_did));
@ -152,19 +155,19 @@ pub type AllTraitsVec = Vec<TraitInfo>;
fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
rcvr_ty: Ty<'tcx>,
method_name: ast::Name,
item_name: ast::Name,
rcvr_expr: Option<&ast::Expr>,
valid_out_of_scope_traits: Vec<ast::DefId>)
{
let tcx = fcx.tcx();
let method_ustring = method_name.user_string(tcx);
let item_ustring = item_name.user_string(tcx);
if !valid_out_of_scope_traits.is_empty() {
let mut candidates = valid_out_of_scope_traits;
candidates.sort();
candidates.dedup();
let msg = format!(
"methods from traits can only be called if the trait is in scope; \
"items from traits can only be used if the trait is in scope; \
the following {traits_are} implemented but not in scope, \
perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {"trait is"} else {"traits are"},
@ -185,7 +188,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let type_is_local = type_derefs_to_local(fcx, span, rcvr_ty, rcvr_expr);
// there's no implemented traits, so lets suggest some traits to
// implement, by finding ones that have the method name, and are
// implement, by finding ones that have the item name, and are
// legal to implement.
let mut candidates = all_traits(fcx.ccx)
.filter(|info| {
@ -196,7 +199,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// implementing a trait would be legal but is rejected
// here).
(type_is_local || ast_util::is_local(info.def_id))
&& trait_method(tcx, info.def_id, method_name).is_some()
&& trait_item(tcx, info.def_id, item_name).is_some()
})
.collect::<Vec<_>>();
@ -209,12 +212,12 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// of a type parameter: suggest adding a trait bound rather
// than implementing.
let msg = format!(
"methods from traits can only be called if the trait is implemented and in scope; \
the following {traits_define} a method `{name}`, \
"items from traits can only be used if the trait is implemented and in scope; \
the following {traits_define} an item `{name}`, \
perhaps you need to implement {one_of_them}:",
traits_define = if candidates.len() == 1 {"trait defines"} else {"traits define"},
one_of_them = if candidates.len() == 1 {"it"} else {"one of them"},
name = method_ustring);
name = item_ustring);
fcx.sess().fileline_help(span, &msg[..]);

View File

@ -0,0 +1,33 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_consts)]
trait Foo {
const ID: i32;
}
trait Bar {
const ID: i32;
}
impl Foo for i32 {
const ID: i32 = 1;
}
impl Bar for i32 {
const ID: i32 = 3;
}
const X: i32 = <i32>::ID; //~ ERROR E0034
fn main() {
assert_eq!(1, X);
}

View File

@ -15,11 +15,11 @@ fn main() {
// vectors to slices then automatically create a self reference.
let mut a = vec!(0);
a.test_mut(); //~ ERROR does not implement any method in scope named `test_mut`
a.test(); //~ ERROR does not implement any method in scope named `test`
a.test_mut(); //~ ERROR no method named `test_mut` found
a.test(); //~ ERROR no method named `test` found
([1]).test(); //~ ERROR does not implement any method in scope named `test`
(&[1]).test(); //~ ERROR does not implement any method in scope named `test`
([1]).test(); //~ ERROR no method named `test` found
(&[1]).test(); //~ ERROR no method named `test` found
}
trait MyIter {

View File

@ -60,5 +60,5 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> cat {
fn main() {
let nyan: Box<noisy> = box cat(0, 2, "nyan".to_string()) as Box<noisy>;
nyan.eat(); //~ ERROR does not implement any method in scope named `eat`
nyan.eat(); //~ ERROR no method named `eat` found
}

View File

@ -38,7 +38,7 @@ mod NoImport {
use Lib::TheStruct;
fn call_the_fn(s: &TheStruct) {
s.the_fn(); //~ ERROR does not implement any method in scope named `the_fn`
s.the_fn(); //~ ERROR no method named `the_fn` found
}
}

View File

@ -30,7 +30,7 @@ mod NoImport {
use coherence_inherent_cc_lib::TheStruct;
fn call_the_fn(s: &TheStruct) {
s.the_fn(); //~ ERROR does not implement any method in scope named `the_fn`
s.the_fn(); //~ ERROR no method named `the_fn` found
}
}

View File

@ -26,6 +26,6 @@ fn foo(i:isize) -> foo {
fn main() {
let x = foo(10);
let _y = x.clone();
//~^ ERROR does not implement any method in scope
//~^ ERROR no method named `clone` found
println!("{:?}", x);
}

View File

@ -24,7 +24,7 @@ pub mod b {
use b::B;
fn foo(b: &B) {
b.foo(); //~ ERROR: does not implement any method in scope named
b.foo(); //~ ERROR: no method named `foo` found
}
}

View File

@ -31,7 +31,7 @@ impl Node for Stuff {
}
fn iterate<N: Node, G: Graph<N>>(graph: &G) {
for node in graph.iter() { //~ ERROR does not implement any method in scope named
for node in graph.iter() { //~ ERROR no method named `iter` found
node.zomg(); //~ error: the type of this value must be known in this context
}
}

View File

@ -14,6 +14,6 @@ struct Obj<F> where F: FnMut() -> u32 {
fn main() {
let o = Obj { closure: || 42 };
o.closure(); //~ ERROR does not implement any method in scope named `closure`
o.closure(); //~ ERROR no method named `closure` found
//~^ NOTE use `(s.closure)(...)` if you meant to call the function stored in the `closure` field
}

View File

@ -14,7 +14,7 @@ fn main() {
let f = 42;
let _g = if f < 5 {
f.honk() //~ ERROR does not implement any method in scope named `honk`
f.honk() //~ ERROR no method named `honk` found
}
else {
()

View File

@ -11,5 +11,5 @@
#![feature(unboxed_closures)]
fn main() {
"".homura()(); //~ ERROR does not implement any method
"".homura()(); //~ ERROR no method named `homura` found
}

View File

@ -11,7 +11,7 @@
struct Homura;
fn akemi(homura: Homura) {
let Some(ref madoka) = Some(homura.kaname()); //~ ERROR does not implement any method
let Some(ref madoka) = Some(homura.kaname()); //~ ERROR no method named `kaname` found
madoka.clone(); //~ ERROR the type of this value must be known in this context
}

View File

@ -22,5 +22,5 @@ impl<A> vec_monad<A> for Vec<A> {
}
fn main() {
["hi"].bind(|x| [x] );
//~^ ERROR type `[&str; 1]` does not implement any method in scope named `bind`
//~^ ERROR no method named `bind` found for type `[&str; 1]` in the current scope
}

View File

@ -20,5 +20,5 @@ impl Drop for C {
fn main() {
let c = C{ x: 2};
let _d = c.clone(); //~ ERROR does not implement any method in scope
let _d = c.clone(); //~ ERROR no method named `clone` found
}

View File

@ -11,7 +11,7 @@
trait A {
fn a(&self) {
|| self.b()
//~^ ERROR type `&Self` does not implement any method in scope named `b`
//~^ ERROR no method named `b` found for type `&Self` in the current scope
//~| ERROR mismatched types
//~| expected `()`
//~| found closure

View File

@ -23,7 +23,7 @@ trait Add {
impl Add for isize {
fn to_int(&self) -> isize { *self }
fn add_dynamic(&self, other: &Add) -> isize {
self.to_int() + other.to_int() //~ ERROR multiple applicable methods in scope
self.to_int() + other.to_int() //~ ERROR multiple applicable items in scope
}
}

View File

@ -17,7 +17,7 @@ impl Obj {
return 1+1 == 2
}
pub fn chirp(&self) {
self.boom(); //~ ERROR `&Obj` does not implement any method in scope named `boom`
self.boom(); //~ ERROR no method named `boom` found for type `&Obj` in the current scope
}
}

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: type `&Foo` does not implement any method in scope named `foo`
trait Foo {
fn foo(self: Box<Self>);
}
@ -20,4 +18,5 @@ impl Foo for isize {
fn main() {
(&5 as &Foo).foo();
//~^ ERROR: no method named `foo` found for type `&Foo` in the current scope
}

View File

@ -71,15 +71,15 @@ impl ManyImplTrait for Myisize {}
fn no_param_bound(u: usize, m: Myisize) -> usize {
u.f8(42) + u.f9(342) + m.fff(42)
//~^ ERROR type `usize` does not implement any method in scope named `f9`
//~^ ERROR no method named `f9` found for type `usize` in the current scope
//~^^ NOTE found defined static methods, maybe a `self` is missing?
//~^^^ ERROR type `Myisize` does not implement any method in scope named `fff`
//~^^^ ERROR no method named `fff` found for type `Myisize` in the current scope
//~^^^^ NOTE found defined static methods, maybe a `self` is missing?
}
fn param_bound<T: ManyImplTrait>(t: T) -> bool {
t.is_str()
//~^ ERROR type `T` does not implement any method in scope named `is_str`
//~^ ERROR no method named `is_str` found for type `T` in the current scope
//~^^ NOTE found defined static methods, maybe a `self` is missing?
}

View File

@ -13,5 +13,5 @@
struct Foo;
fn main() {
Foo::bar(); //~ ERROR type `Foo` does not implement any method in scope named `bar`
Foo::bar(); //~ ERROR no associated item named `bar` found for type `Foo` in the current scope
}

View File

@ -12,7 +12,7 @@
macro_rules! fake_method_stmt { //~ NOTE in expansion of
() => {
1.fake() //~ ERROR does not implement any method
1.fake() //~ ERROR no method named `fake` found
}
}
@ -30,7 +30,7 @@ macro_rules! fake_anon_field_stmt { //~ NOTE in expansion of
macro_rules! fake_method_expr { //~ NOTE in expansion of
() => {
1.fake() //~ ERROR does not implement any method
1.fake() //~ ERROR no method named `fake` found
}
}

View File

@ -25,6 +25,6 @@ fn main() {
let y = Foo;
y.zero()
.take() //~ ERROR type `Foo` does not implement any method in scope named `take`
.take() //~ ERROR no method named `take` found for type `Foo` in the current scope
.one(0);
}

View File

@ -16,7 +16,7 @@ fn foo<F>(f: F) where F: FnMut(Foo) {}
fn main() {
foo(|s| s.is_empty());
//~^ ERROR does not implement any method
//~^ ERROR no method named `is_empty` found
//~^^ HELP #1: `core::slice::SliceExt`
//~^^^ HELP #2: `core::str::StrExt`
}

View File

@ -33,36 +33,36 @@ fn main() {
1u32.method();
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
//~^^ ERROR does not implement
//~^^ ERROR no method named
//~^^^ HELP `foo::Bar`
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
std::rc::Rc::new(&mut Box::new(&1u32)).method();
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
//~^^ ERROR does not implement
//~^^ ERROR no method named
//~^^^ HELP `foo::Bar`
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
'a'.method();
//~^ ERROR does not implement
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `foo::Bar`
std::rc::Rc::new(&mut Box::new(&'a')).method();
//~^ ERROR does not implement
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `foo::Bar`
1i32.method();
//~^ ERROR does not implement
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
std::rc::Rc::new(&mut Box::new(&1i32)).method();
//~^ ERROR does not implement
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
Foo.method();
//~^ ERROR does not implement
//~^^ HELP following traits define a method `method`, perhaps you need to implement one of them
//~^ ERROR no method named
//~^^ HELP following traits define an item `method`, perhaps you need to implement one of them
//~^^^ HELP `foo::Bar`
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
//~^^^^^ HELP `no_method_suggested_traits::reexport::Reexported`
@ -70,8 +70,8 @@ fn main() {
//~^^^^^^^ HELP `no_method_suggested_traits::qux::PrivPub`
//~^^^^^^^^ HELP `no_method_suggested_traits::quz::PrivPriv`
std::rc::Rc::new(&mut Box::new(&Foo)).method();
//~^ ERROR does not implement
//~^^ HELP following traits define a method `method`, perhaps you need to implement one of them
//~^ ERROR no method named
//~^^ HELP following traits define an item `method`, perhaps you need to implement one of them
//~^^^ HELP `foo::Bar`
//~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
//~^^^^^ HELP `no_method_suggested_traits::reexport::Reexported`
@ -80,55 +80,55 @@ fn main() {
//~^^^^^^^^ HELP `no_method_suggested_traits::quz::PrivPriv`
1u64.method2();
//~^ ERROR does not implement
//~^^ HELP the following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP the following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
std::rc::Rc::new(&mut Box::new(&1u64)).method2();
//~^ ERROR does not implement
//~^^ HELP the following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP the following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
no_method_suggested_traits::Foo.method2();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
no_method_suggested_traits::Bar::X.method2();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method2`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
//~^^^ HELP `foo::Bar`
Foo.method3();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method3`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
std::rc::Rc::new(&mut Box::new(&Foo)).method3();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method3`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
Bar::X.method3();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method3`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
//~^ ERROR does not implement
//~^^ HELP following trait defines a method `method3`, perhaps you need to implement it
//~^ ERROR no method named
//~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
// should have no help:
1_usize.method3(); //~ ERROR does not implement
std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR does not implement
no_method_suggested_traits::Foo.method3(); //~ ERROR does not implement
1_usize.method3(); //~ ERROR no method named
std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR no method named
no_method_suggested_traits::Foo.method3(); //~ ERROR no method named
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
//~^ ERROR does not implement
no_method_suggested_traits::Bar::X.method3(); //~ ERROR does not implement
//~^ ERROR no method named
no_method_suggested_traits::Bar::X.method3(); //~ ERROR no method named
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
//~^ ERROR does not implement
//~^ ERROR no method named
}

View File

@ -15,6 +15,6 @@ fn main() {
let y : *const libc::c_void = x as *const libc::c_void;
unsafe {
let _z = (*y).clone();
//~^ ERROR does not implement any method in scope
//~^ ERROR no method named `clone` found
}
}

View File

@ -41,6 +41,6 @@ fn foo(i:isize) -> foo {
fn main() {
let x = foo(10);
let _y = x.clone(); //~ ERROR does not implement any method in scope
let _y = x.clone(); //~ ERROR no method named `clone` found
println!("{:?}", x);
}

View File

@ -19,19 +19,19 @@ trait Foo {
fn borrowed_receiver(x: &Foo) {
x.borrowed();
x.borrowed_mut(); // See [1]
x.owned(); //~ ERROR does not implement any method
x.owned(); //~ ERROR no method named `owned` found
}
fn borrowed_mut_receiver(x: &mut Foo) {
x.borrowed();
x.borrowed_mut();
x.owned(); //~ ERROR does not implement any method
x.owned(); //~ ERROR no method named `owned` found
}
fn owned_receiver(x: Box<Foo>) {
x.borrowed();
x.borrowed_mut(); // See [1]
x.managed(); //~ ERROR does not implement any method
x.managed(); //~ ERROR no method named `managed` found
x.owned();
}

View File

@ -22,5 +22,5 @@ impl T for i32 {}
fn main() {
let x = &42i32;
x.foo(); //~ERROR: type `&i32` does not implement any method in scope named `foo`
x.foo(); //~ERROR: no method named `foo` found for type `&i32` in the current scope
}

View File

@ -14,5 +14,5 @@ fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn main() {
let mut_ = to_fn_mut(|x| x);
mut_.call((0, )); //~ ERROR does not implement any method in scope named `call`
mut_.call((0, )); //~ ERROR no method named `call` found
}

View File

@ -31,5 +31,5 @@ impl Foo for Bar {
fn main() {
let x = box Bar { x: 10 };
let y: Box<Foo> = x as Box<Foo>;
let _z = y.clone(); //~ ERROR does not implement any method in scope
let _z = y.clone(); //~ ERROR no method named `clone` found
}

View File

@ -20,6 +20,6 @@ impl Drop for r {
fn main() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let i = Box::new(r { b: true });
let _j = i.clone(); //~ ERROR not implement
let _j = i.clone(); //~ ERROR no method named `clone` found
println!("{:?}", i);
}