2017-06-02 12:15:13 -05:00
|
|
|
// aux-build:no_method_suggested_traits.rs
|
|
|
|
extern crate no_method_suggested_traits;
|
|
|
|
|
2017-12-10 14:29:24 -06:00
|
|
|
struct Foo;
|
2017-06-02 12:15:13 -05:00
|
|
|
enum Bar { X }
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub trait Bar {
|
|
|
|
fn method(&self) {}
|
|
|
|
|
|
|
|
fn method2(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Bar for u32 {}
|
|
|
|
|
|
|
|
impl Bar for char {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// test the values themselves, and autoderef.
|
|
|
|
|
|
|
|
|
|
|
|
1u32.method();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR no method named
|
|
|
|
//~|items from traits can only be used if the trait is in scope
|
2017-06-02 12:15:13 -05:00
|
|
|
std::rc::Rc::new(&mut Box::new(&1u32)).method();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^items from traits can only be used if the trait is in scope
|
2020-01-08 10:05:31 -06:00
|
|
|
//~| ERROR no method named `method` found for struct
|
2017-06-02 12:15:13 -05:00
|
|
|
|
|
|
|
'a'.method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&'a')).method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
1i32.method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&1i32)).method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
Foo.method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&Foo)).method();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
1u64.method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&1u64)).method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
no_method_suggested_traits::Foo.method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
no_method_suggested_traits::Bar::X.method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
Foo.method3();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&Foo)).method3();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
Bar::X.method3();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
|
|
|
|
//~^ ERROR no method named
|
|
|
|
|
|
|
|
// should have no help:
|
|
|
|
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 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 no method named
|
|
|
|
}
|